added support for operation via command instead of user

This commit is contained in:
Zehka
2021-11-07 18:02:14 +01:00
parent 8bb7f10d84
commit 30b027014e
2 changed files with 71 additions and 47 deletions

28
foodoor
View File

@ -9,15 +9,29 @@ if [ ! -e $PIPE_PATH ]
exit 1
fi
case $1 in
close)
echo close > $PIPE_PATH
action="$1"
isTriggerActivated="0"
if [ -z "$action" ]
then
action="$SSH_ORIGINAL_COMMAND"
isTriggerActivated="1"
fi
case $action in
close|open)
echo $action | tee $PIPE_PATH > /tmp/state
;;
open)
echo open > $PIPE_PATH
status)
;;
*)
echo "Usage: $(basename $0) { close, open}"
echo "Usage: $(basename $0) { close, open, status }"
exit 1
;;
;;
esac
if [ $isTriggerActivated -eq 1 ]
then
cat /tmp/state
sleep 2
fi