SSH support hardware api call (#155)

* Update config.json

* Extend for support hardware and pretty print
This commit is contained in:
Pascal Vizeli
2017-07-29 00:42:16 +02:00
committed by GitHub
parent 1a5e48b909
commit d7775c4cb8
2 changed files with 14 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "SSH server",
"version": "2.1",
"version": "2.2",
"slug": "ssh",
"description": "Connect to your server over SSH",
"url": "https://home-assistant.io/addons/ssh/",

View File

@@ -14,6 +14,7 @@ HomeAssistant:
$ hassio homeassistant update
Host:
$ hassio host hardware
$ hassio host reboot
$ hassio host shutdown
$ hassio host update
@@ -25,7 +26,12 @@ function call_api() {
echo "API error: $api_ret"
exit 1
fi
echo "$api_ret"
if [ "$3" == "logs" ]; then
echo "$api_ret"
else
echo "$api_ret" | jq .
fi
}
######
@@ -37,7 +43,6 @@ if [ "$1" == "homeassistant" ]; then
exit 1
fi
# logs
if [ "$2" == "logs" ]; then
call_api GET "$1" "$2"
else
@@ -48,11 +53,15 @@ fi
######
# host functions
if [ "$1" == "host" ]; then
hass_cmd=('reboot' 'shutdown' 'update')
hass_cmd=('reboot' 'shutdown' 'update' 'hardware')
if [[ ! ${hass_cmd[*]} =~ $2 ]]; then
echo "No host command '$2' found!"
exit 1
fi
call_api POST "$1" "$2"
if [ "$2" == "hardware" ]; then
call_api GET "$1" "$2"
else
call_api POST "$1" "$2"
fi
fi