2014-11-14 23:03:24 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# changes level2 state by the state of the main door
|
|
|
|
# i.e. people have to leave it open to keep status open
|
2015-01-01 22:24:58 +01:00
|
|
|
sleep 1 # silly way to debounce
|
2014-11-14 23:03:24 +01:00
|
|
|
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
|