@@ -113,6 +113,9 @@ display_help() {
113113 echo " when a directory is provided, the format of the"
114114 echo " tarball's name will be {REPO_ID}-{TIMESTAMP}.tgz"
115115 echo " [default: not set]"
116+ echo " -S | --sandbox - use sandbox mode (i.e. convert .sif image to sandbox and then run"
117+ echo " it instead)"
118+ echo " [default: not set]"
116119 echo " -v | --verbose - display more information [default: false]"
117120 echo " -x | --http-proxy URL - provides URL for the env variable http_proxy"
118121 echo " [default: not set]; uses env var \$ http_proxy if set"
@@ -275,6 +278,10 @@ while [[ $# -gt 0 ]]; do
275278 SAVE=" $2 "
276279 shift 2
277280 ;;
281+ -S|--sandbox)
282+ SANDBOX=1
283+ shift 1
284+ ;;
278285 -u|--resume)
279286 RESUME=" $2 "
280287 shift 2
@@ -1039,10 +1046,23 @@ for arg in "${PASS_THROUGH[@]}"; do
10391046 ADDITIONAL_CONTAINER_OPTIONS+=(${arg} )
10401047done
10411048
1042- echo " Launching container with command (next line):"
1043- echo " singularity ${RUN_QUIET} ${MODE} ${ADDITIONAL_CONTAINER_OPTIONS[@]} ${EESSI_FUSE_MOUNTS[@]} ${CONTAINER} $@ "
1044- singularity ${RUN_QUIET} ${MODE} " ${ADDITIONAL_CONTAINER_OPTIONS[@]} " " ${EESSI_FUSE_MOUNTS[@]} " ${CONTAINER} " $@ "
1045- exit_code=$?
1049+ # EESSI_SINGULARITY_SANDBOX is an environment variable (typically set in site_config.sh, if needed)
1050+ if [[ -n " ${EESSI_SINGULARITY_SANDBOX} " || ${SANDBOX} -eq 1 ]]; then
1051+ # using a sandbox image mode is more robust at the cleanup phase at the end
1052+ CONTAINER_SANDBOX=" ${CONTAINER% .sif} .sandbox"
1053+ echo " Building a sandbox image with command (next line):"
1054+ echo " singularity build --sandbox --force ${CONTAINER_SANDBOX} ${CONTAINER} "
1055+ singularity build --sandbox --force ${CONTAINER_SANDBOX} ${CONTAINER}
1056+ echo " Launching sandbox container with command (next line):"
1057+ echo " singularity ${RUN_QUIET} ${MODE} ${ADDITIONAL_CONTAINER_OPTIONS[@]} ${EESSI_FUSE_MOUNTS[@]} ${CONTAINER_SANDBOX} $@ "
1058+ singularity ${RUN_QUIET} ${MODE} " ${ADDITIONAL_CONTAINER_OPTIONS[@]} " " ${EESSI_FUSE_MOUNTS[@]} " ${CONTAINER_SANDBOX} " $@ "
1059+ exit_code=$?
1060+ else
1061+ echo " Launching container with command (next line):"
1062+ echo " singularity ${RUN_QUIET} ${MODE} ${ADDITIONAL_CONTAINER_OPTIONS[@]} ${EESSI_FUSE_MOUNTS[@]} ${CONTAINER} $@ "
1063+ singularity ${RUN_QUIET} ${MODE} " ${ADDITIONAL_CONTAINER_OPTIONS[@]} " " ${EESSI_FUSE_MOUNTS[@]} " ${CONTAINER} " $@ "
1064+ exit_code=$?
1065+ fi
10461066
10471067# 6. save tmp if requested (arg -s|--save)
10481068if [[ ! -z ${SAVE} ]]; then
0 commit comments