20 lines
937 B
Bash
Executable File
20 lines
937 B
Bash
Executable File
#!/bin/bash
|
|
# changes level2 state by the state of the main door
|
|
# i.e. people have to leave it open to keep status open
|
|
sleep 1 # silly way to debounce
|
|
if [ "$1" = "pushed" ] &&
|
|
[ "$(cat /run/spacestatus)" = "open" ]
|
|
then
|
|
FORM_action="close" /root/pidor/webserver/cgi-bin/pidor.sh
|
|
/root/pidor/scripts/upd_status.sh
|
|
fi
|
|
if [ "$1" = "released" ] && # if switch was released (the door opened, or someone is playing with the switch)
|
|
[ "$(cat /run/spacestatus)" = "closed" ] # the status was closed
|
|
# [ $(stat -c "%Y" /run/spacestatus) -lt $(date --date "1 hour ago" +%s) ] # since at least one hour
|
|
then
|
|
FORM_action="open" /root/pidor/webserver/cgi-bin/pidor.sh
|
|
/root/pidor/scripts/upd_status.sh
|
|
# echo "intrusion detected: space was closed since some time and locked, but now is still closed but unlocked" | wall
|
|
# logger -t $(basename $0) "INTRUSION ALARM. door was opened while status is closed"
|
|
fi
|