Aggunto eventi cron_add_before, cron_add_after, cron_del_before, cron_del_after, ev_open_in_before, ev_open_in_after, exec_poweroff_before, exec_poweroff_after, exec_reboot_before, exec_reboot_after ed eseguito bugfix vari
This commit is contained in:
@@ -39,10 +39,10 @@ function cron_del {
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
trigger_event "cron_del_before" "$1" "$2"
|
||||
$SED "$START,${END}d" "$TMP_CRON_FILE" | $SED '$!N; /^\(.*\)\n\1$/!P; D' | $CRONTAB -
|
||||
#$CRONTAB "$TMP_CRON_FILE"
|
||||
rm "$TMP_CRON_FILE"
|
||||
trigger_event "cron_del_after" "$1" "$2"
|
||||
|
||||
}
|
||||
|
||||
@@ -206,8 +206,10 @@ function cron_add {
|
||||
echo "$CRON_DISABLED$CRON_M $CRON_H $CRON_DOM $CRON_MON $CRON_DOW $CRON_COMMAND" >> "$TMP_CRON_FILE2"
|
||||
echo "# END cron $CRON_TYPE $CRON_ARG" >> "$TMP_CRON_FILE2"
|
||||
|
||||
trigger_event "cron_add_before" "$CRON_TYPE" "$CRON_ARG" "$CRON_DISABLED$CRON_M $CRON_H $CRON_DOM $CRON_MON $CRON_DOW $CRON_COMMAND"
|
||||
$CRONTAB "$TMP_CRON_FILE2"
|
||||
rm "$TMP_CRON_FILE" "$TMP_CRON_FILE2"
|
||||
trigger_event "cron_add_after" "$CRON_TYPE" "$CRON_ARG" "$CRON_DISABLED$CRON_M $CRON_H $CRON_DOM $CRON_MON $CRON_DOW $CRON_COMMAND"
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,19 +5,6 @@
|
||||
|
||||
function trigger_event {
|
||||
|
||||
# check_rain_online_after
|
||||
# check_rain_online_before
|
||||
# check_rain_online_change
|
||||
# check_rain_sensor_after
|
||||
# check_rain_sensor_before
|
||||
# check_rain_sensor_change
|
||||
# ev_close_after
|
||||
# ev_close_before
|
||||
# ev_open_after
|
||||
# ev_open_before
|
||||
# init_after
|
||||
# init_before
|
||||
|
||||
local EVENT="$1"
|
||||
local CAUSE="$2"
|
||||
local current_event_dir="$EVENT_DIR/$EVENT"
|
||||
@@ -34,6 +21,22 @@ function trigger_event {
|
||||
$f "$EVENT" "$ALIAS" "$FORCE" `date +%s` &> /dev/null
|
||||
;;
|
||||
|
||||
"ev_open_in_before")
|
||||
ALIAS="$2"
|
||||
FORCE="$3"
|
||||
local MINUTE_START="$4"
|
||||
local MINUTE_STOP="$5"
|
||||
$f "$EVENT" "$ALIAS" "$FORCE" "$MINUTE_START" "$MINUTE_STOP" `date +%s` &> /dev/null
|
||||
;;
|
||||
|
||||
"ev_open_in_after")
|
||||
ALIAS="$2"
|
||||
FORCE="$3"
|
||||
local CRON_START="$4"
|
||||
local CRON_STOP="$5"
|
||||
$f "$EVENT" "$ALIAS" "$FORCE" "$CRON_START" "$CRON_STOP" `date +%s` &> /dev/null
|
||||
;;
|
||||
|
||||
"ev_close_before" | "ev_close_after")
|
||||
ALIAS="$2"
|
||||
$f "$EVENT" "$ALIAS" `date +%s` &> /dev/null
|
||||
@@ -45,11 +48,40 @@ function trigger_event {
|
||||
$f "$EVENT" "$STATE" `date +%s` &> /dev/null
|
||||
;;
|
||||
|
||||
"check_rain_online_before" | "check_rain_online_after" | "check_rain_online_change")
|
||||
"check_rain_online_before")
|
||||
STATE="$2"
|
||||
$f "$EVENT" "$STATE" `date +%s` &> /dev/null
|
||||
;;
|
||||
|
||||
"check_rain_online_after" | "check_rain_online_change")
|
||||
STATE="$2"
|
||||
WEATHER="$3"
|
||||
$f "$EVENT" "$STATE" "$WEATHER" `date +%s` &> /dev/null
|
||||
;;
|
||||
|
||||
|
||||
"init_before" | "init_after")
|
||||
STATE="$2"
|
||||
$f "$EVENT" `date +%s` &> /dev/null
|
||||
;;
|
||||
|
||||
"cron_add_before" | "cron_add_after")
|
||||
local CRON_TYPE="$2"
|
||||
local CRON_ARG="$3"
|
||||
local CRON_ELEMENT="$4"
|
||||
$f "$EVENT" "$CRON_TYPE" "$CRON_ARG" "$CRON_ELEMENT" `date +%s` &> /dev/null
|
||||
;;
|
||||
|
||||
"cron_del_before" | "cron_del_after")
|
||||
local CRON_TYPE="$2"
|
||||
local CRON_ARG="$3"
|
||||
$f "$EVENT" "$CRON_TYPE" "$CRON_ARG" `date +%s` &> /dev/null
|
||||
;;
|
||||
|
||||
"exec_poweroff_before" | "exec_poweroff_after" | "exec_reboot_before" | "exec_reboot_after" )
|
||||
$f "$EVENT" `date +%s` &> /dev/null
|
||||
;;
|
||||
|
||||
*)
|
||||
$f "$EVENT" "$CAUSE" `date +%s` &> /dev/null
|
||||
;;
|
||||
|
||||
@@ -35,11 +35,11 @@ function check_rain_online {
|
||||
echo "$current_observation" > "$STATUS_DIR/last_weather_online"
|
||||
if [ "$current_state_rain_online" != "$last_state_rain_online" ]; then
|
||||
echo "$current_state_rain_online" > "$STATUS_DIR/last_state_rain_online"
|
||||
trigger_event "check_rain_online_change" "$current_state_rain_online"
|
||||
trigger_event "check_rain_online_change" "$current_state_rain_online" "$weather"
|
||||
fi
|
||||
fi
|
||||
|
||||
trigger_event "check_rain_online_after" "$current_state_rain_online"
|
||||
trigger_event "check_rain_online_after" "$current_state_rain_online" "$weather"
|
||||
}
|
||||
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user