File indexing completed on 2026-11-02 09:30:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 ORGANIZATION="eicweb"
0011 CONTAINER="eic_xl"
0012 VERSION="nightly"
0013 PREFIX="$PWD"
0014
0015 function print_the_help {
0016 echo "USAGE: ./install.sh [-p PREFIX] [-v VERSION]"
0017 echo "OPTIONAL ARGUMENTS:"
0018 echo " -p,--prefix Working directory to deploy the environment (D: $PREFIX)"
0019 echo " -t,--tmpdir Change tmp directory (D: $([[ -z "$TMPDIR" ]] && echo "/tmp" || echo "$TMPDIR"))"
0020 echo " -n,--no-cvmfs Disable check for local CVMFS (D: enabled)"
0021 echo " -o,--organization Organization (D: $ORGANIZATION) (requires cvmfs)"
0022 echo " -c,--container Container family (D: $CONTAINER)"
0023 echo " -v,--version Version to install (D: $VERSION)"
0024 echo " -h,--help Print this message"
0025 echo ""
0026 echo " Set up containerized development environment."
0027 echo ""
0028 echo "EXAMPLE: ./install.sh"
0029 exit
0030 }
0031
0032 while [ $
0033 key=$1
0034 case $key in
0035 -p|--prefix)
0036 PREFIX=$(realpath ${2?Missing argument. Use --help for more info.})
0037 shift
0038 shift
0039 ;;
0040 -t|--tmpdir)
0041 export TMPDIR=${2?Missing argument. Use --help for more info.}
0042 export APPTAINER_TMPDIR=${2?Missing argument. Use --help for more info.}
0043 export SINGULARITY_TMPDIR=${2?Missing argument. Use --help for more info.}
0044 shift
0045 shift
0046 ;;
0047 -n|--no-cvmfs)
0048 DISABLE_CVMFS_USAGE=true
0049 shift
0050 ;;
0051 -c|--container)
0052 CONTAINER=${2?Missing argument. Use --help for more info.}
0053 shift
0054 shift
0055 ;;
0056 -v|--version)
0057 VERSION=${2?Missing argument. Use --help for more info.}
0058 shift
0059 shift
0060 ;;
0061 -h|--help)
0062 print_the_help
0063 exit 0
0064 ;;
0065 *)
0066 echo "ERROR: unknown argument: $key"
0067 echo "use --help for more info"
0068 exit 1
0069 ;;
0070 esac
0071 done
0072
0073
0074 mkdir -p $PREFIX || exit 1
0075 pushd $PREFIX
0076
0077 if [ ! -d $PREFIX ]; then
0078 echo "ERROR: not a valid directory: $PREFIX"
0079 echo "use --help for more info"
0080 exit 1
0081 fi
0082
0083 echo "Setting up development environment for eicweb/$CONTAINER:$VERSION"
0084
0085 mkdir -p $PREFIX/local/lib || exit 1
0086
0087 function install_singularity() {
0088 SINGULARITY=
0089
0090
0091 if [ $(type -P apptainer ) ]; then
0092 SINGULARITY=$(which apptainer)
0093 SINGULARITY_VERSION=`$SINGULARITY --version`
0094 fi
0095 if [ -z "$SINGULARITY" ]; then
0096
0097
0098 if [ $(type -P singularity ) ]; then
0099 SINGULARITY=$(which singularity)
0100 SINGULARITY_VERSION=$($SINGULARITY --version)
0101 if [ ${SINGULARITY_VERSION:0:1} = 2 ]; then
0102
0103 SINGULARITY=
0104 fi
0105 fi
0106 fi
0107 if [ -z "$SINGULARITY" ]; then
0108
0109 if [ -d "/apps/singularity/3.7.1/bin/" ]; then
0110 SINGULARITY="/apps/singularity/3.7.1/bin/singularity"
0111
0112 elif [ $(type -P singularity ) ]; then
0113 SINGULARITY=$(which singularity)
0114
0115 elif [ -f "/cvmfs/oasis.opensciencegrid.org/mis/apptainer/bin/apptainer" ]; then
0116 SINGULARITY="/cvmfs/oasis.opensciencegrid.org/mis/apptainer/bin/apptainer"
0117
0118 elif [ -f "/cvmfs/oasis.opensciencegrid.org/mis/singularity/bin/singularity" ]; then
0119 SINGULARITY="/cvmfs/oasis.opensciencegrid.org/mis/singularity/bin/singularity"
0120
0121 else
0122 echo "ERROR: no apptainer or singularity found, please make sure you have apptainer or singularity in your \$PATH"
0123 exit 1
0124 fi
0125 fi
0126 echo " - Found apptainer/singularity at $SINGULARITY"
0127
0128
0129
0130
0131 SINGULARITY_VERSION=`$SINGULARITY --version`
0132 SIF=
0133 if [ ${SINGULARITY_VERSION:0:1} = 2 ]; then
0134 SIF="$PREFIX/local/lib/${CONTAINER}-${VERSION}.simg"
0135
0136 echo "WARNING: your singularity version $SINGULARITY_VERSION is ancient, we strongly recommend using version 3.x"
0137 echo "We will attempt to use a fall-back SIMG image to be used with this singularity version"
0138 if [ -f /gpfs02/eic/athena/${CONTAINER}-${VERSION}.simg ]; then
0139 ln -sf /gpfs02/eic/athena/${CONTAINER}-${VERSION}.simg ${SIF}
0140 else
0141 echo "Attempting last-resort singularity pull for old image"
0142 echo "This may take a few minutes..."
0143 INSIF=`basename ${SIF}`
0144 singularity pull --name "${INSIF}" docker://eicweb/$CONTAINER:$VERSION
0145 mv ${INSIF} $SIF
0146 chmod +x ${SIF}
0147 unset INSIF
0148 fi
0149
0150 else
0151
0152 SIF="$PREFIX/local/lib/${CONTAINER}-${VERSION}.sif"
0153 if [ -z "$DISABLE_CVMFS_USAGE" -a -d /cvmfs/singularity.opensciencegrid.org/${ORGANIZATION}/${CONTAINER}:${VERSION} ]; then
0154 SIF="$PREFIX/local/lib/${CONTAINER}-${VERSION}"
0155
0156 rm -rf ${SIF}
0157 ln -sf /cvmfs/singularity.opensciencegrid.org/${ORGANIZATION}/${CONTAINER}:${VERSION} ${SIF}
0158 elif [ -f /cvmfs/eic.opensciencegrid.org/singularity/athena/${CONTAINER}_v${VERSION}.sif ]; then
0159 ln -sf /cvmfs/eic.opensciencegrid.org/singularity/athena/${CONTAINER}_v${VERSION}.sif ${SIF}
0160 elif [ -f /gpfs02/cvmfst0/eic.opensciencegrid.org/singularity/athena/${CONTAINER}_v${VERSION}.sif ]; then
0161 ln -sf /gpfs02/cvmfst0/eic.opensciencegrid.org/singularity/athena/${CONTAINER}_v${VERSION}.sif ${SIF}
0162
0163 elif [ -f $PWD/.gitlab-ci/${CONTAINER}-${VERSION}.sif ]; then
0164 ln -sf $PWD/.gitlab-ci/${CONTAINER}-${VERSION}.sif ${SIF}
0165
0166 else
0167
0168
0169 tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
0170 pushd $tmp_dir
0171 wget https://eic.github.io/eic-shell/install.py
0172 chmod +x install.py
0173 ./install.py -f -c $CONTAINER -v $VERSION .
0174 INSIF=lib/`basename ${SIF}`
0175 mv $INSIF $SIF
0176 chmod +x ${SIF}
0177
0178 popd
0179 rm -rf $tmp_dir
0180 unset INSIF
0181 fi
0182 fi
0183
0184 echo $SIF
0185 ls $SIF 2>&1 > /dev/null && GOOD_SIF=1
0186 if [ -z "$SIF" -o -z "$GOOD_SIF" ]; then
0187 echo "ERROR: no singularity image found"
0188 exit 1
0189 else
0190 echo " - Deployed ${CONTAINER} image: $SIF"
0191 fi
0192
0193
0194
0195
0196 echo " - Determining additional bind paths"
0197 BINDPATH=$(echo ${SINGULARITY_BINDPATH},${APPTAINER_BINDPATH} | tr ',' '\n' | sort -u | tr '\n' ',' | sed 's/^,//;s/,$//')
0198 echo " --> system bindpath: $BINDPATH"
0199 PREFIX_ROOT="/$(realpath $PREFIX | cut -d "/" -f2)"
0200 for dir in /w /work /media /scratch /volatile /cache /cvmfs /gpfs /gpfs01 /gpfs02 $PREFIX_ROOT; do
0201
0202 if [[ ",$BINDPATH," == *,"$dir",* ]]; then
0203 continue
0204 fi
0205 if [ -d $dir ]; then
0206 echo " --> $dir"
0207 BINDPATH=${dir}${BINDPATH:+,$BINDPATH}
0208 fi
0209 done
0210
0211
0212
0213 cat << EOF > eic-shell
0214
0215
0216
0217 ORGANIZATION=$ORGANIZATION
0218 CONTAINER=$CONTAINER
0219 TMPDIR=$TMPDIR
0220 VERSION=$VERSION
0221 PREFIX=$PREFIX
0222 DISABLE_CVMFS_USAGE=${DISABLE_CVMFS_USAGE}
0223
0224 function print_the_help {
0225 echo "USAGE: ./eic-shell [OPTIONS] [ -- COMMAND ]"
0226 echo "OPTIONAL ARGUMENTS:"
0227 echo " -u,--upgrade Upgrade the container to the latest version"
0228 echo " -n,--no-cvmfs Disable check for local CVMFS when updating. (D: enabled)"
0229 echo " -o,--organization Organization (D: \$ORGANIZATION) (requires cvmfs)"
0230 echo " -c,--container Container family (D: \$CONTAINER) (requires cvmfs)"
0231 echo " -v,--version Version to install (D: \$VERSION) (requires cvmfs)"
0232 echo " -h,--help Print this message"
0233 echo ""
0234 echo " Start the eic-shell containerized software environment (Apptainer/Singularity version)."
0235 echo ""
0236 echo "ENVIRONMENT VARIABLES:"
0237 echo " SINGULARITY Path to the singularity executable (D: detected during installation)"
0238 echo " SINGULARITY_OPTIONS Additional options to pass to singularity exec (D: none)"
0239 echo ""
0240 echo "EXAMPLES: "
0241 echo " - Start an interactive shell: ./eic-shell"
0242 echo " - Upgrade the container: ./eic-shell --upgrade"
0243 echo " - Use different version: ./eic-shell --version \$(date +%y.%m).0-stable"
0244 echo " - Execute a single command: ./eic-shell -- <COMMAND>"
0245 echo " - Use custom singularity: SINGULARITY=/path/to/singularity ./eic-shell"
0246 echo " - Pass singularity options: SINGULARITY_OPTIONS='--nv' ./eic-shell"
0247 echo ""
0248 exit
0249 }
0250
0251 UPGRADE=
0252
0253 while [ \$
0254 key=\$1
0255 case \$key in
0256 -u|--upgrade)
0257 UPGRADE=1
0258 shift
0259 ;;
0260 -n|--no-cvmfs)
0261 DISABLE_CVMFS_USAGE=true
0262 shift
0263 ;;
0264 -c|--container)
0265 CONTAINER=\${2?Missing argument. Use --help for more info.}
0266 export SIF=/cvmfs/singularity.opensciencegrid.org/\${ORGANIZATION}/\${CONTAINER}:\${VERSION}
0267 shift
0268 shift
0269 ;;
0270 -v|--version)
0271 VERSION=\${2?Missing argument. Use --help for more info.}
0272 export SIF=/cvmfs/singularity.opensciencegrid.org/\${ORGANIZATION}/\${CONTAINER}:\${VERSION}
0273 shift
0274 shift
0275 ;;
0276 -h|--help)
0277 print_the_help
0278 exit 0
0279 ;;
0280 --)
0281 shift
0282 break
0283 ;;
0284 *)
0285 echo "ERROR: unknown argument: \$key"
0286 echo "use --help for more info"
0287 exit 1
0288 ;;
0289 esac
0290 done
0291
0292 if [ ! -z \${UPGRADE} ]; then
0293 echo "Upgrading eic-shell..."
0294 if [ -z "\$DISABLE_CVMFS_USAGE" -a -d /cvmfs/singularity.opensciencegrid.org/\${ORGANIZATION}/\${CONTAINER}:\${VERSION} ]; then
0295 echo ""
0296 echo "Note: You cannot manually update the container as you are using the CVMFS version."
0297 echo " The container will automatically update every 24 hours."
0298 echo " You can override this by setting the '--no-cvmfs' flag, which will"
0299 echo " instantiate a local version."
0300 echo " This is only recommended for expert usage."
0301 echo ""
0302 echo "This will only upgrade the eic-shell script itself."
0303 echo ""
0304 fi
0305 FLAGS="-p \${PREFIX} -v \${VERSION}"
0306 if [ ! -z \${TMPDIR} ]; then
0307 FLAGS="\${FLAGS} -t \${TMPDIR}"
0308 fi
0309 if [ ! -z \${DISABLE_CVMFS_USAGE} ]; then
0310 FLAGS="\${FLAGS} --no-cvmfs"
0311 fi
0312 curl -L https://github.com/eic/eic-shell/raw/main/install.sh \
0313 | bash -s -- \${FLAGS}
0314 echo "eic-shell upgrade sucessful"
0315 exit 0
0316 fi
0317
0318 export EIC_SHELL_PREFIX=$PREFIX/local
0319 export APPTAINER_BINDPATH=$BINDPATH
0320 export SINGULARITY_BINDPATH=$BINDPATH
0321 \${SINGULARITY:-$SINGULARITY} exec \${SINGULARITY_OPTIONS:-} \${SIF:-$SIF} eic-shell \$@
0322 EOF
0323
0324 chmod +x eic-shell
0325
0326 echo " - Created custom eic-shell excecutable"
0327 }
0328
0329 function install_docker() {
0330
0331 DOCKER=$(which docker)
0332 if [ -z ${DOCKER} ]; then
0333 echo "ERROR: no docker install found, docker is required for the docker-based install"
0334 fi
0335 echo " - Found docker at ${DOCKER}"
0336
0337 IMG=eicweb/${CONTAINER}:${VERSION}
0338 docker pull ${IMG}
0339 echo " - Deployed ${CONTAINER} image: ${IMG}"
0340
0341
0342
0343
0344 echo " - Determining mount paths"
0345 PREFIX_ROOT="/$(realpath $PREFIX | cut -d "/" -f2)"
0346 MOUNT=""
0347 echo " --> $PREFIX_ROOT"
0348 for dir in /Volumes /Users /tmp; do
0349
0350 if [[ ${MOUNT} =~ $(basename $dir) ]]; then
0351 continue
0352 fi
0353 if [ -d $dir ]; then
0354 echo " --> $dir"
0355 MOUNT="$MOUNT -v $dir:$dir"
0356 fi
0357 done
0358 echo " - Docker mount directive: '$MOUNT'"
0359 PLATFORM_FLAG=''
0360 if [ `uname -m` = 'arm64' ]; then
0361 PLATFORM_FLAG='--platform linux/amd64'
0362 echo " - Additional platform flag to run on arm64"
0363 fi
0364
0365
0366
0367 cat << EOF > eic-shell
0368
0369
0370
0371 CONTAINER=$CONTAINER
0372 TMPDIR=$TMPDIR
0373 VERSION=$VERSION
0374 PREFIX=$PREFIX
0375 DISABLE_CVMFS_USAGE=${DISABLE_CVMFS_USAGE}
0376
0377 function print_the_help {
0378 echo "USAGE: ./eic-shell [OPTIONS] [ -- COMMAND ]"
0379 echo "OPTIONAL ARGUMENTS:"
0380 echo " -u,--upgrade Upgrade the container to the latest version"
0381 echo " --noX Disable X11 forwarding on macOS"
0382 echo " -h,--help Print this message"
0383 echo ""
0384 echo " Start the eic-shell containerized software environment (Docker version)."
0385 echo ""
0386 echo "EXAMPLES: "
0387 echo " - Start an interactive shell: ./eic-shell"
0388 echo " - Upgrade the container: ./eic-shell --upgrade"
0389 echo " - Execute a single command: ./eic-shell -- <COMMAND>"
0390 echo ""
0391 exit
0392 }
0393
0394 UPGRADE=
0395 NOX=
0396 while [ \$
0397 key=\$1
0398 case \$key in
0399 -u|--upgrade)
0400 UPGRADE=1
0401 shift
0402 ;;
0403 --noX)
0404 NOX=1
0405 shift
0406 ;;
0407 -h|--help)
0408 print_the_help
0409 exit 0
0410 ;;
0411 --)
0412 shift
0413 break
0414 ;;
0415 *)
0416 echo "ERROR: unknown argument: \$key"
0417 echo "use --help for more info"
0418 exit 1
0419 ;;
0420 esac
0421 done
0422
0423 if [ x\${DISPLAY} == "x" ] ; then
0424 echo "No X11 display detected, disabling X11" >&2
0425 NOX=1
0426 fi
0427
0428 if [ ! -z \${UPGRADE} ]; then
0429 echo "Upgrading eic-shell..."
0430 docker pull $IMG || exit 1
0431 echo "eic-shell upgrade sucessful"
0432 exit 0
0433 fi
0434 EOF
0435
0436 if [ `uname -s` = 'Darwin' ]; then
0437 echo 'if [ ! ${NOX} ]; then' >> eic-shell
0438 echo ' nolisten=`defaults find nolisten_tcp | grep nolisten | head -n 1 | awk ' "'{print" '$3}'"'" '|cut -b 1 `' >> eic-shell
0439 echo ' [[ $nolisten -ne 0 ]] && echo "For X support: In XQuartz settings --> Security --> enable \"Allow connections from network clients\" and restart (should be only once)." >&2' >> eic-shell
0440
0441
0442 echo ' xhost +localhost >&2' >> eic-shell
0443 echo ' dispnum=`ps -e |grep Xquartz | grep listen | grep -v xinit |awk ' "'{print" '$5}'"'" '`' >> eic-shell
0444 echo ' XSTUFF="-e DISPLAY=host.docker.internal${dispnum} -v /tmp/.X11-unix:/tmp/.X11-unix"' >> eic-shell
0445 echo 'fi' >> eic-shell
0446 fi
0447
0448 echo 'STDIO=; [ -t 0 ] || STDIO=-i; [ -t 0 ] && [ -t 1 ] && STDIO=-it' >> eic-shell
0449
0450
0451 echo 'CMD=; case $# in 0) ;; 1) CMD=$1 ;; *) CMD=$(printf "%q " "$@") ;; esac' >> eic-shell
0452 echo "docker run $PLATFORM_FLAG \${DOCKER_OPTIONS:-} $MOUNT \$XSTUFF -w=$PWD \$STDIO --rm -e EIC_SHELL_PREFIX=$PREFIX/local $IMG eic-shell \${CMD:+\"\$CMD\"}" >> eic-shell
0453
0454 chmod +x eic-shell
0455 echo " - Created custom eic-shell excecutable"
0456 }
0457
0458
0459 OS=`uname -s`
0460 CPU=`uname -m`
0461 case ${OS} in
0462 Linux)
0463 echo " - Detected OS: Linux"
0464 echo " - Detected CPU: $CPU"
0465 if [ "$CPU" = "arm64" ]; then
0466 install_docker
0467 else
0468 install_singularity
0469 fi
0470 ;;
0471 Darwin)
0472 echo " - Detected OS: MacOS"
0473 echo " - Detected CPU: $CPU"
0474 install_docker
0475 ;;
0476 *)
0477 echo "ERROR: OS '${OS}' not currently supported"
0478 exit 1
0479 ;;
0480 esac
0481
0482 popd
0483 echo "Environment setup succesfull"
0484 echo "You can start the development environment by running './eic-shell'"