From 00dfd4bc0274070d9bc979593d5aab7cd97b9fc3 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Mon, 15 Dec 2025 13:41:01 +0000 Subject: [PATCH] fixes --- dyndns.sh | 18 +++++++++--------- get_ip_addr.sh | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dyndns.sh b/dyndns.sh index 4847154..005264b 100755 --- a/dyndns.sh +++ b/dyndns.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh # Work with DigitalOcean api to update "A" and "AAAA" records for a domain. # Store DigitalOcean API token in file : DIGITALOCEAN_TOKEN @@ -6,14 +6,8 @@ ip_version="$1" if [ -z "${ip_version:-}" ] || ([ "$ip_version" != 4 ] && [ "$ip_version" != 6 ]); then - echo "Error: no valid IP version provided" &>2 - echo "Usage: dyndns.bash <4|6>" &>2 - exit 1 -fi - -IP="$(./get_ip_addr.sh $ip_version)" -if [ -z "$IP" ]; then - echo "Error: could not find IP address" &>2 + echo "Error: no valid IP version provided" >&2 + echo "Usage: dyndns.bash <4|6>" >&2 exit 1 fi @@ -21,6 +15,12 @@ SCRIPT="$0" SCRIPT_DIR=$(cd "${SCRIPT%/*}" && pwd ) SCRIPT_NAME=${SCRIPT##*/} +IP="$($SCRIPT_DIR/get_ip_addr.sh $ip_version)" +if [ -z "$IP" ]; then + echo "Error: could not find IP address" >&2 + exit 1 +fi + REPEAT_CHECK_DIR=$SCRIPT_DIR REPEAT_CHECK_A=$REPEAT_CHECK_DIR/REPEAT_CHECK_A REPEAT_CHECK_AAAA=$REPEAT_CHECK_DIR/REPEAT_CHECK_AAAA diff --git a/get_ip_addr.sh b/get_ip_addr.sh index 27c948a..057fcd0 100755 --- a/get_ip_addr.sh +++ b/get_ip_addr.sh @@ -2,7 +2,7 @@ ip_version="$1" if [ -z "${ip_version:-}" ] || ([ "$ip_version" != 4 ] && [ "$ip_version" != 6 ]); then - echo "Usage: get_ip_addr <4|6>" &>2 + echo "Usage: get_ip_addr <4|6>" >&2 exit 1 fi @@ -15,13 +15,13 @@ set -eu CONN_NAME=${CONN_NAME:-nevis} conn_device_name="$(nmcli --fields NAME,DEVICE con show | grep ^$CONN_NAME | sed 's/\s\+/ /g' | cut -d' ' -f 2)" if [ -z "${conn_device_name:-}" ]; then - echo "Could not find the connection device name for connection: \"$CONN_NAME\"" &>2 + echo "Could not find the connection device name for connection: \"$CONN_NAME\"" >&2 exit 1 fi device_line_no="$(ip addr | grep -En ^[0-9]+:\ $conn_device_name | cut -d':' -f 1)" if [ -z "${device_line_no:-}" ]; then - echo "Could not find device: \"$conn_device_name\" in output of ip addr" &>2 + echo "Could not find device: \"$conn_device_name\" in output of ip addr" >&2 exit 1 fi