nvchecker: add time

This commit is contained in:
George Rawlinson 2021-08-09 23:44:21 +00:00
parent 3782d93ae2
commit d4d029c3f6
Signed by: grawlinson
GPG Key ID: E0959FEA8B550539
2 changed files with 38 additions and 0 deletions

View File

@ -729,6 +729,10 @@ cmd = "./.repo/pkgver/html-xml-utils.sh"
source = "cmd"
cmd = "./.repo/pkgver/sendmail.sh"
[time]
source = "cmd"
cmd = "./.repo/pkgver/time.sh"
# git
#[plasma-pass-git]
#source = "git"

34
.repo/pkgver/time.sh Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/bash
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.gnu.org/gnu/time/"
# options to pass to cURL, including custom user agent
USER_AGENT="time-version-checker/1.0 george@rawlinson.net.nz"
CURL_OPTS=(--ftp-pasv --silent --user-agent "$USER_AGENT")
curl "${CURL_OPTS[@]}" "$UPSTREAM_URL" \
| tr -s ' ' \
| cut -d ' ' -f 9 \
| grep ".tar.gz$" \
| sort -n \
| tail -n 1 \
| sed -e "s/^time-//" -e "s/.tar.gz$//"
exit 0