Skip to content

Instantly share code, notes, and snippets.

@cstrat
Forked from mbierman/fwg_reboot_notifications.sh
Created August 24, 2021 00:03
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 cstrat/db2be23525cc2607b2ab94b6054be9a6 to your computer and use it in GitHub Desktop.
Save cstrat/db2be23525cc2607b2ab94b6054be9a6 to your computer and use it in GitHub Desktop.
Firewalla reboot notification via IFTT
#!/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