[25911] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | # The original version of a script by this name had gone missing
|
---|
| 4 | # I have guessed at the logic it contained based on the script's name
|
---|
| 5 | # of "wget-status-page"
|
---|
| 6 | # This script wgets the dynamic status page at
|
---|
[28993] | 7 | # http://puka.cs.waikato.ac.nz/cgi-bin/gti/linux/library.cgi?a=gti&p=status
|
---|
[25911] | 8 | # and saves it into /greenstone/custom/gti/etc/status.html so that it
|
---|
| 9 | # can then be viewed statically at http://www.greenstone.org/gti/status.html
|
---|
| 10 | # ak19, 17 May 2012
|
---|
| 11 |
|
---|
[30605] | 12 | #url="http://puka.cs.waikato.ac.nz/cgi-bin/gti/linux/library.cgi?a=gti&p=status"
|
---|
| 13 | ##url="http://localhost:80/cgi-bin/gti/linux/library.cgi?a=gti&p=status"
|
---|
| 14 | #url="http://gti.cms.waikato.ac.nz/cgi-bin/library.cgi?a=gti&p=status"
|
---|
| 15 | url="http://gti.greenstone.org/cgi-bin/library.cgi?a=gti&p=status"
|
---|
[25911] | 16 | savedas_filename="library.cgi?a=gti&p=status"
|
---|
| 17 | output_filename="etc/status.html"
|
---|
| 18 | old_output_filename="$output_filename.orig"
|
---|
| 19 |
|
---|
| 20 | echo "WGetting translation status page from dynamic URL: $url."
|
---|
| 21 | echo "This may take some time because the page, being dynamic, is first generated."
|
---|
| 22 |
|
---|
| 23 | # wait 10 mins=600s before giving up (at the moment it takes <5 mins to work)
|
---|
| 24 | # the dynamic GTI translation status page takes quite some time to generate
|
---|
| 25 | # the data, but we try only once
|
---|
| 26 | if test -f $output_filename ; then
|
---|
| 27 | mv $output_filename $old_output_filename
|
---|
| 28 | fi
|
---|
| 29 | wget $url --tries=1 --timeout=600
|
---|
| 30 |
|
---|
| 31 | returnval=$?
|
---|
| 32 |
|
---|
| 33 | # If we succeeded, the return value is 0 and we have a file saved under
|
---|
[28490] | 34 | # $savedas_filename. In that case, we get rid of the previous status page
|
---|
[25911] | 35 | # If wget failed or the expected file is not saved, we keep the previous
|
---|
| 36 | # day's status page, but with a log message about why.
|
---|
| 37 | if [ "$returnval" == "0" ]; then
|
---|
| 38 | if test -f $savedas_filename ; then
|
---|
| 39 | mv $savedas_filename $output_filename
|
---|
| 40 | if test -f $old_output_filename ; then
|
---|
| 41 | rm $old_output_filename
|
---|
| 42 | fi
|
---|
| 43 | else
|
---|
| 44 | echo "Wget succeeded yet the expected page $savedas_filename"
|
---|
| 45 | echo "does not exist. Resorting to previous version of file $output_filename"
|
---|
| 46 | if test -f $old_output_filename ; then
|
---|
| 47 | mv $old_output_filename $output_filename
|
---|
| 48 | else
|
---|
| 49 | echo "Previous version of $output_filename does not exist either."
|
---|
| 50 | fi
|
---|
| 51 | fi
|
---|
| 52 | else
|
---|
| 53 | echo "wget did not succeed in retrieving $url."
|
---|
| 54 | echo "Return value was: $returnval"
|
---|
[30605] | 55 | fi
|
---|