Last active
October 13, 2015 01:57
-
-
Save pyropeter/4120953 to your computer and use it in GitHub Desktop.
Embassy of Nerdistan Tuerstatuserkennung
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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