forked from epics_driver_modules/require
support init files
This commit is contained in:
@@ -14,6 +14,7 @@ help () {
|
||||
echo " -d, --debug Run IOC with gdb."
|
||||
echo " -dv Run IOC with valgrind."
|
||||
echo " -dp Run IOC with perf record."
|
||||
echo " -i bashscript Source bashscript before starting ioc."
|
||||
echo " -c 'cmd args' Ioc shell command."
|
||||
echo " -s 'prog m=v' Sequencer program (and arguments), run with 'seq'."
|
||||
echo " This forces an 'iocInit' before running the program."
|
||||
@@ -30,6 +31,9 @@ help () {
|
||||
echo "All other files are executed as startup scripts by the EPICS shell."
|
||||
echo "After a file you can specify substitutions like m1=v1 m2=v1 for that file."
|
||||
echo
|
||||
echo "If a readable file iocsh.init exists in ./, cfg/, or /etc/, it is sourced"
|
||||
echo "when iocsh starts. Only the first one found is sourced."
|
||||
echo
|
||||
echo "Examples:"
|
||||
echo " iocsh st.cmd"
|
||||
echo " iocsh my_database.template P=XY M=3"
|
||||
@@ -70,6 +74,19 @@ then
|
||||
unset EPICS_BASE
|
||||
fi 2> /dev/null
|
||||
|
||||
# IOC name derives from hostname
|
||||
# (trailing possible '\r' under cygwin)
|
||||
IOC=$(hostname|tr -d '\r')
|
||||
# trailing possible domain name
|
||||
IOC=${IOC%%.*}
|
||||
# or get IOC name from start directory following PSI convention
|
||||
D=$(basename $(dirname $PWD))
|
||||
if [ ${D#*_} = "ioc" ]
|
||||
then
|
||||
IOC=$(basename $PWD)
|
||||
fi
|
||||
export IOC
|
||||
|
||||
while true
|
||||
do
|
||||
case $1 in
|
||||
@@ -83,6 +100,10 @@ do
|
||||
unset EPICS_BASE
|
||||
BASE=${1#-}
|
||||
;;
|
||||
( -n )
|
||||
shift
|
||||
IOC="$1"
|
||||
;;
|
||||
( * ) break
|
||||
;;
|
||||
esac
|
||||
@@ -210,19 +231,6 @@ do
|
||||
fi
|
||||
done
|
||||
|
||||
# IOC name derives from hostname
|
||||
# (trailing possible '\r' under cygwin)
|
||||
IOC=$(hostname|tr -d '\r')
|
||||
# trailing possible domain name
|
||||
IOC=${IOC%%.*}
|
||||
# or get IOC name from start directory following PSI convention
|
||||
D=$(basename $(dirname $PWD))
|
||||
if [ ${D#*_} = "ioc" ]
|
||||
then
|
||||
IOC=$(basename $PWD)
|
||||
fi
|
||||
export IOC
|
||||
|
||||
# Check for 64 bit versions, default to 32 bit
|
||||
if [ ! -d $EPICS_BASE/lib/${EPICS_HOST_ARCH} -a -d $EPICS_BASE/lib/${EPICS_HOST_ARCH%_64} ]
|
||||
then
|
||||
@@ -258,6 +266,16 @@ then
|
||||
fi
|
||||
export EPICS_DRIVER_PATH
|
||||
|
||||
# Call init script after IOC name, EPICS_HOST_ARCH and EPICS_BASE are set.
|
||||
for dir in . cfg /etc
|
||||
do
|
||||
if [ -r $dir/iocsh.init ]
|
||||
then
|
||||
source $dir/iocsh.init
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
loadFiles () {
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
@@ -289,6 +307,10 @@ do
|
||||
( -dp )
|
||||
LOADER="perf record $LOADER"
|
||||
;;
|
||||
( -i )
|
||||
shift
|
||||
source $1
|
||||
;;
|
||||
( -c )
|
||||
shift
|
||||
case $1 in
|
||||
@@ -318,10 +340,6 @@ do
|
||||
shift
|
||||
echo "require $1"
|
||||
;;
|
||||
( -n )
|
||||
shift
|
||||
IOC="$1"
|
||||
;;
|
||||
( -* )
|
||||
echo "Unknown option $1" >&2
|
||||
echo "Try: $(basename $0) --help" >&2
|
||||
|
||||
Reference in New Issue
Block a user