#!/bin/bash TARGET=/srv/www-sugarlabs/download/soas/test BASEURL=http://alt.fedoraproject.org/pub/alt/nightly-composes/soas/ LATEST=soas-i386-test-latest LOGFILE=soas-wget-log # file for logging output, can be /dev/null # Send all output to LOGFILE exec >${LOGFILE} 2>&1 # Change to target directory cd ${TARGET} # Fetch the index page, and from the index page get the ISO filename NAME=$(wget -o /dev/null -O- ${BASEURL}|\ sed -n "s/^.*\(soas-i386-20[.0-9]*iso\).*/\1/p") # Abort if file already exists if [ -f ${NAME} ] then exit 1 fi # Fetch the ISO using the name from above if wget ${BASEURL}/${NAME} then # If successful, also get the checksum file wget -O ${NAME/iso/sha} ${BASEURL}/CHECKSUM-i386 # Remove and recreate the "latest" symlinks rm -f ${LATEST}-checksum.sha ln -s ${NAME/iso/sha} ${LATEST}-checksum.sha rm -f ${LATEST}.iso ln -s ${NAME} ${LATEST}.iso fi