#!/bin/bash set -e # check dependencies count=0 for dependency in hxnormalize hxselect 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="https://www.la-samhna.de/samhain/s_download.html" # options to pass to cURL, including custom user agent USER_AGENT="samhain-version-checker/1.0 george@rawlinson.net.nz" CURL_OPTS=(--silent --user-agent "$USER_AGENT") curl "${CURL_OPTS[@]}" "$UPSTREAM_URL" | \ hxnormalize -x | \ hxselect -c 'div.table-wrapper ' 'td' | \ head -n 1 | \ sed -e "s/Version //" -e "s/<.*//" exit 0