script added

This commit is contained in:
Martin Ness 2015-09-28 23:06:01 +02:00
parent e813711ad8
commit aab9eb3700
2 changed files with 37 additions and 0 deletions

13
push.d/skeleton.sh Normal file
View file

@ -0,0 +1,13 @@
#!/bin/sh
case "$1" in
ON)
echo 'ON'
;;
HALF)
echo 'HALF'
;;
OFF)
echo 'OFF'
;;
esac

24
push.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/sh -e
DEV='/dev/ttyUSB0'
DIR='push.d'
stty -F "$DEV" 9600 -brkint -icrnl -imaxbel -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
if [ -c "$DEV" ]; then
sleep 2 && echo '?' >> "$DEV" &
fi
while true; do
if [ -c "$DEV" ]; then
read state < "$DEV"
case "$state" in
ON|HALF|OFF)
for f in $(find -O3 -P "$DIR" -type f -executable | sort -n); do
"$f" "$state" || echo "File $f exited with error $?"
done
;;
esac
else
sleep 10
fi
done