Skip to content

Instantly share code, notes, and snippets.

@zembutsu
Last active December 28, 2015 00:29
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 zembutsu/7413905 to your computer and use it in GitHub Desktop.
Save zembutsu/7413905 to your computer and use it in GitHub Desktop.
serf event handler
#!/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