-
-
Save cstrat/db2be23525cc2607b2ab94b6054be9a6 to your computer and use it in GitHub Desktop.
Firewalla reboot notification via IFTT
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/bash | |
dir=$(dirname "$0") | |
IFTTTKEY="$(cat $dir/rebootdata.txt | grep IFTTTKEY | cut -f2 -d "=" )" | |
IFTTTrigger="$(cat $dir/rebootdata.txt | grep IFTTTTrigger | cut -f2 -d "=" )" | |
echo $IFTTTrigger | |
ONLINE=1 | |
while [ $ONLINE -ne 0 ] | |
do | |
ping -q -c 1 -w 1 www.ifttt.com >/dev/null 2>&1 | |
ONLINE=$? | |
if [ $ONLINE -ne 0 ] | |
then | |
sleep 60 | |
fi | |
done | |
echo "We are on line!" | |
IMAGE="https://avatars2.githubusercontent.com/u/21322342?s=200&v=4" | |
URL="firewalla://" | |
PACKAGE="Firewalla Gold reboot" | |
pushAlert () { | |
# This requires an IFTTT pro key | |
if [ -n "IFTTTKEY" ]; then | |
curl -X POST -H "Content-Type: application/json" --data '{"value1":"Firewalla has rebooted","value2":"'$URL'","value3":"'$IMAGE'"}' \ | |
https://maker.ifttt.com/trigger/$IFTTTrigger/with/key/$IFTTTKEY | |
fi | |
} | |
pushAlert $URL $IMAGE | |
echo $(date) FWG Rebooted >> /data/fwg_reboot.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment