Skip to content

Commit 50ec7dc

Browse files
committed
platform independence of containerized execution
1 parent 94e512c commit 50ec7dc

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

GRID/utils/runGRIDContainerized.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,31 @@ SCRIPT=$1
77
[ $SCRIPT == "" ] && echo "Please provide a script to run" && exit 1
88
echo "Trying to run script ${SCRIPT} in a container environment"
99

10+
# detect architecture (ARM or X86)
11+
ARCH=$(uname -i)
12+
if [ "$ARCH" == "aarch64" ] || [ "$arch" == "x86" ]; then
13+
echo "Detected hardware architecture : $ARCH"
14+
else
15+
echo "Invalid architecture ${ARCH} detected. Exiting"
16+
exit 1
17+
fi
18+
if [ "$ARCH" == "aarch64" ]; then
19+
ISAARCH64="1"
20+
fi
1021
# we just use the default singularity container
11-
APPTAINER_CONTAINER=/cvmfs/alice.cern.ch/containers/fs/singularity/default
22+
APPTAINER_CONTAINER=/cvmfs/alice.cern.ch/containers/fs/singularity/default${ISAARCH64+"-aarch64"}
1223

13-
# create workdir
14-
WORK_DIR=$(mktemp -d /tmp/alien-job-XXXXXX)
24+
# create workdir if not specified externally
25+
if [ ! "${WORK_DIR}" ]; then
26+
WORK_DIR=$(mktemp -d /tmp/alien-job-XXXXXX)
27+
fi
1528
echo "This job will be run in $WORK_DIR"
1629

30+
if [ ! -d "${WORK_DIR}" ]; then
31+
echo "working directory ${WORK_DIR} does not exist; Please create before running"
32+
exit 1
33+
fi
34+
1735
# copy script to WORK_DIR
1836
cp ${SCRIPT} ${WORK_DIR}/job.sh
1937

@@ -31,5 +49,5 @@ echo "JALIEN_TOKEN_CERT=/workdir/usercert.pem" > ${WORK_DIR}/envfile
3149
echo "JALIEN_TOKEN_KEY=/workdir/userkey.pem" >> ${WORK_DIR}/envfile
3250

3351
# launch job = script inside the container in the workdir
34-
/cvmfs/alice.cern.ch/containers/bin/apptainer/current/bin/apptainer exec -C -B /cvmfs:/cvmfs,${WORK_DIR}:/workdir \
52+
/cvmfs/alice.cern.ch/containers/bin/apptainer/current${ISAARCH64+"-aarch64"}/bin/apptainer exec -C -B /cvmfs:/cvmfs,${WORK_DIR}:/workdir \
3553
--pwd /workdir --env-file ${WORK_DIR}/envfile ${APPTAINER_CONTAINER} /workdir/job.sh

0 commit comments

Comments
 (0)