# See the License for the specific language governing permissions and
# limitations under the License.
-
-set -e; . /usr/local/lib/bash-bear; set +e
+. /a/c/fsf-script-lib
[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
this_file="$(readlink -f -- "${BASH_SOURCE[0]}")"
fi
# if we failed to get our ipv6 addr, we probably have ipv6
- # connectivity problem.
- if [[ ! $ip6 ]]; then
+ # connectivity problem. But also just vary to ipv4 if we are failing.
+ if [[ ! $ip6 ]] || (( nsupdate_fails % 3 )); then
ip_arg=-4
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))
+ nsupdate_fails_start=$nsupdate_fails
+ if ! mb chronic nsupdate $ip_arg -k /p/c/user-specific/bind/etc/bind/Kb8.nz.*.private <$tmpf; then
+ echo "nsupdate stdin:"; cat $tmpf
+ nsupdate_fails=$((nsupdate_fails + 1))
+ elif $verbose; then
+ echo "nsupdate stdin:"; cat $tmpf
+ fi
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 ! chronic nsupdate $ip_arg -k /p/c/user-specific/bind/etc/bind/Kb8.nz.*.private <$tmpf; then
+ echo "nsupdate stdin:"; cat $tmpf
+ nsupdate_fails=$((nsupdate_fails + 1))
+ elif $verbose; then
+ echo "nsupdate stdin:"; cat $tmpf
+ fi
+
+ if (( nsupdate_fails_start == nsupdate_fails )); then
+ nsupdate_fails=0
+ fi
+
if (( nsupdate_fails > nsupdate_fail_limit )); then
echo error: nsupdate is persistently failing >&2
exit 1
nsupdate_fails=0
if [[ $PPID == 1 ]]; then
- nsupdate_fail_limit=10
+ nsupdate_fail_limit=20
loop-main
else
nsupdate_fail_limit=0