implementato comandi e socket server api per lo spengimento e riavvio del sistema. Corretto problema che lasciava sul sistema file di appoggio per i messaggi da inviare tramite socket server

This commit is contained in:
lejubila
2017-09-10 12:44:35 +02:00
parent 59b27365ed
commit e64f651cab
5 changed files with 55 additions and 4 deletions

View File

@@ -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

View File

@@ -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"
;;

View File

@@ -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##*/}
@@ -918,6 +940,14 @@ case "$1" in
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

2
scripts/poweroff.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
sudo /sbin/poweroff

2
scripts/reboot.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
sudo /sbin/reboot