Permalink
Switch branches/tags
Nothing to show
Find file Copy path
c3f5f1a Jul 30, 2017
3 contributors

Users who have contributed to this file

@t0xicCode @SapuSeven @AntonioCS
31 lines (22 sloc) 788 Bytes
#!/bin/bash
# No-IP uses emails as usernames, so make sure that you encode the @ as %40
USERNAME=username
PASSWORD=password
HOST=hostsite
LOGFILE=logdir/noip.log
STOREDIPFILE=configdir/current_ip
USERAGENT="Simple Bash No-IP Updater/0.4 antoniocs@gmail.com"
if [ ! -e $STOREDIPFILE ]; then
touch $STOREDIPFILE
fi
NEWIP=$(wget -O - http://icanhazip.com/ -o /dev/null)
STOREDIP=$(cat $STOREDIPFILE)
if [ "$NEWIP" != "$STOREDIP" ]; then
RESULT=$(wget -O "$LOGFILE" -q --user-agent="$USERAGENT" --no-check-certificate "https://$USERNAME:$PASSWORD@dynupdate.no-ip.com/nic/update?hostname=$HOST&myip=$NEWIP")
LOGLINE="[$(date +"%Y-%m-%d %H:%M:%S")] $RESULT"
echo $NEWIP > $STOREDIPFILE
else
LOGLINE="[$(date +"%Y-%m-%d %H:%M:%S")] No IP change"
fi
echo $LOGLINE >> $LOGFILE
exit 0