Skip to content

Commit 6437a6e

Browse files
committed
prevent binding nonexistent files/directories
1 parent 5f95038 commit 6437a6e

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

bind_condor.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
#!/bin/bash
22

3+
bind_if_exists(){
4+
for ITEM in "$@"; do
5+
TESTITEM="${ITEM%%:*}"
6+
if [ -e "$TESTITEM" ]; then
7+
export APPTAINER_BIND=${APPTAINER_BIND}${APPTAINER_BIND:+,}${ITEM}
8+
fi
9+
done
10+
}
11+
312
LPC_CONDOR_CONFIG=/etc/condor/config.d/01_cmslpc_interactive
413
LPC_CONDOR_LOCAL=/usr/local/bin/cmslpc-local-conf.py
514

@@ -12,18 +21,18 @@ if [ "$COMMAND_NAME" = "$(basename $LPC_CONDOR_LOCAL)" ]; then
1221
fi
1322

1423
OSG_CONDOR_CONFIG=/etc/condor/condor_config
15-
OSG_CONDOR_LOCAL=/usr/share/condor/config.d,/etc/condor/config.d
24+
OSG_CONDOR_LOCAL=(/usr/share/condor/config.d /etc/condor/config.d)
1625

1726
LXP_CONDOR_CONFIG=/etc/condor/condor_config
18-
LXP_CONDOR_LOCAL=/etc/condor/config.d,/usr/bin/myschedd.sh,/usr/bin/myschedd,/etc/myschedd
27+
LXP_CONDOR_LOCAL=(/etc/condor/config.d /usr/bin/myschedd.sh /usr/bin/myschedd /etc/myschedd)
1928

2029
if [[ "$(uname -a)" == *cms*.fnal.gov* ]]; then
21-
export APPTAINER_BIND=${APPTAINER_BIND}${APPTAINER_BIND:+,}${LPC_CONDOR_CONFIG},${LPC_CONDOR_LOCAL}:${LPC_CONDOR_LOCAL}.orig,${COMMAND_PATH}:${LPC_CONDOR_LOCAL}
30+
bind_if_exists ${LPC_CONDOR_CONFIG} ${LPC_CONDOR_LOCAL}:${LPC_CONDOR_LOCAL}.orig "${COMMAND_PATH}":${LPC_CONDOR_LOCAL}
2231
export APPTAINERENV_CONDOR_CONFIG=${LPC_CONDOR_CONFIG}
2332
elif [[ "$(uname -a)" == *.uscms.org* ]] || [[ "$(uname -a)" == *.osg-htc.org* ]]; then
24-
export APPTAINER_BIND=${APPTAINER_BIND}${APPTAINER_BIND:+,}${OSG_CONDOR_CONFIG},${OSG_CONDOR_LOCAL}
33+
bind_if_exists ${OSG_CONDOR_CONFIG} "${OSG_CONDOR_LOCAL[@]}"
2534
export APPTAINERENV_CONDOR_CONFIG=${OSG_CONDOR_CONFIG}
2635
elif [[ "$(uname -a)" == *lxplus*.cern.ch* ]]; then
27-
export APPTAINER_BIND=${APPTAINER_BIND}${APPTAINER_BIND:+,}${LXP_CONDOR_CONFIG},${LXP_CONDOR_LOCAL}
36+
bind_if_exists ${LXP_CONDOR_CONFIG} "${LXP_CONDOR_LOCAL[@]}"
2837
export APPTAINERENV_CONDOR_CONFIG=${LXP_CONDOR_CONFIG}
2938
fi

0 commit comments

Comments
 (0)