#!/bin/sh # To change the default values for the EPICS Environment parameters, # uncomment and modify the relevant lines below. export EPICS_IOC_LOG_PORT export EPICS_IOC_LOG_FILE_NAME export EPICS_IOC_LOG_FILE_LIMIT EPICS_IOC_LOG_PORT="6500" EPICS_IOC_LOG_FILE_NAME="/exchange/slsop/common/log/iocLog/$(hostname -i|cut -f 1,2 -d .)" MV_LOG="" if [ "$1" = "-m" ] then email="$2" shift 2 else email="" fi outtmp=/tmp/iocLogger_out$$ errtmp=/tmp/iocLogger_err$$ rm -f $outtmp $errtmp function output () { if [ "$email" = "" ] then echo $* else echo $* >>$outtmp fi } { if touch $EPICS_IOC_LOG_FILE_NAME 2>/dev/null then mv $EPICS_IOC_LOG_FILE_NAME ${EPICS_IOC_LOG_FILE_NAME}_$(date +%Y%m%d_%H%M) output "Moved logfile to ${EPICS_IOC_LOG_FILE_NAME}_$(date +%Y%m%d_%H%M)" fi EPICS_IOC_LOG_FILE_LIMIT="10000000" LOGSVRNAME=iocLogServer export PATH=$PATH:/prod/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/prod/lib LOGSVR=$(which $LOGSVRNAME) if [ "$1" = "stop" ] || [ "$1" = "restart" ] then pid=$(ps acx | awk '$0 ~/iocLogServer/{print $1}') if [ "${pid}" != "" ] then output "Stopping EPICS Log Server " kill ${pid} sleep 1 else output "No EPICS Log Server running" fi fi if [ "$1" = "start" ] || [ "$1" = "restart" ] then if [ -x $LOGSVR ] then output "Starting EPICS Log Server $LOGSVR ${EPICS_IOC_LOG_FILE_NAME}" $LOGSVR & else output "location of \"$LOGSVRNAME\" must be in the PATH" output "$LOGSVR" fi fi if [ "$1" != "start" ] && [ "$1" != "restart" ] && [ "$1" != "stop" ] then echo "using: $0 start|stop|restart" >&2 fi } >>$outtmp 2>>$errtmp if [ -s $errtmp ] && [ "$email" != "" ] then cat $outtmp $errtmp | mail -s "iocLogger $1 $(hostname)" $email elif [ "$email" = "" ] then cat $outtmp $errtmp fi rm -f $outtmp $errtmp