X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/ddd16464764026559f8efe414ca6ac05406618a4..c8599aad9649a7970e77fdf24f29ade0fcb987a7:/src/util/renew-opendmarc-tlds.sh diff --git a/src/util/renew-opendmarc-tlds.sh b/src/util/renew-opendmarc-tlds.sh index c276fcd5f..9967018e2 100755 --- a/src/util/renew-opendmarc-tlds.sh +++ b/src/util/renew-opendmarc-tlds.sh @@ -13,7 +13,7 @@ # Create a cron-job as the Exim run-time user to invoke this daily, with a # single parameter, 'cron'. Eg: # -# 3 4 * * * /usr/local/sbin/renew-opendmarc-tlds.sh cron +# 3 4 * * * /usr/local/sbin/renew-opendmarc-tlds.sh cron # # That will, at 3 minutes past the 4th hour (in whatever timezone cron is # running it) invoke this script with 'cron'; we will then sleep between 10 and @@ -24,7 +24,8 @@ # This should be "pretty portable"; the only things it depends upon are: # * a POSIX shell which additionally implements 'local' (dash works) # * the 'curl' command; change the fetch_candidate() function to replace that -# * the 'stat' command, to get the size of a file; change size_of() if need be +# * the 'stat' command, to get the size of a file; else Perl +# + change size_of() if need be; it's defined per-OS # * the 'hexdump' command and /dev/urandom existing # + used when invoked with 'cron', to avoid retrieving on a minute boundary # and contending with many other automated systems. @@ -77,9 +78,19 @@ fetch_candidate() { curl --user-agent "$CurlUserAgent" -fSs -o "${WorkingFile}" "${URL}" } -size_of() { - stat -c %s "$1" -} +case $(uname -s) in +*BSD|Darwin) + size_of() { stat -f %z "$1"; } + ;; +Linux) + size_of() { stat -c %s "$1"; } + ;; +*) + # why do we live in a world where Perl is the safe portable solution + # to getting the size of a file? + size_of() { perl -le 'print((stat($ARGV[0]))[7])' -- "$1"; } + ;; +esac sanity_check_candidate() { local new_size prev_size re