Skip to content

Instantly share code, notes, and snippets.

@mbierman
Last active August 11, 2022 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mbierman/ccbd5504a1f7ca25a17b595b63bb3418 to your computer and use it in GitHub Desktop.
Save mbierman/ccbd5504a1f7ca25a17b595b63bb3418 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
@mbierman
Copy link
Author

Put this script in /home/pi/.firewalla/config/post_main.d and it will run when Firewalla boots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment