2021-08-09 23:45:07 +00:00
|
|
|
#!/bin/bash
|
2021-07-24 12:58:02 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
# check dependencies
|
|
|
|
count=0
|
|
|
|
for dependency in curl tr cut grep sed sort tail; do
|
|
|
|
if [ ! -x "$(command -v $dependency)" ]; then
|
|
|
|
echo "$dependency missing"
|
|
|
|
count=$((count+1))
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# exit script if any dependencies missing
|
|
|
|
if [ $count -ne 0 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# upstream URL
|
|
|
|
UPSTREAM_URL="ftp://ftp.sendmail.org/pub/sendmail/"
|
|
|
|
|
|
|
|
# options to pass to cURL, including custom user agent
|
|
|
|
USER_AGENT="sendmail-version-checker/1.0 george@rawlinson.net.nz"
|
|
|
|
CURL_OPTS=(--ftp-pasv --silent --user-agent "$USER_AGENT")
|
|
|
|
|
2021-08-10 04:33:57 +00:00
|
|
|
curl "${CURL_OPTS[@]}" "$UPSTREAM_URL" | \
|
|
|
|
tr -s ' ' | \
|
|
|
|
cut -d ' ' -f 9 | \
|
|
|
|
grep -E "sendmail\..+\.tar\.gz\.sig$" | \
|
|
|
|
sed -e 's/^sendmail\.//' -e 's/\.tar\.gz\.sig$//' | \
|
|
|
|
sort -n | \
|
|
|
|
tail -n 1
|
2021-07-24 12:58:02 +00:00
|
|
|
|
|
|
|
exit 0
|