-
Notifications
You must be signed in to change notification settings - Fork 1
/
reboot.sh
executable file
·41 lines (35 loc) · 1.29 KB
/
reboot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/ash
# Title: Kankun Plug Rebooter Script
# Author: Allan Paul Sy Ortile
# Date: 2017-11-18
# Version: 0.03 (Start Date: 2016-08-05)
#
# Put this as a cronjob via crontab -e
# This will check every 15 minutes if the IP is the same, if not it will reboot the device
# */30 * * * * /root/reboot.sh >/dev/null 2>&1
#
# Things to change according to your configuration:
# <DSL_IP> - This should contain the static IP of your connection.
# <KANKUN_IP> - This is the IP address of your Kankun device which has the relay.cgi script.
# <IFTTT_KEY> - Your Maker IFTTT channel key.
#
# date
DSL_IP="127.0.0.1"
PUBLIC_IP=`wget http://icanhazip.com -O - -q ; echo -n`
echo This is your public IP: $PUBLIC_IP
# This hardcodes the public IP. USE ONLY FOR TESTING.
#PUBLIC_IP="127.0.0.1"
#echo TESTING TESTING TESTING
if [[ $DSL_IP == $PUBLIC_IP ]]; then
echo "Still the same, doing nothing."
else
echo "Invoking flip switch."
# INSERT TOGGLE OFF HERE
wget http://<KANKUN_IP>/cgi-bin/relay.cgi?off -O - -q
sleep 10
# INSERT TOGGLE ON HERE
wget http://<KANKUN_IP>/cgi-bin/relay.cgi?on -O - -q
# PUSH REPORT TO IFTTT
wget http://maker.ifttt.com/trigger/reboot_triggered/with/key/<IFTTT_KEY> -O - -q
echo "Done."
fi