ubnt-manager: run through shellcheck
Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
5fc06d939f
commit
a4b08f7c1c
1 changed files with 7 additions and 9 deletions
|
@ -13,14 +13,13 @@ rexec() {
|
||||||
local username="$2"
|
local username="$2"
|
||||||
local password="$3"
|
local password="$3"
|
||||||
local cmd="$4"
|
local cmd="$4"
|
||||||
raw=$(DROPBEAR_PASSWORD="$password" ssh -y $username@$target "$cmd" 2>/dev/null)
|
raw=$(DROPBEAR_PASSWORD="$password" ssh -y "$username@$target" "$cmd" 2>/dev/null)
|
||||||
ssh_result=$?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_json_dump() {
|
get_json_dump() {
|
||||||
local cmd="/usr/www/status.cgi"
|
local cmd="/usr/www/status.cgi"
|
||||||
rexec $* "$cmd"
|
rexec "$@" "$cmd"
|
||||||
echo $raw
|
echo "$raw"
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_device() {
|
handle_device() {
|
||||||
|
@ -29,7 +28,6 @@ handle_device() {
|
||||||
config_get target "$device" target
|
config_get target "$device" target
|
||||||
config_get username "$device" username
|
config_get username "$device" username
|
||||||
config_get password "$device" password
|
config_get password "$device" password
|
||||||
ssh_result=0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_device_to_list() {
|
add_device_to_list() {
|
||||||
|
@ -41,7 +39,7 @@ list_devices() {
|
||||||
device_list=""
|
device_list=""
|
||||||
config_load ubnt-manager
|
config_load ubnt-manager
|
||||||
config_foreach add_device_to_list device device_list
|
config_foreach add_device_to_list device device_list
|
||||||
echo $device_list
|
echo "$device_list"
|
||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
|
@ -59,7 +57,7 @@ while [ "$1" != "" ]; do
|
||||||
-t | --target)
|
-t | --target)
|
||||||
shift
|
shift
|
||||||
target=$1
|
target=$1
|
||||||
handle_device $target
|
handle_device "$target"
|
||||||
;;
|
;;
|
||||||
-j | --json)
|
-j | --json)
|
||||||
json=1
|
json=1
|
||||||
|
@ -74,6 +72,6 @@ while [ "$1" != "" ]; do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ! -z $json ]; then
|
if [ -n "$json" ]; then
|
||||||
get_json_dump $target $username $password | sed 's/Content-Type:\ application\/json//'
|
get_json_dump "$target" "$username" "$password" | sed 's/Content-Type:\ application\/json//'
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue