From a3ac56e5422a28e80b65e61c918bb08238e8a8e8 Mon Sep 17 00:00:00 2001 From: Jameson Rollins <jameson.rollins@ligo.org> Date: Thu, 22 Aug 2019 15:50:31 -0700 Subject: [PATCH] cli: elliminate need to specify OPTRTCDS env var in /etc/advligorts/env The target location of /opt/rtcds/$site/$ifo is hard coded deep throughout the code. Until we address that issue, we can just derive the target from SITE and IFO, which simplifies the config. --- support/bin/rtcds.in | 60 ++++++++++++++++++++++++++----------- support/bin/rts_epics_exec | 7 +++-- support/bin/rts_module_ctrl | 4 +-- 3 files changed, 49 insertions(+), 22 deletions(-) diff --git a/support/bin/rtcds.in b/support/bin/rtcds.in index 982625a31..9650c8a18 100755 --- a/support/bin/rtcds.in +++ b/support/bin/rtcds.in @@ -1,11 +1,9 @@ #!/bin/bash -e RTS_VERSION=${RTS_VERSION:-__VERSION__} -ENV_FILE=${RTS_ENV:-/etc/advligorts/env} -RCG_SRC=${RCG_SRC:-/usr/share/advligorts/src} -RCG_BUILDD=${RCG_BUILDD:-/var/cache/advligorts/rcg-$RTS_VERSION} -RTS_USER=${RTS_USER:-controls} +# this should define all USER_VARS (see below) +ENV_FILE=${RTS_ENV:-/etc/advligorts/env} source "$ENV_FILE" 2>/dev/null || true SITE=${SITE^^*} @@ -13,15 +11,22 @@ site=${SITE,,*} IFO=${IFO^^*} ifo=${IFO,,*} +RCG_SRC=${RCG_SRC:-/usr/share/advligorts/src} +RCG_BUILDD=${RCG_BUILDD:-/var/cache/advligorts/rcg-$RTS_VERSION} +# FIXME: the RCG hard-codes /opt/rtcds as the root +RCG_TARGET=/opt/rtcds/${site}/${ifo} +RTS_USER=${RTS_USER:-controls} + # search paths for C source code CDS_SRC=${CDS_SRC:-$RCG_LIB_PATH} CDS_IFO_SRC=${CDS_IFO_SRC:-$CDS_SRC} # add RCG module source to lib path +# FIXME: rename RCG_MOD_PATH RCG_LIB_PATH=$RCG_LIB_PATH:${RCG_SRC}/src/epics/simLink/:${RCG_SRC}/src/epics/simLink/lib -USER_VARS=(SITE IFO OPTRTCDS RCG_LIB_PATH) -LIST_VARS=(RTS_VERSION ${USER_VARS[@]} RCG_SRC RCG_BUILDD RTS_USER) +USER_VARS=(SITE IFO RCG_LIB_PATH) +LIST_VARS=(RTS_VERSION ${USER_VARS[@]} RCG_SRC RCG_BUILDD RCG_TARGET RTS_USER) EXPORT_VARS=(${USER_VARS[@]} site ifo CDS_SRC CDS_IFO_SRC) ################################################## @@ -49,20 +54,40 @@ check_env() { done } -prep_target(){ - log "creating OPTRTCDS..." - mkdir -p ${OPTRTCDS}/{target,chans}/tmp -} - prep_buildd() { - sudo mkdir -p "$RCG_BUILDD" - sudo chown "$RTS_USER" "$RCG_BUILDD" - if [ -e "$RCG_BUILDD"/Makefile ] ; then - return + if [ -d "$RCG_BUILDD" ] ; then + return fi - log "configuring RCG_BUILDD..." + log "creating RCG_BUILDD $RCG_BUILDD..." + if sudo -u $RTS_USER mkdir -p "$RCG_BUILDD" 2>/dev/null ; then + sudo -u $RTS_USER chown $RTS_USER:$RTS_USER "$RCG_BUILDD" + elif sudo mkdir -p "$RCG_BUILDD" 2>/dev/null ; then + sudo chown $RTS_USER:$RTS_USER "$RCG_BUILDD" + else + log "Could not create build directory '$RCG_BUILDD' (owner: $RTS_USER:$RTS_USER)." + log "Please create manually to continue." + exit 1 + fi + log "configuring RCG_BUILDD $RCG_BUILDD..." cd "$RCG_BUILDD" - "$RCG_SRC"/configure + sudo -u $RTS_USER "$RCG_SRC"/configure +} + +prep_target(){ + if [ -d "$RCG_TARGET" ] ; then + return + fi + log "creating RCG_TARGET $RCG_TARGET..." + if sudo -u $RTS_USER mkdir -p "$RCG_TARGET" 2>/dev/null ; then + sudo -u $RTS_USER chown $RTS_USER:$RTS_USER "$RCG_TARGET" + elif sudo mkdir -p "$RCG_TARGET" 2>/dev/null ; then + sudo chown $RTS_USER:$RTS_USER "$RCG_TARGET" + else + log "Could not create target directory '$RCG_TARGET' (owner: $RTS_USER:$RTS_USER)." + log "Please create manually to continue." + exit 1 + fi + sudo -u $RTS_USER mkdir -p ${RCG_TARGET}/{target,chans/tmp} } ######## @@ -224,6 +249,7 @@ case $cmd in exit 2 fi check_env + prep_target install_sys $@ ;; 'start') diff --git a/support/bin/rts_epics_exec b/support/bin/rts_epics_exec index 8425af5de..605c6a5bd 100755 --- a/support/bin/rts_epics_exec +++ b/support/bin/rts_epics_exec @@ -6,6 +6,7 @@ if [ -z "$sys" ] ; then exit 1 fi export EPICS_DB_INCLUDE_PATH=/usr/lib/epics/dbd -TARGET=${OPTRTCDS}/target/${sys}/${sys}epics -cd ${TARGET} -exec ${TARGET}/${sys}epics ${sys}epics${IFO}.cmd +TARGET=/opt/rtcds/${SITE,,*}/${IFO,,*} +ETARGET=${TARGET}/target/${sys}/${sys}epics +cd ${ETARGET} +exec ./${sys}epics ${sys}epics${IFO}.cmd diff --git a/support/bin/rts_module_ctrl b/support/bin/rts_module_ctrl index 25c44ef7d..e5ad15861 100755 --- a/support/bin/rts_module_ctrl +++ b/support/bin/rts_module_ctrl @@ -6,10 +6,10 @@ if [ -z "$sys" ] ; then echo "usage: $(basename $0) start|stop <sys>" exit 1 fi -TARGET=${OPTRTCDS}/target/${sys} +TARGET=/opt/rtcds/${SITE,,*}/${IFO,,*} case $cmd in start) - /sbin/insmod "$TARGET"/bin/${sys}.ko + /sbin/insmod "$TARGET"/target/${sys}/bin/${sys}.ko ;; stop) /sbin/rmmod ${sys} -- GitLab