allows multiple domain names using second arg

This commit is contained in:
2026-02-09 10:27:20 +00:00
parent 3d2a0602e4
commit 532e63e038
2 changed files with 11 additions and 3 deletions
+9 -1
View File
@@ -21,7 +21,8 @@ Write this to `DIGITALOCEAN_TOKEN`.
The script should now run. Try it out: The script should now run. Try it out:
```sh ```sh
./dyndns.sh ./dyndns.sh 4 # for IPv$
./dyndns.sh 6 # for IPv$
``` ```
Go to the control panel in DigitalOcean for your domain, and check the A and Go to the control panel in DigitalOcean for your domain, and check the A and
@@ -40,3 +41,10 @@ Wait one minute, and check the logs. If you want to see that it works, delete
the REPEAT_CHECK_A and REPEAT_CHECK_AAAA files and wait for the script to run the REPEAT_CHECK_A and REPEAT_CHECK_AAAA files and wait for the script to run
again. You may also want to have an MTA set up, as cron will try to send any again. You may also want to have an MTA set up, as cron will try to send any
unhandled output to your inbox. unhandled output to your inbox.
If you want to use this script for more than one domain, you can supply a domain
name as a second argument. For example:
```sh
./dyndns.sh 4 example.com
```
+2 -2
View File
@@ -7,7 +7,7 @@
ip_version="$1" ip_version="$1"
if [ -z "${ip_version:-}" ] || ([ "$ip_version" != 4 ] && [ "$ip_version" != 6 ]); then if [ -z "${ip_version:-}" ] || ([ "$ip_version" != 4 ] && [ "$ip_version" != 6 ]); then
echo "Error: no valid IP version provided" >&2 echo "Error: no valid IP version provided" >&2
echo "Usage: dyndns.bash <4|6>" >&2 echo "Usage: dyndns.bash <4|6> [domain]" >&2
exit 1 exit 1
fi fi
@@ -26,7 +26,7 @@ REPEAT_CHECK_A=$REPEAT_CHECK_DIR/REPEAT_CHECK_A
REPEAT_CHECK_AAAA=$REPEAT_CHECK_DIR/REPEAT_CHECK_AAAA REPEAT_CHECK_AAAA=$REPEAT_CHECK_DIR/REPEAT_CHECK_AAAA
REPEAT_CHECK="$([ $ip_version = 4 ] && echo $REPEAT_CHECK_A || echo $REPEAT_CHECK_AAAA)" REPEAT_CHECK="$([ $ip_version = 4 ] && echo $REPEAT_CHECK_A || echo $REPEAT_CHECK_AAAA)"
DIGITALOCEAN_DOMAIN=`cat $SCRIPT_DIR/DIGITALOCEAN_DOMAIN` DIGITALOCEAN_DOMAIN=${2:-`cat $SCRIPT_DIR/DIGITALOCEAN_DOMAIN`}
DIGITALOCEAN_TOKEN=`cat $SCRIPT_DIR/DIGITALOCEAN_TOKEN` DIGITALOCEAN_TOKEN=`cat $SCRIPT_DIR/DIGITALOCEAN_TOKEN`
get_a_record_ids() { get_a_record_ids() {