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
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
domaintmp=${fqdn#*.}
hostnametmp=${fqdn%%.*}
# i for internet
- fqdn=${hostnametmp}i.${domaintmp}
+ fqdn6=${hostnametmp}i6.${domaintmp}
up4=false
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
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
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
}
-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
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 ) ))