#!/bin/bash # The original version of a script by this name had gone missing # I have guessed at the logic it contained based on the script's name # of "wget-status-page" # This script wgets the dynamic status page at # http://puka.cs.waikato.ac.nz/cgi-bin/gti/linux/library.cgi?a=gti&p=status # and saves it into /greenstone/custom/gti/etc/status.html so that it # can then be viewed statically at http://www.greenstone.org/gti/status.html # ak19, 17 May 2012 url="http://puka.cs.waikato.ac.nz/cgi-bin/gti/linux/library.cgi?a=gti&p=status" #url="http://localhost:80/cgi-bin/gti/linux/library.cgi?a=gti&p=status" savedas_filename="library.cgi?a=gti&p=status" output_filename="etc/status.html" old_output_filename="$output_filename.orig" echo "WGetting translation status page from dynamic URL: $url." echo "This may take some time because the page, being dynamic, is first generated." # wait 10 mins=600s before giving up (at the moment it takes <5 mins to work) # the dynamic GTI translation status page takes quite some time to generate # the data, but we try only once if test -f $output_filename ; then mv $output_filename $old_output_filename fi wget $url --tries=1 --timeout=600 returnval=$? # If we succeeded, the return value is 0 and we have a file saved under # $savedas_filename. In that case, we get rid of the previous status page # If wget failed or the expected file is not saved, we keep the previous # day's status page, but with a log message about why. if [ "$returnval" == "0" ]; then if test -f $savedas_filename ; then mv $savedas_filename $output_filename if test -f $old_output_filename ; then rm $old_output_filename fi else echo "Wget succeeded yet the expected page $savedas_filename" echo "does not exist. Resorting to previous version of file $output_filename" if test -f $old_output_filename ; then mv $old_output_filename $output_filename else echo "Previous version of $output_filename does not exist either." fi fi else echo "wget did not succeed in retrieving $url." echo "Return value was: $returnval" fi