phone_notification is first method, was later replaces by doorbuzz_wrapper from the doorbuzz project

master
Gunstick 2015-05-11 00:28:03 +02:00
parent f5666ab147
commit 4dc5da4a26
5 changed files with 68 additions and 1 deletions

25
scripts/doorbuzz_wrapper.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
# put into /root/.ssh/authorized_keys this:
# command="/root/pidor/scripts/doorbuzz_wrapper.sh" ssh-rsa AAAAB3.......................7fEbKbG2UcaO4d0YZ67T pi@doorbuzz
while read cmd
do
if [ "$cmd" = "spacestatus" ]
then
cat /var/run/spacestatus
fi
if [ "$cmd" = "flashon" ]
then
logger -t $(basename $0) "phone status change detected"
logger -t $(basename $0) "phone ring light on"
/usr/local/bin/433send 2 15 1 1 >&2
fi
if [ "$cmd" = "flashoff" ]
then
logger -t $(basename $0) "phone status change detected"
logger -t $(basename $0) "phone ring light off"
/usr/local/bin/433send 2 15 1 0 >&2
fi
done

View File

@ -15,6 +15,10 @@ then
done done
logger -t $(basename $0) "all lights should be off now" logger -t $(basename $0) "all lights should be off now"
fi fi
if [ "$1" = "released" ]
then # switch status lights on, in any case
/usr/local/bin/433send 2 1A 2 1 #on
fi
if [ "$1" = "released" ] && # the door has been opened if [ "$1" = "released" ] && # the door has been opened
# [ "$(cat /run/spacestatus)" = "open" ] && # status is open # [ "$(cat /run/spacestatus)" = "open" ] && # status is open
# [ "$(stat -c %Y /run/spacestatus)" -gt "$(date --date "50 minutes ago" +%s)" ] && # since less than 5 minutes # [ "$(stat -c %Y /run/spacestatus)" -gt "$(date --date "50 minutes ago" +%s)" ] && # since less than 5 minutes

33
scripts/phone_notification.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
url=http://10.2.113.137
run_file="/var/run/phone_ringing_status"
while true
do
sleep 1
if ! [ "$(cat /var/run/spacestatus)" = "open" ]; then
continue
else
if ! [ -e "$run_file" ]; then
touch $run_file
fi
curl -q "$url" 2>/dev/null | grep Ringing
new_status=$?
old_status=$(cat ${run_file})
if [ "$new_status" -eq "$old_status" ]; then
continue
fi
logger -t $(basename $0) "phone status change detected"
if [ "$new_status" -eq 0 ]; then
logger -t $(basename $0) "phone ring light on"
/usr/local/bin/433send 2 15 1 1
else
logger -t $(basename $0) "phone ring light off"
/usr/local/bin/433send 2 15 1 0
fi
echo $new_status > ${run_file}
fi
done

View File

@ -15,6 +15,10 @@ then
done done
logger -t $(basename $0) "all lights should be off now" logger -t $(basename $0) "all lights should be off now"
fi fi
if [ "$1" = "released" ]
then # switch status lights on, in any case
/usr/local/bin/433send 2 1A 2 1 #on
fi
if [ "$1" = "released" ] && # the door has been opened if [ "$1" = "released" ] && # the door has been opened
# [ "$(cat /run/spacestatus)" = "open" ] && # status is open # [ "$(cat /run/spacestatus)" = "open" ] && # status is open
# [ "$(stat -c %Y /run/spacestatus)" -gt "$(date --date "50 minutes ago" +%s)" ] && # since less than 5 minutes # [ "$(stat -c %Y /run/spacestatus)" -gt "$(date --date "50 minutes ago" +%s)" ] && # since less than 5 minutes

View File

@ -72,4 +72,5 @@ po::powerokwait:/etc/init.d/powerfail stop
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100 T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
# pidor # pidor
P0:2345:respawn:/root/lockbutton.sh P0:2345:respawn:/root/pidor/scripts/lockbutton.sh
#P1:2345:respawn:/root/pidor/scripts/phone_notification.sh