CE-cms-singularity-wrapper 2.84 KB
Newer Older
1
2
#!/bin/sh

3
4
5
# default image
export OSG_SINGULARITY_IMAGE_DEFAULT="/cvmfs/singularity.opensciencegrid.org/cmssw/cms:rhel6-m202001"

6
7
8
9
10
11
12
13
14
# Useful Information in case of a problem:
echo "System: `/bin/uname -a`"
echo "Current working directory: `/bin/pwd`"
/bin/ls -ld .
echo "SAME_SENSOR_HOME = ${SAME_SENSOR_HOME}"
/bin/ls -ld ${SAME_SENSOR_HOME}
echo "PATH = ${PATH}"
/bin/ls -l /cvmfs/cms.cern.ch/SITECONF/local || true

15
16
source ${SAME_SENSOR_HOME}/tests/singularity_lib.sh

17
18
19
echo "Unsetting SCRAM_ARCH..."
unset SCRAM_ARCH

20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Argument is the name of the test to run inside singularity
TEST_SCRIPT=$1

# some known singularity locations
for LOCATION in \
         /util/opt/singularity/2.2.1/gcc/4.4/bin \
         /util/opt/singularity/2.2/gcc/4.4/bin \
         /uufs/chpc.utah.edu/sys/installdir/singularity/std/bin ; do
     if [ -e "$LOCATION" ]; then
         echo " ... prepending $LOCATION to PATH"
         export PATH="$LOCATION:$PATH"
         break
     fi
done
34
export PATH
35

36
singularity_locate_bin /usr/bin $OSG_SINGULARITY_IMAGE_DEFAULT
37
38
39
40
41
42
43
44

# Grid environment is taken from OSG, check it's available:
if [ ! -e /cvmfs/oasis.opensciencegrid.org/osg-software/osg-wn-client ]; then
     HAS_SINGULARITY='False'
     echo "WARNING: OSG client software CVMFS not accessible"
fi

if [ "$HAS_SINGULARITY" == "False" ] ; then
45
46
47
48
     echo 'ERROR: Singularity not found!'
     echo 'summary: SINGULARITY_NOT_FOUND'
     exit $SAME_ERROR
else
49
50
     echo "OSG_SINGULARITY_VERSION = ${GWMS_SINGULARITY_VERSION}"
     echo "OSG_SINGULARITY_PATH = ${GWMS_SINGULARITY_PATH}"
51
52
53
54
fi

OSG_SINGULARITY_EXTRA_OPTS="--home ${SAME_SENSOR_HOME}:/srv --bind /cvmfs --contain"
# Various possible mount points to pull into the container:
Andrea Sciaba's avatar
Andrea Sciaba committed
55
for VAR in /lfs_roots /storage /cms /hadoop /hdfs /mnt/hadoop /etc/cvmfs/SITECONF; do
56
57
58
59
   if [ -e "$VAR" ]; then
      OSG_SINGULARITY_EXTRA_OPTS="$OSG_SINGULARITY_EXTRA_OPTS --bind $VAR"
   fi
done
60
echo "OSG_SINGULARITY_EXTRA_OPTS = ${OSG_SINGULARITY_EXTRA_OPTS}"
Andrea Sciaba's avatar
Andrea Sciaba committed
61
62
63
64
65
66
67
68
69
70
if [ -f "$X509_USER_PROXY" ] ; then
   cp -f $X509_USER_PROXY ${SAME_SENSOR_HOME}/proxy.pem
elif [ -f /tmp/x509up_u`id -u` ] ; then
   cp -f /tmp/x509up_u`id -u` ${SAME_SENSOR_HOME}/proxy.pem
else
   echo "ERRROR: proxy not found!"
   echo "summary: PROXY_NOT_FOUND"
   exit $SAME_ERROR
fi
export X509_USER_PROXY=/srv/proxy.pem
71
72

cd /cvmfs/singularity.opensciencegrid.org
73
$GWMS_SINGULARITY_PATH exec $OSG_SINGULARITY_EXTRA_OPTS \
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
                                --pwd /srv \
                                --ipc --pid \
                                "$OSG_SINGULARITY_IMAGE_DEFAULT" \
                                /srv/tests/CE-cms-singularity-runner /srv/tests/${TEST_SCRIPT}

RC=$?

# If the following code executes, Singularity failed
if [ "$RC" -eq 255 ] ; then
     echo "ERROR: Singularity execution of ${TEST_SCRIPT} finished with return code $RC"
     echo "summary: SINGULARITY_ERROR"
     exit $SAME_ERROR
fi

exit $RC