Skip to content

Instantly share code, notes, and snippets.

@pyropeter
Last active October 13, 2015 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pyropeter/4120953 to your computer and use it in GitHub Desktop.
Save pyropeter/4120953 to your computer and use it in GitHub Desktop.
Embassy of Nerdistan Tuerstatuserkennung
Dieser Code läuft z.Z. auf einem TP-Link-Router, an dessen Reset-Button-Port ein
einfacher Fischer-Technik-Taster hängt.
1. Passwort in upload.sh anpassen.
2. Dateien kopieren:
handler.sh -> /etc/hotplug.d/button/42-reset-tuerstatus
upload.sh -> /root/tuerstatus
3. Cronjob fuer /root/tuerstatus anlegen
#!/bin/sh
LED='/sys/class/leds/tp-link:green:qss/brightness'
if [ "$BUTTON" != reset ]; then
exit
fi
if [ "$ACTION" = pressed ]; then
echo 0 > /tmp/tuer_offen
echo 0 > "$LED"
elif [ "$ACTION" = released ]; then
echo 1 > /tmp/tuer_offen
echo 1 > "$LED"
fi
#!/bin/sh
SECRET='secret'
URL='http://embassy.ccchb.de/status/door/set'
if [ ! -r /tmp/tuer_offen ]; then
exit 1
fi
OFFEN=$(cat /tmp/tuer_offen)
wget-nossl -q -O - --post-data="secret=$SECRET&isopen=$OFFEN" "$URL" | \
head -c 4096 > /tmp/tuer_lastlog
echo $? > /tmp/tuer_exitstatus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment