JWS-121 & JWS-109 Improved the way the service_status.jsp and usage_statistics.jsp...
[jabaws.git] / website / refresh_service_status.sh
1 #!/usr/bin/env bash
2
3 # run command as ./refresh_service_status.sh http://gjb-www-3.cluster.lifesci.dundee.ac.uk:9507/jabaws/ServiceStatus 15 cached_service_status.html &
4 # the command starts executing, but continues to run forever
5
6 # Host URL $1 (example: http://gjb-www-3.cluster.lifesci.dundee.ac.uk:9507/jabaws/ServiceStatus)
7 # Host URL $1 (example: http://gjb-www-3.cluster.lifesci.dundee.ac.uk:9507/jabaws/PublicAnnualStat)
8 if [ -z "$1" ]
9   then
10     echo "Hostname needs to be passed as 1st argument! (example http://compbio.lifesci.dundee.ac.uk/jabaws/ServiceStatus)"
11     exit 1
12 fi
13
14 # Refresh Time $2 (minutes)
15 if [ -z "$2" ]
16   then
17     echo "Refresh Time (min) needs to be passed as 2nd argument! (example 15)"
18     exit 1
19 fi
20
21 # Output-file $3 (html) (example: cached_service_status.html)
22 # Output-file $3 (html) (example: cached_usage_statistics.html)
23 if [ -z "$3" ]
24   then
25     echo "Outputfile (html) needs to be passed as 3rd argument! (example: cached_service_status.html)"
26     exit 1
27 fi
28
29 # gets the file as a tmp
30 while :; do echo "Fetching from $1:" `date "+%d/%m/%Y %H:%M:%S"`; wget -q $1 -O "tmp_cache.html"; mv "tmp_cache.html" $3; sleep $2m; done