foodoord/debian/usr/sbin/foodoor

35 lines
554 B
Plaintext
Raw Normal View History

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