diff --git a/CHANGELOG.md b/CHANGELOG.md index 551af01..292fdd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,11 @@ -## 0.4.5 - xx/08/2017 +## 0.5.0 - xx/08/2017 - Implemented driver subsystem for interfacing with other board - Added driver spb16ch for interfacing with "Smart Power Board 16 channel with RTC" - Added socket server api for close all zones and disable all scheduling +- Implement command and socket server api to perform system shutdown and reboot - Fix problem with cron management on similar type cron - Fix bug: in case of rain the weather data were not updated +- Fix bug: delete the temporary files for managing the socket server messages that were kept on the system ## 0.4.4 - 17/06/2017 - Remove lock/unlock from init function for resove bug diff --git a/include/socket.include.sh b/include/socket.include.sh index 79059ea..5a8fa3c 100644 --- a/include/socket.include.sh +++ b/include/socket.include.sh @@ -205,6 +205,20 @@ function socket_server_command { ;; + reboot) + message_write "warning" "System reboot is started" + json_status + local PATH_SCRIPT=`$READLINK -f "$DIR_SCRIPT/$NAME_SCRIPT"` + nohup $PATH_SCRIPT reboot > /dev/null 2>&1 & + ;; + + poweroff) + message_write "warning" "System shutdown is started" + json_status + local PATH_SCRIPT=`$READLINK -f "$DIR_SCRIPT/$NAME_SCRIPT"` + nohup $PATH_SCRIPT poweroff > /dev/null 2>&1 & + ;; + *) json_error 0 "invalid command" ;; diff --git a/piGarden.sh b/piGarden.sh index c80545e..0c86a3c 100755 --- a/piGarden.sh +++ b/piGarden.sh @@ -588,6 +588,9 @@ function show_usage { echo -e "\t$NAME_SCRIPT start_socket_server [force] start socket server, with 'force' parameter force close socket server if already open" echo -e "\t$NAME_SCRIPT stop_socket_server stop socket server" echo -e "\n" + echo -e "\t$NAME_SCRIPT reboot reboot system" + echo -e "\t$NAME_SCRIPT poweroff shutdown system" + echo -e "\n" echo -e "\t$NAME_SCRIPT set_cron_init set crontab for initialize control unit" echo -e "\t$NAME_SCRIPT del_cron_init remove crontab for initialize control unit" echo -e "\t$NAME_SCRIPT set_cron_start_socket_server set crontab for start socket server" @@ -706,6 +709,25 @@ function send_identifier { } +# +# Spenge il sistema +# +function exec_poweroff { + local PATH_SCRIPT=`$READLINK -f "$DIR_SCRIPT/scripts/poweroff.sh"` +echo "$PATH_SCRIPT" > tmp/prova.txt + sleep 15 + . $PATH_SCRIPT +} + +# +# Spenge il sistema +# +function exec_reboot { + local PATH_SCRIPT=`$READLINK -f "$DIR_SCRIPT/scripts/reboot.sh"` + sleep 15 + . $PATH_SCRIPT +} + function debug1 { . "$DIR_SCRIPT/debug/debug1.sh" } @@ -715,8 +737,8 @@ function debug2 { } VERSION=0 -SUB_VERSION=4 -RELEASE_VERSION=5 +SUB_VERSION=5 +RELEASE_VERSION=0 DIR_SCRIPT=`dirname $0` NAME_SCRIPT=${0##*/} @@ -917,6 +939,14 @@ case "$1" in get_cron_close) get_cron_close $2 ;; + + reboot) + exec_reboot + ;; + + poweroff) + exec_poweroff + ;; debug1) debug1 $2 $3 $4 $5 @@ -933,7 +963,8 @@ case "$1" in ;; esac -# Elimina eventuali file temporane utilizzati per la gestione dei cron +# Elimina eventuali file temporani utilizzati per la gestione dei cron e i messaggi per il sockt server rm "$TMP_CRON_FILE" 2> /dev/null rm "$TMP_CRON_FILE-2" 2> /dev/null +reset_messages &> /dev/null diff --git a/scripts/poweroff.sh b/scripts/poweroff.sh new file mode 100755 index 0000000..51b4d26 --- /dev/null +++ b/scripts/poweroff.sh @@ -0,0 +1,2 @@ +#!/bin/bash +sudo /sbin/poweroff diff --git a/scripts/reboot.sh b/scripts/reboot.sh new file mode 100755 index 0000000..36f1ffa --- /dev/null +++ b/scripts/reboot.sh @@ -0,0 +1,2 @@ +#!/bin/bash +sudo /sbin/reboot