2014-10-29 18:33:36 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
|
|
|
PIPE_PATH=/var/run/foodoord.pipe
|
|
|
|
|
|
|
|
if [ ! -e $PIPE_PATH ]
|
|
|
|
then
|
|
|
|
echo "Pipe missing. Check daemon status."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-11-07 17:02:14 +00:00
|
|
|
action="$1"
|
|
|
|
isTriggerActivated="0"
|
|
|
|
|
|
|
|
if [ -z "$action" ]
|
|
|
|
then
|
|
|
|
action="$SSH_ORIGINAL_COMMAND"
|
|
|
|
isTriggerActivated="1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
case $action in
|
|
|
|
close|open)
|
2021-11-07 17:52:41 +00:00
|
|
|
echo $action | tee $PIPE_PATH |sed 's/open/UNLOCKED/;s/close/LOCKED/' > /state
|
2014-10-29 18:33:36 +00:00
|
|
|
;;
|
2021-11-07 17:02:14 +00:00
|
|
|
status)
|
2014-10-29 18:33:36 +00:00
|
|
|
;;
|
|
|
|
*)
|
2021-11-07 17:02:14 +00:00
|
|
|
echo "Usage: $(basename $0) { close, open, status }"
|
2014-10-29 18:33:36 +00:00
|
|
|
exit 1
|
2021-11-07 17:02:14 +00:00
|
|
|
;;
|
2014-10-29 18:33:36 +00:00
|
|
|
esac
|
2021-11-07 17:02:14 +00:00
|
|
|
|
|
|
|
if [ $isTriggerActivated -eq 1 ]
|
|
|
|
then
|
2021-11-07 17:49:54 +00:00
|
|
|
cat /state
|
2021-11-07 17:02:14 +00:00
|
|
|
sleep 2
|
|
|
|
fi
|