minor improvements
authorIan Kelling <ian@iankelling.org>
Sat, 14 Feb 2026 14:42:25 +0000 (09:42 -0500)
committerIan Kelling <ian@iankelling.org>
Sat, 14 Feb 2026 14:42:25 +0000 (09:42 -0500)
dynamic-ip-update
mailtest-check

index b18b1bb0d2d198124099d795916d9e653d374828..f72ee0eac2334457a96a34bafa4365024e6be159 100755 (executable)
@@ -36,6 +36,7 @@ Usage: ${0##*/} [-f]
 Update ip in remote nameserver.
 
 -f         Force update even if ip hasn't changed.
+-v         Verbose mode.
 -h|--help  Print help and exit.
 
 Note: Uses util-linux getopt option parsing: spaces between args and
@@ -50,12 +51,14 @@ EOF
 ret=0; getopt -T || ret=$?
 [[ $ret == 4 ]] || { echo "Install util-linux for enhanced getopt" >&2; exit 1; }
 
+verbose=false
 force=false # default
-temp=$(getopt -l help hf "$@") || usage 1
+temp=$(getopt -l help hfv "$@") || usage 1
 eval set -- "$temp"
 while true; do
   case $1 in
     -f) force=true ;;
+    -v) verbose=true ;;
     --) shift; break ;;
     *) echo "$0: unexpected args: $*" >&2 ; usage 1 ;;
   esac
@@ -70,7 +73,7 @@ main() {
   domaintmp=${fqdn#*.}
   hostnametmp=${fqdn%%.*}
   # i for internet
-  fqdn=${hostnametmp}i.${domaintmp}
+  fqdn6=${hostnametmp}i6.${domaintmp}
 
   up4=false
 
@@ -134,7 +137,7 @@ main() {
   fi
 
   # may not be set yet so allow fail
-  cur6="$(host -4 -t aaaa $fqdn iankelling.org | sed -rn 's/.*has IPv6 address (.*)/\1/p;T;q')" ||:
+  cur6="$(host -4 -t aaaa $fqdn6 iankelling.org | sed -rn 's/.*has IPv6 address (.*)/\1/p;T;q')" ||:
 
   up6=false
 
@@ -189,12 +192,12 @@ EOF
   if $up6; then
     if [[ $ip6 ]]; then
       cat >>$tmpf <<EOF
-update delete $fqdn. AAAA
-update add $fqdn. 60 AAAA $ip6
+update delete $fqdn6. AAAA
+update add $fqdn6. 60 AAAA $ip6
 EOF
     else
       cat >>$tmpf <<EOF
-update delete $fqdn. AAAA
+update delete $fqdn6. AAAA
 EOF
     fi
   fi
@@ -206,8 +209,10 @@ answer
 quit
 EOF
 
+  if $verbose; then echo "nsupdate stdin:"; cat $tmpf; fi
   chronic nsupdate $ip_arg -k /p/c/user-specific/bind/etc/bind/Kb8.nz.*.private <$tmpf || nsupdate_fails=$((nsupdate_fails + 1))
   sed -i 's/^server .*/server bk.b8.nz/' $tmpf
+  if $verbose; then echo "nsupdate stdin:"; cat $tmpf; fi
   chronic nsupdate $ip_arg -k /p/c/user-specific/bind/etc/bind/Kb8.nz.*.private <$tmpf  || nsupdate_fails=$((nsupdate_fails + 1))
   if (( nsupdate_fails > nsupdate_fail_limit )); then
     echo error: nsupdate is persistently failing >&2
index c08062b9081b55605661a166686f41cb47a0f2c4..f416acd447aafe8dbfac461dcf8ca81f44212b02 100755 (executable)
@@ -73,41 +73,6 @@ ssh-lan() {
 }
 
 
-maybe-toggle-ssh() {
-
-  # something went wrong in this case.
-  if (( lock_check_fails >= 2 )); then
-    ssh-wan
-  fi
-  export DISPLAY=:0
-  export XAUTHORITY=/home/iank/.Xauthority
-
-  if ! lock_info=$(xscreensaver-command -time 2>/dev/null); then
-    lock_check_fails+=1
-    return 0
-  fi
-
-  lock_or_unlock_time=$(echo "$lock_info" | grep -o 'since.*' | sed 's/since //')
-  lock_or_unlock_time=$(date -d "$lock_or_unlock_time" +%s 2>/dev/null ||:)
-  uint_regex='^[0-9]+$'
-  if [[ ! $lock_or_unlock_time =~ $uint_regex ]]; then
-    lock_check_fails+=1
-    return 0
-  fi
-  lock_check_fails=0
-
-  if [[ $lock_info == *non-blanked* ]]; then
-    if ! $deactivated_sshd; then
-      deactivated_sshd=true
-      ssh-lan
-    fi
-    # if its been blanked more than a few minutes while I'm afk turn ssh back on.
-  elif $deactivated_sshd && (( EPOCHSECONDS - lock_or_unlock_time > 60 * 2 )); then
-    deactivated_sshd=false
-    ssh-wan
-  fi
-}
-
 rspamc-process() {
 
   # note, this could in theory break since we aren't limiting it to the
@@ -487,11 +452,6 @@ loop-main() {
   sleep 10
   while true; do
     premain_sec=$EPOCHSECONDS
-    # Disabled as the config change seems to be unreliable. I see ssh
-    # start, then listen on only 1 port even though 2 are listed in the
-    # config, I can't figure out why, then it starts working randomly.
-
-    #maybe-toggle-ssh
     main
     maini=$((maini + 1))
     sleep $(( 300 - ( EPOCHSECONDS - premain_sec ) ))