December 4, 200916 yr Is there a way to recognize a change of the WAN IP? I would like to call a script whenever this IP changes (to re-start nzbget for example): nzbget -q nzbget -s & Many thanks in advance. Harald
December 5, 200916 yr No, but you can do it easily: You can write a script that pulls your router config page with wget, parses it for the router's WAN IP address, and then take action if changed. Then put it in a loop with a sleep command or schedule it with cron.
December 5, 200916 yr Is there a way to recognize a change of the WAN IP? I would like to call a script whenever this IP changes (to re-start nzbget for example): nzbget -q nzbget -s & Many thanks in advance. Harald For example (copy/paste the following into root user terminal session): SCRIPT=/boot/custom/bin/restart_on_ip_change.sh SCRIPT_DIR=`dirname $SCRIPT` [ -d "$SCRIPT_DIR" ] || mkdir -p $SCRIPT_DIR cp -p /boot/config/go /var/tmp cat >>/boot/config/go <<EOF # # Add nzbget restart to crontab # crontab -l >/tmp/crontab cp /tmp/crontab /var/spool/cron/crontabs/root- (echo -n '0 * * * * '; echo $SCRIPT) >>/tmp/crontab crontab /tmp/crontab EOF cat >$SCRIPT <<EOF #!/bin/bash IP_FILE="/var/tmp/current_ip" NEW_ADDR=\$(wget -O - http://ipdetect.dnspark.com/ 2>/dev/null | grep Address | tr -cd '0-9.') OLD_ADDR=\$(cat $IP_FILE) if [ "\$NEW_ADDR" != "\$OLD_ADDR" ]; then nzbget -q nzbget -s & fi echo \$NEW_ADDR >\$IP_FILE EOF
December 5, 200916 yr Sorry, there was an error. Here is the correct code: SCRIPT=/boot/custom/bin/restart_on_ip_change.sh SCRIPT_DIR=`dirname $SCRIPT` [ -d "$SCRIPT_DIR" ] || mkdir -p $SCRIPT_DIR cp -p /boot/config/go /var/tmp cat >>/boot/config/go <<EOF # # Add nzbget restart to crontab # crontab -l >/tmp/crontab cp /tmp/crontab /var/spool/cron/crontabs/root- (echo -n '0 * * * * '; echo $SCRIPT) >>/tmp/crontab crontab /tmp/crontab EOF cat >$SCRIPT <<EOF #!/bin/bash IP_FILE="/var/tmp/current_ip" NEW_ADDR=\$(wget -O - http://ipdetect.dnspark.com/ 2>/dev/null | grep Address | tr -cd '0-9.') OLD_ADDR=\$(cat \$IP_FILE 2>/dev/null) if [ "\$NEW_ADDR" != "\$OLD_ADDR" ]; then nzbget -q nzbget -s & fi echo \$NEW_ADDR >\$IP_FILE EOF chmod +x $SCRIPT
Archived
This topic is now archived and is closed to further replies.