#!/bin/bash # # The script saves information to Run Configuration database on end of run # path to coda run statistics should be provided to script as first argument # #--------------------------------------------------------------------------- # 1. FIND THIS SCRIPT PATH #Next lines just finds the path of the file #Works for all versions,including #when called via multple depth soft link, #when script called by command "source" aka . (dot) operator. #when arg $0 is modified from caller. #"./script" "/full/path/to/script" "/some/path/../../another/path/script" "./some/folder/script" #THIS_SCRIPT_PATH is given in full path, no matter how it is called. #Just make sure you locate this at start of the script. THIS_SCRIPT_PATH="${BASH_SOURCE[0]}"; if([ -h "${THIS_SCRIPT_PATH}" ]) then while([ -h "${THIS_SCRIPT_PATH}" ]) do THIS_SCRIPT_PATH=`readlink "${THIS_SCRIPT_PATH}"`; done fi pushd . > /dev/null cd `dirname ${THIS_SCRIPT_PATH}` > /dev/null THIS_SCRIPT_PATH=`pwd`; popd > /dev/null # 2. IS ENVIRONMENT SET? if [ -z "$RCDB_HOME" ]; then source $THIS_SCRIPT_PATH/daq_environment.bash fi source $THIS_SCRIPT_PATH/daq_environment.bash if [ -z "$RCDB_CONNECTION" ]; then source $THIS_SCRIPT_PATH/daq_environment.bash fi #3. PYTHON SCRIPT START if [[ $# -eq 1 ]]; then LOGFILE="$1" shift else LOGFILE=$COOL_HOME/$SESSION/ddb/run-log/$SESSION/current_run.log fi date echo LOG=$LOGFILE cat $LOGFILE echo "RCDB PATH=$THIS_SCRIPT_PATH" echo "RCDB_CONNECTION=$RCDB_CONNECTION" echo "RCDB_HOME=$RCDB_HOME" echo "PYTHONPATH=$PYTHONPATH" #sleep 5 echo "------------- rcdb update python ---------------------" echo "update.py params: $*" python $RCDB_HOME/python/update.py $LOGFILE "$@"