Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Start script on change of WAN-IP possible?

Featured Replies

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

 

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.

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

 

 

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

 

  • Author

Thanks a lot guys. This helps a lot.

 

Regards

Harald

 

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.