Epics@GSI Webhome

StartBackgroundEpicsIOC script: (re)start hadcon at reboot - procServ caller

%begin bash% #!/bin/sh # startBackgroundEpicsIOC.sh # # starts EPICS IOC in background using procServ tool # # created: 28-05-2009 # author: p.zumbruch, GSI # modified: 29-05-2009

#debug - uncomment to debug #set -xv

#predefines scriptname=startBackgroundEpicsIOC.sh

HomeHadaq=/home/hadaq

EpicsAppBaseDir=${HomeHadaq}/EPICS/epics_apps EpicsAppDir=${EpicsAppBaseDir}/HadControlTemperatureAndThreshold EpicsIocBootDir=${EpicsAppDir}/iocBoot/iocHadControlTemperatureAndThreshold_linux-cris_v10 EpicsCommandName=st_linux-cris_v10.cmd

ProcServExecutableDir=${HomeHadaq}/peter/procServ ProcServLibDir=${HomeHadaq}/peter/procServ/lib ProcServExecutable=${ProcServExecutableDir}/procServ

ProcServTelnetPort=48120 #(4711 + 101)*10

ProcServProcName="$(hostname):${EpicsCommandName}"

unset myDebug;

#unset function unsets () { unset myHostname mylist item unset EpicsBaseDir unset EpicsAppDir unset EpicsIocBootDir unset EpicsCommandName

unset ProcServExecutableDir unset ProcServLibDir unset ProcServExecutable

unset ProcServTelnetPort unset ProcServProcName unset myDebug return 0; }

#usage function usage() { echo echo "$scriptname" echo "usage: $scriptname [options]" echo echo "starts EPICS IOC in background using procServ tool," echo " which spawns and automatically respawns the ioc process " echo " and makes it available via local telnet:" echo " telnet localhost port" echo " where port is set to default \`${ProcServTelnetPort}'" echo "options:" echo " -h : this help" echo " -d : debug mode sets set -xv" echo " -a dir : EPICS IOC application dir" echo " [\`${EpicsAppDir}']" echo " -i dir : EPICS IOC iocboot dir " echo " [\`${EpicsIocBootDir}']" echo " -c command file : st.cmd file started relativ to \`./' " echo " [\`${EpicsCommandName}']" echo " -e procServ exe : procServ executable" echo " [\`${ProcServExecutable}']" echo " -l procServ lib : procServ lib path needed to be added to LD_LIBRARY_PATH" echo " [\`${ProcServLibDir}']" echo " -p port : telnet port [\`${ProcServTelnetPort}'], see above" echo " -n name : name of process" echo " [\`${ProcServProcName}']" echo " -D : just echos command instead of executing" echo }

#eval options while getopts a:c:de:hi:l:n:p:D arg do case $arg in \? | h )usage ; unsets; exit 0; shift ;; a ) EpicsAppDir=$OPTARG; shift 2;; i ) EpicsIocBootDir=$OPTARG; shift 2;; c ) EpicsCommandName=$OPTARG; shift 2;; e ) ProcServExecutable=$OPTARG; shift 2;; l ) ProcServLibDir=$OPTARG; shift 2;; p ) ProcServTelnetPort=$OPTARG; shift 2;; n ) ProcServProcName=$OPTARG; shift 2;; d ) set -xv shift;; D ) myDebug=echo shift;; esac done

#check directories and permissions if [ ! -d "${EpicsIocBootDir}" ] then echo "$scriptname: EPICS IOC Boot dir: \`${EpicsIocBootDir}' is not a valid directory ... exiting" 1>&2 unsets exit 1; fi if [ ! -f "${EpicsIocBootDir}/${EpicsCommandName}" ]; then echo "$scriptname: EPICS IOC st.cmd file \`${EpicsIocBootDir}/${EpicsCommandName}' is not a valid file ... exiting" 1>&2 unsets exit 1; fi

[ ! -z ${ProcServLibDir} ] && for item in $(echo ${ProcServLibDir} | sed -e 's/:/ /g') do if [ ! -d "${item}" ] then echo "$scriptname: procServ Lib dir \`${ProcServLibDir}' contains invalid directory \`$item' ... exiting" 1>&2 unsets exit 1; fi done

if [ ! -x "${ProcServExecutable}" ] then echo "$scriptname: procServ executable \`${ProcServExecutable}' is not a valid executable ... exiting" 1>&2 unsets exit 1; fi

#execute ${myDebug} eval ${ProcServLibDir:+LD_LIBRARY_PATH=${ProcServLibDir}${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}} ${ProcServExecutable} --chdir ${EpicsIocBootDir} --ignore ^D^C --name "${ProcServProcName}" ${ProcServTelnetPort} ./${EpicsCommandName}

unsets

exit 0 %end%


-- PeterZumbruch - 13 Jan 2010

Topic attachments
ISorted ascending Attachment Action Size Date Who Comment
startBackgroundEpicsIOC.shsh startBackgroundEpicsIOC.sh manage 4.0 K 2010-01-13 - 15:07 PeterZumbruch startBackgroundEpicsIOC.sh
This topic: Epics > WebHome > EpicsProjectsAndActivities > HadesControlSystem > HowToSetupHadesIOCsRestartAtReboot > HowToSetupHadesIOCsRestartAtRebootIOCStartBackgroundEpicsIocScript
Topic revision: revision 1
 
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding GSI Wiki? Send feedback
Imprint (in German)
Privacy Policy (in German)