diff options
| author | Dennis Camera <cdist@dtnr.ch> | 2021-02-20 21:49:07 +0100 |
|---|---|---|
| committer | Dennis Camera <cdist@dtnr.ch> | 2021-03-19 11:06:07 +0100 |
| commit | bb4712ed65bcc385afad9300f611023d02a68ac3 (patch) | |
| tree | 92fce440c48a58c55e52f2468f016c12ceabf744 /type | |
| parent | 53b98513f2cac9542c683bca15e69f36b8061a4f (diff) | |
| download | __dtnrch_egov-bb4712ed65bcc385afad9300f611023d02a68ac3.tar.gz __dtnrch_egov-bb4712ed65bcc385afad9300f611023d02a68ac3.zip | |
[type/__dtnrch_etax_sgnp] Rename maint/check-urls.sh to check-all-urls.sh
Diffstat (limited to 'type')
| -rwxr-xr-x | type/__dtnrch_etax_sgnp/files/maint/check-all-urls.sh (renamed from type/__dtnrch_etax_sgnp/files/maint/check-urls.sh) | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/type/__dtnrch_etax_sgnp/files/maint/check-urls.sh b/type/__dtnrch_etax_sgnp/files/maint/check-all-urls.sh index cbfca05..d8d2ede 100755 --- a/type/__dtnrch_etax_sgnp/files/maint/check-urls.sh +++ b/type/__dtnrch_etax_sgnp/files/maint/check-all-urls.sh @@ -21,7 +21,7 @@ do awk -f "${__files}/ini_get_section.awk" "${release}" "${metafile}" \ | command -p awk ' /=/ { - k = toupper(substr($0, 1, index($0, "=") - 1)) + k = substr($0, 1, index($0, "=") - 1) sub(/ *$/, "", k) v = substr($0, index($0, "=") + 1) sub(/^ */, "", v) @@ -33,34 +33,36 @@ do }' )" - for url in "${URL-}" "${URL_ALT-}" "${URL_ARCHIVE-}" + for varname in url url_alt url_archive do + url=$(eval printf '%s\\n' \"\${${varname}-}\") test -n "${url}" || continue - case $(python3 -c 'import sys, urllib.request; sys.stdout.write("%u\n" % urllib.request.urlopen(urllib.request.Request(sys.argv[1], method="HEAD")).getcode())' "${url}") + case $(python3 -c 'import sys, urllib.request; sys.stdout.write("%u\n" % urllib.request.urlopen(urllib.request.Request(sys.argv[1], method="HEAD")).getcode())' "${url}" 2>/dev/null) in (200) - : $((working_urls+=1)) + working_urls=${working_urls-}${working_urls:+, }${varname} ;; (404|500) - : $((non_working_urls+=1)) + broken_urls=${broken_urls-}${broken_urls:+, }${varname} continue ;; esac done - if test ${working_urls:-0} -gt 0 + if test -n "${working_urls:-}" then printf '%s/%s: ' "${version}" "${release}" - printf '%u working URLs' "${working_urls}" - if test ${non_working_urls:-0} -gt 0 + + if test -z "${broken_urls:-}" then - printf ', %u working URLs' "${non_working_urls}" + printf 'all URLs working' + else + printf 'working URLs (%s), broken URLs (%s)' "${working_urls}" "${broken_urls}" fi printf '.\n' else - printf '%s/%s: ' "${version}" "${release}" >&2 - printf 'no working URLs.\n' >&2 + printf '%s/%s: no working URLs.\n' "${version}" "${release}" >&2 exit 1 fi ) || : $((failed_releases+=1)) |
