diff options
author | Milan Oberkirch | 2015-08-09 21:46:02 +1200 |
---|---|---|
committer | Milan Oberkirch | 2015-08-09 21:46:02 +1200 |
commit | c447a55f3a938a0512577cd5da3ee915c0bdce0d (patch) | |
tree | 44c71ff2a28efe4936bb03dce88a322633ac397d | |
parent | 815d416b037df35305c14ea7dfbb043f64a85d98 (diff) | |
download | aur-c447a55f3a938a0512577cd5da3ee915c0bdce0d.tar.gz |
Enable username login.
-rwxr-xr-x | zenbu-login.bash | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/zenbu-login.bash b/zenbu-login.bash index b62e9756cc9b..d37003164a07 100755 --- a/zenbu-login.bash +++ b/zenbu-login.bash @@ -2,13 +2,6 @@ set -e __NAME__="zenbu-login" -# the following file should define 2 variables: $username and $password: -source /etc/"${__NAME__}" -if [[ "$username" == "" ]]; then - echo You need to define username and password in /etc/${__NAME__}. - exit 1 -fi - function zenbu-login () { post_data="form_request=login&gw_address=10.10.24.1&gw_port=2060&gw_id=ZenBu10289&mac=EC%3A0E%3AC4%3A1C%3A8E%3A2F&auth_source=default-network&username=$username&password=$password&form_submit=login" url="$(curl\ @@ -22,5 +15,27 @@ function zenbu-login () { # execute if called directly if grep -q "${__NAME__}" <<< "$0"; then + usage="Usage: $0 [[username] [password/code]\n\ + You can define username and password in /etc/${__NAME__}" + if egrep -q "[[:alnum:]]+" <<< "$1"; then + if [ "$2" ]; then + username="$1" + password="$2" + else + username="" + password="$1" + fi + else + if [ "$1" ]; then + echo -e ${usage} + exit 1 + fi + # the following file should define 2 variables: $username and $password + source /etc/"${__NAME__}" + if [ -z "$password" ]; then + echo -e ${usage} + exit 1 + fi + fi ${__NAME__} fi |