-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdyndns.sh
More file actions
executable file
·35 lines (27 loc) · 1.04 KB
/
Copy pathdyndns.sh
File metadata and controls
executable file
·35 lines (27 loc) · 1.04 KB
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
#! /bin/bash
# this script updates the dynamic ip on http://freedns.afraid.org/ using curl
# check http://freedns.afraid.org/api/ and as weapon ASCII for the phrase in UPDATE_URL
LOG_FILE="/var/log/dyndns-ip.log"
OLDIP_FILE="/var/lib/misc/oldip"
CHECK_CMD="/usr/bin/curl -s http://ip.dnsexit.com/ | sed -e 's/ //'"
UPDATE_URL="http://freedns.afraid.org/dynamic/update.php?U2kwUFhuTnhZdk5ZUzFHUzFMY1U6NjU4NjkyOQ=="
UPDATE_COMMAND="/usr/bin/curl -s $UPDATE_URL"
NOW=$(date +"%Y-%m-%d-%T")
echo "Getting current IP"
CURRENTIP=`${CHECK_CMD}`
echo "Found ${CURRENTIP}"
if [ ! -e "${OLDIP_FILE}" ] ; then
echo "Creating ${OLDIP_FILE}"
echo "0.0.0.0" > "${OLDIP_FILE}"
fi
OLDIP=`cat ${OLDIP_FILE}`
if [ "${CURRENTIP}" != "${OLDIP}" ] ; then
echo "Issuing update command"
${UPDATE_COMMAND}
echo "${NOW}\t${OLDIP}\t${CURRENTIP}" >> "${LOG_FILE}"
python /usr/local/bin/tweet.py "home.sofasurfer.org - IP Changed ${OLDIP} to ${CURRENTIP}"
else
echo "IP still the same:${CURRENTIP}"
fi
echo "Saving IP"
echo "${CURRENTIP}" > "${OLDIP_FILE}"