index : devops | |
Archlinux32 devs' convenience-scripts | gitolite user |
summaryrefslogtreecommitdiff |
author | Erich Eckner <git@eckner.net> | 2018-12-06 08:59:42 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-12-06 08:59:42 +0100 |
commit | 3c5b8b89e4fa60daf73d1f9ba17ded4ed3ee2410 (patch) | |
tree | 5a882841bcf941e7bd5d422b9ef912e4da98ef09 /ddns-update | |
parent | 68898d11cde5d0b78962bb47e2762afa7a9830c0 (diff) |
-rwxr-xr-x | ddns-update | 47 |
diff --git a/ddns-update b/ddns-update index 0476242..d6785d6 100755 --- a/ddns-update +++ b/ddns-update @@ -28,6 +28,29 @@ if [ $# -eq 1 ]; then exit fi +mirrors=$( + curl -s 'https://packages.archlinux32.org/mirrors/status.php?tsv' +) + +url_column=$( + printf '%s\n' "${mirrors}" | \ + head -n1 | \ + tr '\t' '\n' | \ + grep -nxF 'url' | \ + cut -d: -f1 +) +recently_active_column=$( + printf '%s\n' "${mirrors}" | \ + head -n1 | \ + tr '\t' '\n' | \ + grep -nxF 'recently_active' | \ + cut -d: -f1 +) +if [ -z "${url_column}" ] || [ -z "${recently_active_column}" ]; then + # https://packages.archlinux32.org/mirrors/status.php?tsv gave bogus content + exit +fi + { for type in 'A' 'AAAA'; do printf '%s\n' \ @@ -37,25 +60,11 @@ fi 'send' done printf 'zone ddns.eckner.net.\n' - curl -s 'https://packages.archlinux32.org/mirrors/status.php?tsv' | \ - { - read -r headers - url_column=$( - printf '%s\n' "${headers}" | \ - tr '\t' '\n' | \ - grep -nxF 'url' | \ - cut -d: -f1 - ) - recently_active_column=$( - printf '%s\n' "${headers}" | \ - tr '\t' '\n' | \ - grep -nxF 'recently_active' | \ - cut -d: -f1 - ) - awk '{ - print $'"${recently_active_column}"' "\t" $'"${url_column}"' - }' - } | \ + printf '%s\n' "${mirrors}" | \ + sed '1d' | \ + awk '{ + print $'"${recently_active_column}"' "\t" $'"${url_column}"' + }' | \ sed -n ' s/^1\t// T |