Skip to content

Commit

Permalink
Merge pull request #163 from matyasselmeci/pr/die-if-exec-fails
Browse files Browse the repository at this point in the history
Exit out if 'exec' fails
  • Loading branch information
brianhlin authored Feb 2, 2024
2 parents 9a2c30d + a6b040a commit ab07dd8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions sbin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ cvmfsexec_local_config=$cvmfsexec_root/dist/etc/cvmfs/default.local
htcondor_supervisord_config=/etc/supervisord.d/10-htcondor.conf


safe_exec () {
exec "$@"
# we should not get here:
fail "Exec failed with $? on command '$*'"
}


add_or_replace () {
local file="$1"
local var="$2"
Expand Down Expand Up @@ -64,10 +71,10 @@ is_true () {
if [[ -d $config_repo ]]; then
echo "OSG CVMFS already available (perhaps via bind-mount),"
echo "skipping cvmfsexec."
exec "$@"
safe_exec "$@"
elif [[ ! $CVMFSEXEC_REPOS =~ [a-z]+ ]]; then
echo "No CVMFS repos requested, skipping cvmfsexec."
exec "$@"
safe_exec "$@"
fi
CVMFSEXEC_REPOS=$(tr -s ',' ' ' <<<"$CVMFSEXEC_REPOS")

Expand Down Expand Up @@ -105,8 +112,8 @@ fi

if [[ $1 == /usr/local/sbin/supervisord_startup.sh ]]; then
# If we're starting the pilot then run cvmfsexec under tini so signals are propagated
exec tini $cvmfsexec_root/cvmfsexec -- -N $CVMFSEXEC_REPOS -- "$@"
safe_exec tini $cvmfsexec_root/cvmfsexec -- -N $CVMFSEXEC_REPOS -- "$@"
else
# If we're exec'ing in or running an alternate command, then just run cvmfsexec.
exec $cvmfsexec_root/cvmfsexec -N $CVMFSEXEC_REPOS -- "$@"
safe_exec $cvmfsexec_root/cvmfsexec -N $CVMFSEXEC_REPOS -- "$@"
fi

0 comments on commit ab07dd8

Please sign in to comment.