Update ssh hassio cli (#172)

* Update config.json

* add check support

* extend api ouput

* Update hassio
This commit is contained in:
Pascal Vizeli
2017-08-16 09:57:39 +02:00
committed by GitHub
parent 052a558419
commit 0c1718e51c
2 changed files with 24 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "SSH server",
"version": "2.6",
"version": "2.7",
"slug": "ssh",
"description": "Allows connections over SSH",
"url": "https://home-assistant.io/addons/ssh/",

View File

@@ -10,6 +10,7 @@ HomeAssistant:
$ hassio homeassistant logs
$ hassio homeassistant restart
$ hassio homeassistant update
$ hassio homeassistant check
Host:
$ hassio host hardware
@@ -35,20 +36,38 @@ function call_api() {
if ! api_ret="$(curl -s -X $command "http://hassio/$1/$2")"; then
echo "API error: $api_ret"
exit 1
return 1
fi
if [ "$2" == "logs" ]; then
echo "$api_ret"
else
echo "$api_ret" | jq .
return 0
fi
result="$(echo "$api_ret" | jq --raw-output ".result")"
# On error
if [ "$result" == "error" ]; then
message="$(echo "$api_ret" | jq --raw-output ".message // empty")"
echo "Error on $1/$2:" "$message"
return 0
fi
# On success
data="$(echo "$api_ret" | jq 'if .data == {} then empty else .data end')"
if [ ! -z "$data" ]; then
echo "$data" | jq .
else
echo "Success $1/$2"
fi
return 0
}
######
# homeassistant functions
if [ "$1" == "homeassistant" ]; then
hass_cmd=('logs' 'restart' 'update')
hass_cmd=('logs' 'restart' 'update' 'check')
if [[ ! ${hass_cmd[*]} =~ $2 ]]; then
echo "No homeassistant command '$2' found!"
exit 1