File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ # Runs a job containerized ... as would be the case on the GRID.
4+ # Mimics what the AliEn job handler does.
5+
6+ SCRIPT=$1
7+ [ $SCRIPT == " " ] && echo " Please provide a script to run" && exit 1
8+ echo " Trying to run script ${SCRIPT} in a container environment"
9+
10+ # we just use the default singularity container
11+ APPTAINER_CONTAINER=/cvmfs/alice.cern.ch/containers/fs/singularity/default
12+
13+ # create workdir
14+ WORK_DIR=$( mktemp -d /tmp/alien-job-XXXXXX)
15+ echo " This job will be run in $WORK_DIR "
16+
17+ # copy script to WORK_DIR
18+ cp ${SCRIPT} ${WORK_DIR} /job.sh
19+
20+ # export certificates (need to be created before)
21+ ALIEN_CERTFILE=$( ls -t /tmp/tokencert_* .pem 2> /dev/null | head -n 1)
22+ ALIEN_KEYFILE=$( ls -t /tmp/tokenkey_* .pem 2> /dev/null | head -n 1)
23+
24+ [ " ${ALIEN_CERTFILE} " == " " ] && echo " No certificate file found; Initialize a token with alien-init-token or similar" && exit 1
25+ [ " ${ALIEN_KEYFILE} " == " " ] && echo " No certificate file found; Initialize a token with alien-init-token or similar" && exit 1
26+
27+ JALIEN_TOKEN_CERT=$( awk ' ! /^-/{print $0}' ${ALIEN_CERTFILE} | tr -d ' \n' )
28+ JALIEN_TOKEN_KEY=$( awk ' ! /^-/{print $0}' ${ALIEN_KEYFILE} | tr -d ' \n' )
29+
30+ echo " JALIEN_TOKEN_CERT=${JALIEN_TOKEN_CERT} " > ${WORK_DIR} /envfile
31+ echo " JALIEN_TOKEN_KEY=${JALIEN_TOKEN_KEY} " >> ${WORK_DIR} /envfile
32+
33+ # 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 \
35+ --pwd /workdir --env-file ${WORK_DIR} /envfile ${APPTAINER_CONTAINER} /workdir/job.sh
You can’t perform that action at this time.
0 commit comments