#!/bin/bash # alfplayer # 2014-06-12 # # Test if mirrors are online. Specifically, it tests the connection to a specific file. logfile="$HOME/log/iso-files-online-test.log" logfile_dir="$(dirname ${logfile})" if [[ ! -w ${logfile_dir} ]] ; then echo -e "Can't write to logfile directory: \"${logfile_dir}\"\nNothing done." exit 1 fi isodate="2014.06.01" filename="parabola-${isodate}-dual.iso" url=( "http://parabolagnulinux.mirrors.linux.ro/iso/${isodate}/${filename}" "http://alfplayer.com/parabola/iso/${isodate}/${filename}" "http://snapshots.alfplayer.com/parabola/iso/${isodate}/${filename}" "http://mtjm.eu/releases/parabola/${filename}" # "http://www.fscorsica.org/iso/${filename}" "http://m.tiddles.me/${filename}" # "http://hive.ist.unomaha.edu/parabola/iso/${isodate}/${filename}" "http://repo.parabola.nu/iso/${isodate}/${filename}" "http://oglinzi.ceata.org/parabola-imagini/iso/${isodate}/${filename}" "https://parabola.goodgnus.com.ar/iso/${isodate}/${filename}" "http://mirror.yandex.ru/mirrors/parabola/iso/${isodate}/${filename}" # "http://mirror.parlementum.net/iso/${isodate}/${filename}" "http://b.mirrors.fryxell.info/parabolagnulinux/iso/${isodate}/${filename}" # listed using HTTPS in the mirrorlist ) url_length="$(( ${#url[@]} -1 ))" url_exists() { curl -s --head "$1" | \ head -n 1 | \ grep -q 'HTTP/1.[01] [23]..' } while true ; do for (( i=0; i<=url_length; i++ )) ; do echo "Checking URL \"${url[$i]}\"" #(( ${url_test[$i]} )) || url_exists "${url[$i]}" && { if url_exists "${url[$i]}" ; then #url_test[$i]=1 echo "$(date '+%Y.%m.%d %R') Found: ${url[$i]}" >> "${logfile}" else echo "$(date '+%Y.%m.%d %R') Not found: ${url[$i]}" >> "${logfile}" fi done echo Sleeping... sleep 1800 done