-
Notifications
You must be signed in to change notification settings - Fork 4
/
startProc
executable file
·66 lines (61 loc) · 1.95 KB
/
startProc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
# Usage: startProc IOCNAME PORT HUTCH
if [ -x /etc/pathinit ]; then
source /etc/pathinit
else
export PSPKG_ROOT=/reg/g/pcds/pkg_mgr
export PYPS_ROOT=/reg/g/pcds/pyps
export IOC_ROOT=/reg/g/pcds/epics/ioc
export CAMRECORD_ROOT=/reg/g/pcds/controls/camrecord
export IOC_DATA=/reg/d/iocData
export IOC_COMMON=/reg/d/iocCommon
fi
ioc=$1
port=$2
cfg=$3
shift;shift;shift
if test X$SCRIPTROOT == X; then export SCRIPTROOT=$PYPS_ROOT/config/$cfg/iocmanager; fi
# Start a new log if running procServ-2.6.0-SLAC.
if test X$PROCSERVPID != X; then kill -HUP $PROCSERVPID; fi
# Setup the IOC user environment.
export IOC=$ioc
source $IOC_COMMON/All/${cfg}_env.sh
dir=`python $SCRIPTROOT/getDirectory.py $ioc $cfg`
if test $dir == NO_DIRECTORY; then
if test X$PROCSERVPID != X; then
kill -9 $PROCSERVPID;
exit 0;
else
while test 1 == 1; do sleep 3600; done;
fi
fi
cd $IOC_ROOT/..
if test -d $dir; then cd $dir; fi
if test -f env.sh; then source ./env.sh; fi
if test -d children/build/iocBoot/$ioc; then cd children/build/iocBoot/$ioc; fi
if test -d build/iocBoot/$ioc; then cd build/iocBoot/$ioc; fi
if test -d iocBoot/$ioc; then cd iocBoot/$ioc; fi
if test -f env.sh; then source ./env.sh; fi
umask 2
echo $$ `hostname -s` $port $dir >$PYPS_ROOT/config/.status/$cfg/$ioc
chmod g+rw $PYPS_ROOT/config/.status/$cfg/$ioc
# Force an updated timestamp on the archive request file each time
# so we know when they're stale
if test -f ../../archive/$ioc.archive; then
mkdir -p $IOC_DATA/$ioc/archive
cp -f ../../archive/$ioc.archive $IOC_DATA/$ioc/archive/$ioc.archive;
fi
cmd=$1
shift
if [ "$EPICS_HOST_ARCH" == "linux-arm-apalis" ]; then
exec $cmd $@
else
# Fix T_A if needed in #!/path/to/bin/T_A/iocApp
file=`echo $cmd | awk '{print $1;}' -`
if test `head -c 2 $file | cat -v` == '#!'; then
prog=$(head -1 $file | sed -e 's/#!//' -e "s/[-a-z0-9]\+-x86_64/$EPICS_HOST_ARCH/")
exec $prog $cmd $@
else
exec $cmd $@
fi
fi