51b0e05f3807e351efb2ff9a4870946175121722
mspeir
Wed Dec 21 10:00:55 2016 -0800
Adding usage message and ability to specify output directory per Jonathan's suggestion. Also setting qaConfig and other standard stuff at the top of the script. refs #18316
diff --git src/utils/qa/getPubHubContact.sh src/utils/qa/getPubHubContact.sh
index 3a97a2a..a07fbff 100755
--- src/utils/qa/getPubHubContact.sh
+++ src/utils/qa/getPubHubContact.sh
@@ -1,20 +1,70 @@
#!/bin/bash
+# quit if something within the script fails
+set -beEu -o pipefail
+source `which qaConfig.bash`
+umask 002
+
+################################
+#
+# 12-20-2016
+# Matthew Speir
+#
+# getPubHubInfo.sh
+# Collects contact information for
+# hubs listed in hgcentral.hubPublic.
+# Outputs contact information to HTML-
+# formatted file.
+#
+################################
+
+usage="""
+Collect contact information for hubs in hgcentral.hubPublic on the RR. Places all
+contact information into an HTML-formatted page.\nDefault output location:\n
+/usr/local/apache/htdocs-genecats/qa/test-results/publicHubContactInfo\n\n
+`basename $0` go [outputLocation]\n\n\
+outputLocation is a path to the directory where output should be placed. If not set,
+script assumes default location above.\n
+"""
+
+runScript=""
+base=""
+
+# Print usage statement
+if (( $# < 1 )) || (( $# > 2 ))
+then
+ echo -e $usage
+ exit 1
+elif (( $# == 1 ))
+then
+ runScript=$1
+elif (( $# == 2 ))
+then
+ runScript="$1"
+ base="$2"
+fi
+
+#If no user provided base location, then assume it's being run on dev and output to default loc.
+if [[ "$base" == "" ]]
+then
base="/usr/local/apache/htdocs-genecats/qa/test-results/publicHubContactInfo"
-contactFile="$base/publicHubContact.html"
+fi
+if [[ "$runScript" == "go" ]]
+then
+ contactFile="$base/publicHubContact.html"
# Check if old contact file exists and if it does move it to archive file
if [ -e $contactFile ]
then
mv $contactFile $contactFile.old
fi
# Make header for html file
echo -e "
" >> $contactFile
while read url label
do
# Save hub shortLabel as a file so we can use it in a filename later
@@ -38,15 +88,20 @@
# If email is still empty, hub is likely down and
# we want to use the last email we have as contact email
if [[ $email == "" ]] && [ -e $contactFile.old ]
then
email=$(grep "$url" $contactFile.old | awk '{print $4" "$5}')
fi
fi
# Create hyperlinks to hub.txt files
hubLink="$label"
# Write contact email + hubUrl to file
echo -e "$hubLink $email
" >> $contactFile
done<<<"$(hgsql -h genome-centdb -Ne "select hubUrl,shortLabel from hubPublic" hgcentral)"
+else
+ echo -e "Error: \"$1\" is not a valid input. Please see the usage message.\n\n"
+ echo -e $usage
+ exit 1
+fi