From d7775c4cb8ae973f834ac05055587665f8f163d3 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sat, 29 Jul 2017 00:42:16 +0200 Subject: [PATCH] SSH support hardware api call (#155) * Update config.json * Extend for support hardware and pretty print --- ssh/config.json | 2 +- ssh/hassio | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ssh/config.json b/ssh/config.json index 6f88a4d..818c87e 100644 --- a/ssh/config.json +++ b/ssh/config.json @@ -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/", diff --git a/ssh/hassio b/ssh/hassio index c5d4140..feb0b12 100644 --- a/ssh/hassio +++ b/ssh/hassio @@ -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