different backups for primary and secondary
[scripts/scripts.git] / unreal_update.sh
index 9b8527a..6c30955 100755 (executable)
@@ -3,15 +3,21 @@
 # to update ip of hackdaworld.dyndns.org in unrealircd.conf
 
 CONFIGDIR="/etc/opt/unrealircd"
-BINDIR="/opt/unrealircd"
+BINDIR="/opt/unrealircd/bin"
 BINARY="ircd"
 
 
 NEWIP="`host hackdaworld.dyndns.org | awk '{ print $4 }'`"
 
-# HDWTAG dirty ... but easy :)
+# get CURRENTIP
+CURRENTIP="`grep HDWTAG $CONFIGDIR/unrealircd.conf | awk '{ print $2 }'`"
+
+if [ "$CURRENTIP" != "$NEWIP" ]; then
+
 cat $CONFIGDIR/unrealircd.conf | \
- sed "s/.* HDWTAG .*/hostname $NEWIP \/* HDWTAG *\//" > $CONFDIR/temp
-mv $CONFDIR/temp $CONFIGDIR/unrealircd.conf
-$BINDIR/$BINARY -rehash
+ sed "s/.* HDWTAG .*/hostname ::ffff:$NEWIP; \/* HDWTAG *\//" > $CONFIGDIR/temp
+mv $CONFIGDIR/temp $CONFIGDIR/unrealircd.conf
+killall -HUP $BINARY
+
+fi