]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGPP/QA/scripts/runQA.sh
handle bash args properly using arrays
[u/mrichter/AliRoot.git] / PWGPP / QA / scripts / runQA.sh
index bbc467b6029b01dfec2d97ff3aced1a83f9cb1d2..e378b71c2b8feb3ad11e0cb3b9d98b63207fbd8b 100755 (executable)
@@ -20,7 +20,12 @@ main()
 
   ocdbregex='raw://'
   if [[ ${ocdbStorage} =~ ${ocdbregex} ]]; then
-    alien-token-init
+    alien-token-init ${alienUserName}
+    #this is a hack! alien-token init seems not enough
+    #but the gclient_env script messes up the LD_LIBRARY_PATH
+    while read x; do
+      eval ${x};
+    done < <(grep -v "LD_LIBRARY_PATH" /tmp/gclient_env_${UID})
   fi
 
   updateQA $@
@@ -71,6 +76,7 @@ updateQA()
   for detectorScript in $ALICE_ROOT/PWGPP/QA/detectorQAscripts/*; do
     echo
     echo "##############################################"
+    echo $(date)
     unset planB
     [[ ! ${detectorScript} =~ .*\.sh$ ]] && continue
     detector=${detectorScript%.sh}
@@ -102,6 +108,7 @@ updateQA()
     echo "  outputDir=$outputDir"
     echo "  tmpPrefix=$tmpPrefix"
     
+    #unset the detector functions from previous iterations (detectors)
     unset -f runLevelQA
     unset -f periodLevelQA
     unset -f runLevelHighPtTreeQA
@@ -114,6 +121,7 @@ updateQA()
     declare -A arrOfTouchedProductions
     while read qaFile; do
       echo
+      echo $(date)
       
       #first check if input file exists
       [[ ! -f ${qaFile%\#*} ]] && echo "file ${qaFile%\#*} not accessible" && continue
@@ -198,6 +206,7 @@ updateQA()
       cd ${tmpProductionDir}
       echo
       echo "running period level stuff in ${tmpProductionDir}"
+      echo $(date)
     
       productionDir=${outputDir}/${tmpProductionDir#${tmpPrefix}}
       echo productionDir=${outputDir}/${tmpProductionDir#${tmpPrefix}}
@@ -302,7 +311,7 @@ executePlanB()
     echo
     echo "trouble detected, sending email to ${MAILTO}"
 
-    cat ${logSummary} | mail -s "qa in need of assistance" ${MAILTO}
+    grep BAD ${logSummary} | mail -s "qa in need of assistance" ${MAILTO}
   fi
 }
 
@@ -414,6 +423,8 @@ validateLog()
 
 parseConfig()
 {
+  args=("$@")
+
   #config file
   configFile=""
   #where to search for qa files
@@ -428,32 +439,33 @@ parseConfig()
   #logs
   logDirectory=${workingDirectory}/logs
   #OCDB storage
-  #ocdbStorage="raw://"
+  ocdbStorage="raw://"
   #email to
   #MAILTO="fbellini@cern.ch"
 
   #first, check if the config file is configured
   #is yes - source it so that other options can override it
   #if any
-  for opt in $@; do
+  for opt in "${args[@]}"; do
     if [[ ${opt} =~ configFile=.* ]]; then
       eval "${opt}"
       [[ ! -f ${configFile} ]] && echo "configFile ${configFile} not found, exiting..." && return 1
+      echo "using config file: ${configFile}"
       source "${configFile}"
       break
     fi
   done
 
   #then, parse the options as they override the options from file
-  while [[ -n ${1} ]]; do
-    local var=${1#--}
-    if [[ ${var} =~ .*=.* ]]; then
-      eval "${var}"
-    else
+  for opt in "${args[@]}"; do
+    if [[ ! "${opt}" =~ .*=.* ]]; then
       echo "badly formatted option ${var}, should be: option=value, stopping..."
       return 1
     fi
-    shift
+    local var="${opt%%=*}"
+    local value="${opt#*=}"
+    echo "${var} = ${value}"
+    export ${var}="${value}"
   done
 }