From 9b42d053c61150196e91ce1ffeb2f63f13e20239 Mon Sep 17 00:00:00 2001 From: Chiara Zampolli Date: Tue, 10 May 2022 22:29:55 +0200 Subject: [PATCH] protections for sourcing files --- DATA/common/getCommonArgs.sh | 6 ++++++ DATA/common/setenv.sh | 6 ++++++ DATA/common/setenv_calib.sh | 5 ++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/DATA/common/getCommonArgs.sh b/DATA/common/getCommonArgs.sh index 6d0d924ef..056db51c2 100644 --- a/DATA/common/getCommonArgs.sh +++ b/DATA/common/getCommonArgs.sh @@ -1,5 +1,9 @@ #!/bin/bash +# used to avoid sourcing this file 2x +if [[ -z $SOURCE_GUARD_GETCOMMONARGS ]]; then +SOURCE_GUARD_GETCOMMONARGS=1 + if [[ -z $SEVERITY || -z $NUMAID || -z $SHMSIZE || -z $FILEWORKDIR || -z $EPNSYNCMODE || -z $INFOLOGGER_SEVERITY || -z $SHMTHROW || -z $NORATELOG ]]; then echo "Configuration Environment Variable Missing in getCommonArgs.sh" 1>&2 exit 1 @@ -18,3 +22,5 @@ fi [[ $SHMTHROW == 0 ]] && ARGS_ALL+=" --shm-throw-bad-alloc 0" [[ ! -z $SHM_MANAGER_SHMID && "0$GEN_TOPO_CALIB_WORKFLOW" != "01" ]] && ARGS_ALL+=" --no-cleanup --shm-no-cleanup on --shmid $SHM_MANAGER_SHMID" [[ $NORATELOG == 1 ]] && ARGS_ALL+=" --fairmq-rate-logging 0" + +fi # getCommonArgs.sh sourced diff --git a/DATA/common/setenv.sh b/DATA/common/setenv.sh index bb3f6a687..cae0e2461 100755 --- a/DATA/common/setenv.sh +++ b/DATA/common/setenv.sh @@ -1,5 +1,9 @@ #!/bin/bash +# used to avoid sourcing this file 2x +if [[ -z $SOURCE_GUARD_SETENV ]]; then +SOURCE_GUARD_SETENV=1 + # Make sure we can open sufficiently many files / allocate enough memory if [[ "0$SETENV_NO_ULIMIT" != "01" ]]; then ulimit -S -n 4096 && ulimit -S -m unlimited && ulimit -S -v unlimited && [[ -z "$GPUTYPE" ]] || [[ "$GPUTYPE" == "CPU" ]] || ulimit -S -l unlimited @@ -244,3 +248,5 @@ add_semicolon_separated() fi done } + +fi # setenv.sh sourced diff --git a/DATA/common/setenv_calib.sh b/DATA/common/setenv_calib.sh index 1fad310ee..7d23a5e0a 100755 --- a/DATA/common/setenv_calib.sh +++ b/DATA/common/setenv_calib.sh @@ -7,7 +7,9 @@ # if they are not explicitly disabled. # Then, configure data spec according to enabled calibrations -source $O2DPG_ROOT/DATA/common/setenv.sh +# used to avoid sourcing this file 2x +if [[ -z $SOURCE_GUARD_SETENV_CALIB ]]; then +SOURCE_GUARD_SETENV_CALIB=1 if [[ $BEAMTYPE != "cosmic" ]] || [[ $FORCECALIBRATIONS == 1 ]] ; then @@ -142,3 +144,4 @@ get_proxy_connection() echo $PROXY_CONN } +fi # setenv_calib.sh sourced