#!/bin/sh # default image export OSG_SINGULARITY_IMAGE_DEFAULT="/cvmfs/singularity.opensciencegrid.org/cmssw/cms:rhel6-m202001" # 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 source ${SAME_SENSOR_HOME}/tests/singularity_lib.sh echo "Unsetting SCRAM_ARCH..." unset SCRAM_ARCH # 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 export PATH SINGULARITY_BIN=${SINGULARITY_BIN:-"/usr/bin"} singularity_locate_bin "$SINGULARITY_BIN" $OSG_SINGULARITY_IMAGE_DEFAULT # 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 echo 'ERROR: Singularity not found!' echo 'summary: SINGULARITY_NOT_FOUND' exit $SAME_ERROR else echo "OSG_SINGULARITY_VERSION = ${GWMS_SINGULARITY_VERSION}" echo "OSG_SINGULARITY_PATH = ${GWMS_SINGULARITY_PATH}" fi OSG_SINGULARITY_EXTRA_OPTS="--home ${SAME_SENSOR_HOME}:/srv --bind /cvmfs --contain" # Various possible mount points to pull into the container: for VAR in /lfs_roots /storage /cms /hadoop /hdfs /mnt/hadoop /etc/cvmfs/SITECONF; do if [ -e "$VAR" ]; then OSG_SINGULARITY_EXTRA_OPTS="$OSG_SINGULARITY_EXTRA_OPTS --bind $VAR" fi done echo "OSG_SINGULARITY_EXTRA_OPTS = ${OSG_SINGULARITY_EXTRA_OPTS}" 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 "ERROR: proxy not found!" echo "summary: PROXY_NOT_FOUND" exit $SAME_ERROR fi export X509_USER_PROXY=/srv/proxy.pem cd /cvmfs/singularity.opensciencegrid.org $GWMS_SINGULARITY_PATH exec $OSG_SINGULARITY_EXTRA_OPTS \ --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