2015-05-11 00:28:03 +02:00
|
|
|
#!/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"
|
2015-07-19 22:30:46 +02:00
|
|
|
$(dirname "$0")/lightcommander alarm on
|
|
|
|
#/usr/local/bin/433send 2 15 1 1
|
2015-05-11 00:28:03 +02:00
|
|
|
else
|
|
|
|
logger -t $(basename $0) "phone ring light off"
|
2015-07-19 22:30:46 +02:00
|
|
|
$(dirname "$0")/lightcommander alarm off
|
|
|
|
#/usr/local/bin/433send 2 15 1 0
|
2015-05-11 00:28:03 +02:00
|
|
|
fi
|
|
|
|
echo $new_status > ${run_file}
|
|
|
|
fi
|
|
|
|
done
|