mirror of
https://github.com/aljazceru/addons.git
synced 2026-02-07 14:14:23 +01:00
Update ssh hassio cli (#172)
* Update config.json * add check support * extend api ouput * Update hassio
This commit is contained in:
@@ -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/",
|
||||
|
||||
27
ssh/hassio
27
ssh/hassio
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user