#!/bin/bash # # RUN_PERIOD and RAWDATA_DIR environment variables are set in the file # /gluex/etc/hdonline.cshrc # # CODA will write files to: # # $RAWDATA_DIR/active/$RUN_PERIOD/rawdata/RunXXXXXX # # where "XXXXXX" is the zero padded run number. Other files # related to the run are also placed in this directory. # Some details on the strategy here are given in: # # https://halldweb1/wiki/index.php/Raid-to-Silo_Transfer_Strategy # #---- jcedit -------- # %(DAQ_HOME)/scripts # run_download %(rn) %(udl) %(config) %(rt) # run_prestart %(rn) %(udl) %(config) %(rt) # run_go %(rn) %(udl) %(config) %(rt) # run_end %(rn) %(udl) %(config) %(rt) #=========================================================================================== # !!!!!!!! STD in/out is not allowed in this script !!!!!! #STDO=/tmp/${USER}_DWN_loc.$1 #exec >$STDO 2>&1 SCRIPT=`basename $0 ` date echo "----- > $SCRIPT ENTER <---- param: $1 $2 $3 $4 $5 " #source /gluex/etc/hdonline.cshrc ENV_RAWDATA_DIR=`awk '/RAWDATA_DIR/ {printf "%s %s=%s\n",$1,$2,$3 }' /gluex/etc/hdonline.cshrc | grep setenv | sed s/setenv/export/g ` ENV_RUN_PERIOD=`awk '/RUN_PERIOD/ {printf "%s %s=%s\n",$1,$2,$3 }' /gluex/etc/hdonline.cshrc | grep setenv | sed s/setenv/export/g | sed s/\"//g` $ENV_RAWDATA_DIR $ENV_RUN_PERIOD echo "ENV_RAWDATA_DIR=$ENV_RAWDATA_DIR : $RAWDATA_DIR " echo "ENV_RUN_PERIOD=$ENV_RUN_PERIOD : $RUN_PERIOD" UDL=$2 CONFIG_FILE=$3 source run_lib.sh CONFIG_DIR=`dirname $CONFIG_FILE ` ER_name=ERsoftROC get_host $ER_name ER_host get_host platform pl_host get_host HOSS RST_HOSS #=========================================================================================== RCM_HOST=gluon25 RCM_PORT=32767 RCM_LOG=/dev/tcp/${RCM_HOST}/${RCM_PORT} RCM_LOG_FILE=$DAQ_HOME/../work/rcm_rc.log #------------------------------------------------------------------------------------------- function rcm_log() { echo -e " $1 $2 " # cMsgCommand -u cMsg://gluon100:45000/cMsg/$EXPID -name run_download -subject Download -type DAQ -text "$1" -string severity=$2 [ -n "$RCM_LOG" ] && echo -e "msg:GUI_runconf download:: $1 " > $RCM_LOG [ -n "$UDL" ] && cMsgCommand -u $UDL -name run_download -subject Download -type DAQ -text "$1" -string severity=$2 2>&1 > /tmp/${USER}_cMsgCommand echo -e "`date` :run_dwn:: $2: $1 " >> $RCM_LOG_FILE } # !!! Run Number is wrong !!!! rcm_log "Run=$1 user=$USER `date` UDL=$2 config=$3 4=$4 5=$5 " "INFO" if [ "$#" -lt 1 ]; then echo "You must provide a run number!" echo "" echo "Usage:" echo " run_download RUN" echo "" exit -1 fi export RUN=$(printf '%06d' $1) #=========================================================================================== # DAQ TEST MODE # if [ x$DAQMODE == "xtest" ] ; then rcm_log "WARN: DAQMODE=$DAQMODE " "WARN" exit 0 fi #=========================================================================================== # any other accounts .. # if [ $USER != "hdops" ] ; then which run_log.sh run_log.sh "DOWNLOAD" $RUN $CONFIG_FILE exit 0 fi #=========================================================================================== # HDOPS account only ... #------------------------------------------------------------------------------------------- which run_log.sh #run_log.sh "DOWNLOAD" $RUN $CONFIG_FILE host=`echo $HOST | cut -f1 -d.` if [ $pl_host != $host ] ; then rcm_log "start daq2epics host=$host platform=$pl_host , remote" "INFO" echo "exec: ssh -x $pl_host run_daq2epics.sh " ssh -x $pl_host run_daq2epics.sh 2>&1 > /dev/null & else rcm_log "start daq2epics host=$host platform=$pl_host , local" "INFO" run_daq2epics.sh 2>&1 > /dev/null & fi echo "-------> run_download HOSS restart = $RST_HOSS `date` <-------" # (re)start HOSS system # n.b. hdlog will write stdout to $HDLOG/start_hoss_.log if [ $RST_HOSS != yes ] ; then rcm_log "do not re-start HOSS" "INFO" else rcm_log "(re)start HOSS" "INFO" nohup hdlog start_hoss -r 2>&1 > /dev/null & fi echo "-------> run_download EXIT `date` <-------" exit 0