Last active
December 28, 2015 00:29
-
-
Save zembutsu/7413905 to your computer and use it in GitHub Desktop.
serf event handler
This file contains 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 | |
while read line | |
do | |
echo ${line} | |
HOSTNAME=`echo ${line} | cut -d ' ' -f 1` | |
ADDRESS=`echo ${line} | cut -d ' ' -f 2` | |
case ${SERF_EVENT} in | |
"member-join") | |
#say "Raspberry Client ${ADDRESS} joined" | |
osascript <<__EOM__ | |
tell application "AppleScript Runner" | |
activate | |
#beep 2 | |
display alert "Find RaspberyPi client" message "IP addr:${ADDRESS}\nHostname: $HOSTNAME" | |
end tell | |
__EOM__ | |
;; | |
"member-leave" | "member-failed") | |
#say "Raspberry Client ${ADDRESS} left" | |
osascript <<__EOM__ | |
tell application "AppleScript Runner" | |
activate | |
#beep 3 | |
display alert "Missing client" message "IP addr:${ADDRESS}\nHostname: $HOSTNAME" | |
end tell | |
__EOM__ | |
;; | |
\?) | |
echo "other";; | |
esac | |
break | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment