Skip to content

Commit 226723e

Browse files
author
Xavier L
committed
using a single log file for all results, instead of a logfile per day
1 parent 150ce15 commit 226723e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

noipupdater.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
USERNAME=username
55
PASSWORD=password
66
HOST=hostsite
7-
DIR=dir
8-
CIPFILE=$DIR/current_ip
9-
USERAGENT="Simple bash noip updater/0.2 [email protected]"
7+
LOGFILE=logdir/noip.log
8+
CIPFILE=dir/current_ip
9+
USERAGENT="Simple Bash No-IP Updater/0.3 [email protected]"
1010

1111
if [ ! -e $CIPFILE ]
1212
then
@@ -17,11 +17,16 @@ IP=$(wget -O - -q http://www.whatismyip.org/)
1717
CIP=$(cat $CIPFILE)
1818

1919
if [ "$IP" != "$CIP" ]
20-
then
21-
LOGFILE=$DIR/$(date +"%Y%m%d")_noip_updater.log
22-
wget -O "$LOGFILE" -q --user-agent="$USERAGENT" --no-check-certificate "https://$USERNAME:$PASSWORD@dynupdate.no-ip.com/nic/update?hostname=$HOST&myip=$IP"
20+
then
21+
RESULT=$(wget -O "$LOGFILE" -q --user-agent="$USERAGENT" --no-check-certificate "https://$USERNAME:$PASSWORD@dynupdate.no-ip.com/nic/update?hostname=$HOST&myip=$IP")
22+
23+
LOGLINE="[$(date +"%Y-%m-%d %H:%M:%S")] $RESULT"
2324
echo $IP > $CIPFILE
25+
else
26+
LOGLINE="[$(date +"%Y-%m-%d %H:%M:%S")] No IP change"
2427
fi
2528

29+
echo $LOGLINE >> $LOGFILE
30+
2631
exit 0
2732

0 commit comments

Comments
 (0)