+version_from_attachment() {
+ local url fn dt d t
+ t=$(mktemp)
+
+ for url in "$@"; do
+ # remove querystring to receive proper headers
+ url=${url%\?*}
+ curl -Is "$url" -o "$t"
+ fn=$(awk 'BEGIN {FS=": "}/^[Cc]ontent-[Dd]isposition/{sub(/.*filename=/, "", $2); print $2}' "$t")
+ fn=${fn#GeoLite2-Country-CSV_}
+ d=$(echo "$fn" | sed -e 's/[^0-9-]//g')
+
+ if [ "$d" -gt "$dt" ]; then
+ dt=$d
+ fi
+ done
+
+ test -n "$dt" || die "Failed to find date from $*"
+
+ rm -f $t
+ version=$dt
+}
+