Skip to content
Snippets Groups Projects
Commit 1ac4e740 authored by Wouter Deconinck's avatar Wouter Deconinck
Browse files

feat: rm content now in github.com/eic/eic-shell

parent 58e7cdc6
No related branches found
No related tags found
1 merge request!407feat: rm content now in github.com/eic/eic-shell
EIC software container
============================================
Simple Installation
------------
*The environment has been tested on linux (requires singularity v3+) and MacOS (requires
docker)*
Please follow the steps below to setup and run the container in your environment.
1. Create a local directory that you want to work in, e.g `$HOME/eic`, and go into this
directory.
```bash
mkdir $HOME/eic
cd $HOME/eic
```
2. Execute the following line in your terminal to setup your environment in this directory
to install the latest stable container
```bash
curl https://eicweb.phy.anl.gov/containers/eic_container/-/raw/master/install.sh | bash
```
3. You can now load your development environment by executing the `eic-shell` script that
is in your top-level working directory.
```bash
eic-shell
```
4. Within your development environment (`eic-shell`), you can install software to the
internal `$EIC_SHELL_PREFIX`
Singularity Container setup for Development Usage
-------------
**Note: this container download script is meant for expert usage. If it is unclear to you
why you would want to do this, you are probably looking for the simple `jug_xl` installation
above.**
You can use the same install scripts to setup other container setups, including `jug_dev`
(the main development container). Note that for `jug_dev` there is no nighlty release, and
the appropriate version (tag) would be `testing`. To setup the `jug_dev:testing` environment, do
```bash
curl https://eicweb.phy.anl.gov/containers/eic_container/-/raw/master/install.sh | bash -s -- -c jug_dev -v testing
```
Included software:
------------------
- Included software (for the exact versions, check the file [spack.yaml](spack.yaml) or use the command `eic-info` inside the container):
- gcc
- madx
- cmake
- fmt cxxstd=17
- spdlog
- nlohmann-json
- heppdt
- clhep cxxstd=17
- eigen
- python
- py-numpy
- py-pip
- pkg-config
- xrootd cxxstd=17 +python
- root cxxstd=17
+fftw +fortran +gdml +http +mlp +pythia8
+root7 +tmva +vc +xrootd +ssl
^mesa swr=none +opengl -llvm -osmesa
- pythia8 +fastjet
- fastjet
- hepmc3 +python +rootio
- stow
- cairo +fc+ft+X+pdf+gobject
- podio
- geant4 cxxstd=17 +opengl +vecgeom +x11 +qt +threads ^qt +opengl
- dd4hep +geant4 +assimp +hepmc3 +ipo +lcio
- acts +dd4hep +digitization +identification +json +tgeo +ipo +examples +fatras +geant4
- genfit
- gaudi
- dawn
- dawncut
- opencascade
- emacs toolkit=athena
- imagemagick
- igprof
- The singularity build exports the following applications:
- eic-shell: a development shell in the image
Using the docker container for your CI purposes
-----------------------------------------------
**These instructions are old and need updating. In general we recommend using
`eicweb/juggler:latest` for most CI usages. This image is functionally identical to
`jug_xl:nightly`**
The docker containers are publicly accessible from
[Dockerhub](https://hub.docker.com/u/eicweb). You probably want to use the default
`jug_xl` container. Relevant versions are:
- `eicweb/jug_xl:nightly`: nightly release, with latest detector and reconstruction
version. This is probably what you want to use unless you are dispatching a large
simulation/reconstruciton job
- `eicweb/jug_xl:3.0-stable`: latest stable release, what you want to use for large
simulation jobs (for reproducibility). Please coordinate with the software group to
ensure all desired software changes are present in this container.
1. To load the container environment in your run scripts, you have to do nothing special.
The environment is already setup with good defaults, so you can use all the programs
in the container as usual and assume everything needed to run the included software
is already setup.
2. If using this container as a basis for a new container, you can direction access
the full container environment from a docker `RUN` shell command with no further
action needed. For the most optimal experience, you can install your software to
`/usr/local` to fully integrate with the existing environment. (Note that, internally,
`/usr/local` is a symlink to `/opt/view`).
EIC software environment container
==================================
For installation instructions of `eic-shell`, see https://github.com/eic/eic-shell.
#!/bin/bash
CONTAINER="jug_dev"
VERSION="testing"
ODIR="$PWD"
function print_the_help {
echo "USAGE: ./download_dev.sh [-o DIR] [-v VERSION]"
echo "OPTIONAL ARGUMENTS:"
echo " -o,--outdir Directory to download the container to (D: $ODIR)"
echo " -c,--container Container to download (D: $CONTAINER)"
echo " -v,--version Version to download (D: $VERSION)"
echo " -h,--help Print this message"
echo ""
echo " Download development container into an output directory"
echo ""
echo "EXAMPLE: ./download_dev.sh"
exit
}
echo "WARNING: this container download script is meant for expert usage"
echo " if you don't know what this script does, you are probably"
echo " looking for install.sh"
while [ $# -gt 0 ]; do
key=$1
case $key in
-o|--outdir)
ODIR=$2
shift
shift
;;
-c|--container)
CONTAINER=$2
shift
shift
;;
-v|--version)
VERSION=$2
shift
shift
;;
-h|--help)
print_the_help
exit 0
;;
*)
echo "ERROR: unknown argument: $key"
echo "use --help for more info"
exit 1
;;
esac
done
mkdir -p $ODIR || exit 1
if [ ! -d $ODIR ]; then
echo "ERROR: not a valid directory: $ODIR"
echo "use --help for more info"
exit 1
fi
echo "Deploying development container for eicweb/$CONTAINER:$VERSION to $ODIR"
## Simple setup script that installs the container
## in your local environment under $ODIR/local/lib
## and creates a simple top-level launcher script
## that launches the container for this working directory
## with the $ATHENA_ODIR variable pointing
## to the $ODIR/local directory
mkdir -p local/lib || exit 1
## Always deploy the SIF image using the python installer,
## as this is for experts only anyway
SIF=
## work in temp directory
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
pushd $tmp_dir
wget https://eicweb.phy.anl.gov/containers/eic_container/-/raw/master/install.py
chmod +x install.py
./install.py -f -c $CONTAINER -v $VERSION .
SIF=lib/$CONTAINER-$VERSION.sif
chmod +x ${SIF}
## That's all
if [ -z $SIF -o ! -f $SIF ]; then
echo "ERROR: no singularity image found"
else
echo "Container download succesfull"
fi
## move over the container to our output directory
mv $SIF $ODIR
## cleanup
popd
rm -rf $tmp_dir
#!/usr/bin/env python3
## eic_container: Argonne Universal EIC Container
'''
Deploy the singularity container built by the CI for this version of the software.
The current version is determined from the currently loaded git branch or tag,
unless it is explicitly set on the command line.
Authors:
- Whitney Armstrong <warmstrong@anl.gov>
- Sylvester Joosten <sjoosten@anl.gov>
'''
import os
import argparse
import re
import urllib.request
## Gitlab group and project/program name.
DEFAULT_IMG='jug_xl'
DEFAULT_VERSION='3.0.1'
SHORTCUTS = ['eic-shell']
## URL for the current container (git tag will be filled in by the script)
## components:
## - {ref}:
## - branch/tag --> git branch or tag
## - MR XX --> refs/merge-requests/XX/head
## - nightly --> just use fallback singularity pull
## - {img}: image name
## - {job}: the CI job that built the artifact
CONTAINER_URL = r'https://eicweb.phy.anl.gov/api/v4/projects/290/jobs/artifacts/{ref}/raw/build/{img}.sif?job={job}'
## Docker ref is used as fallback in case regular artifact download fails
## The components are:
## - {img}: image name
## - {tag}: docker tag associated with image
## - master --> testing
## - branch/tag --> branch/tag without leading v
## - MR XX --> unstable (may be incorrect if multiple MRs active)
## - nightly --> nightly
DOCKER_REF = r'docker://eicweb/{img}:{tag}'
## Singularity bind directive
BIND_DIRECTIVE= '-B {0}:{0}'
class UnknownVersionError(Exception):
pass
class ContainerDownloadError(Exception):
pass
class InvalidArgumentError(Exception):
pass
def smart_mkdir(dir):
'''functions as mkdir -p, with a write-check.
Raises an exception if the directory is not writeable.
'''
if not os.path.exists(dir):
try:
os.makedirs(dir)
except Exception as e:
print('ERROR: unable to create directory', dir)
raise e
if not os.access(dir, os.W_OK):
print('ERROR: We do not have the write privileges to', dir)
raise InvalidArgumentError()
## generic launcher bash script to launch the application
_LAUNCHER='''#!/usr/bin/env bash
## Boilerplate to make pipes work
piped_args=
if [ -p /dev/stdin ]; then
# If we want to read the input line by line
while IFS= read line; do
if [ -z "$piped_args" ]; then
piped_args="${{line}}"
else
piped_args="${{piped_args}}\n${{line}}"
fi
done
fi
## Fire off the application wrapper
if [ ${{piped_args}} ] ; then
echo -e ${{piped_args}} | singularity exec {bind} {container} {exe} $@
else
singularity exec {bind} {container} {exe} $@
fi
'''
def _write_script(path, content):
print(' - creating', path)
with open(path, 'w') as file:
file.write(content)
os.system('chmod +x {}'.format(path))
def make_launcher(app, container, bindir,
bind='', exe=None):
'''Configure and install a launcher.
Generic launcher script to launch applications in this container.
The launcher script calls the desired executable from the singularity image.
As the new images have the environment properly setup, we can accomplish this
without using any wrapper scripts.
Arguments:
- app: our application
- container: absolute path to container
- bindir: absolute launcher install path
Optional:
- bind: singularity bind directives
- exe: executable to be associated with app.
Default is app.
- env: environment directives to be added to the wrapper.
Multiline string. Default is nothing
'''
if not exe:
exe = app
## paths
launcher_path = '{}/{}'.format(bindir, app)
## scripts --> use absolute path for wrapper path inside launcher
launcher = _LAUNCHER.format(container=container,
bind=bind,
exe=exe)
## write our scripts
_write_script(launcher_path, launcher)
## Generic module file
_MODULEFILE='''#%Module1.0#####################################################################
##
## for {name} {version}
##
proc ModulesHelp {{ }} {{
puts stderr "This module sets up the environment for the {name} container"
}}
module-whatis "{name} {version}"
# For Tcl script use only
set version 4.1.4
prepend-path PATH {bindir}
'''
def make_modulefile(project, version, moduledir, bindir):
'''Configure and install a modulefile for this project.
Arguments:
- project: project name
- version: project version
- moduledir: root modulefile directory
- bindir: where executables for this project are located
'''
## create our modulefile
content = _MODULEFILE.format(name=project, version=version, bindir=bindir)
fname = '{}/{}'.format(moduledir, version)
print(' - creating', fname)
with open(fname, 'w') as file:
file.write(content)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
'prefix',
help='Install prefix. This is where the container will be deployed.')
parser.add_argument(
'-c', '--container',
dest='container',
default=DEFAULT_IMG,
help='(opt.) Container to install. '
'D: {} (also available: jug_dev, and legacy "eic" container).')
parser.add_argument(
'-v', '--version',
dest='version',
# default=project_version(),
default=DEFAULT_VERSION,
help='(opt.) project version. '
'D: {}. For MRs, use mr-XXX.'.format(DEFAULT_VERSION))
parser.add_argument(
'-f', '--force',
action='store_true',
help='Force-overwrite already downloaded container',
default=False)
parser.add_argument(
'-b', '--bind-path',
dest='bind_paths',
action='append',
help='(opt.) extra bind paths for singularity.')
parser.add_argument(
'-m', '--module-path',
dest='module_path',
help='(opt.) Root module path to install a modulefile. '
'D: Do not install a modulefile')
args = parser.parse_args()
print('Deploying', args.container, 'version', args.version)
## Check if our bind paths are valid
bind_directive = ''
if args.bind_paths and len(args.bind_paths):
print('Singularity bind paths:')
for path in args.bind_paths:
print(' -', path)
if not os.path.exists(path):
print('ERROR: path', path, 'does not exist.')
raise InvalidArgumentError()
bind_directive = ' '.join([BIND_DIRECTIVE.format(path) for path in args.bind_paths])
## Naming schemes:
## We need to deduce both the correct git branch and an appropriate
## local version number from the desired version number
## by default we use whatever version number is given in VERSION, but we want
## to allow users to specify either X.Y.Z or vX.Y.Z for versions (same for stable
## branches).
##
## Policy:
## numbered releases: (v)X.Y.Z --> git vX.Y.Z and local X.Y.Z
## stable branches: (v)X.Y-stable --> git vX.Y-stable and local X.Y-stable
## master branch: latest/master --> git master and local stable
## for other branches --> git <BRANCH> and local unstable
version_docker = None
version_gitlab = None
build_job = '{}:singularity:default'.format(args.container)
## firs look for spacialty containers
if args.container == 'acts_material_scan':
version_docker = args.version
version_gitlab = 'acts-material-scan' #dashes, not underscores
elif args.version in ('master', 'testing'):
version_docker = 'testing'
version_gitlab = 'master'
elif re.search('[0-9]+\.[0-9]', args.version) is not None:
suffix='-stable'
if re.search('{}$'.format(suffix), args.version):
suffix=''
version_docker = args.version + suffix
version_gitlab = args.version + suffix
if version_docker[0] == 'v':
version_docker = version_docker[1:]
if version_gitlab[0].isdigit():
version_gitlab = 'v{}'.format(version_gitlab)
elif args.version[:3] == 'mr-':
version_docker = 'unstable'
version_gitlab = 'refs/merge-requests/{}/head'.format(args.version[3:])
elif args.version == 'nightly':
version_docker = 'nightly'
version_gitlab = 'master'
build_job = '{}:singularity:nightly'.format(args.container)
else:
## fixme add proper error handling
print('Unknown requested version:', args.version)
raise UnknownVersionError()
## 'master' is always docker-tagged as testing
if version_docker == 'master':
version_docker = testing
## when working with the old container, the build job is just 'singularity'
if args.container == 'eic':
build_job = 'singularity'
## Create our install prefix if needed and ensure it is writable
args.prefix = os.path.abspath(args.prefix)
if not args.module_path:
deploy_local=True
else:
deploy_local=False
print('Install prefix:', args.prefix)
print('Creating install prefix if needed...')
bindir = '{}/bin'.format(args.prefix)
libdir = '{}/lib'.format(args.prefix)
libexecdir = '{}/libexec'.format(args.prefix)
root_prefix = os.path.abspath('{}/..'.format(args.prefix))
dirs = [bindir, libdir, libexecdir]
if not deploy_local:
moduledir = '{}/{}'.format(args.module_path, args.container)
dirs.append(moduledir)
for dir in dirs:
print(' -', dir)
smart_mkdir(dir)
## At this point we know we can write to our desired prefix and that we have a set of
## valid bind paths
## Get the container
## We want to slightly modify our version specifier: if it leads with a 'v' drop the v
img = args.container
## Builder SIF is not built anymore, deprecated
#if args.builder:
#img += "_builder"
container = '{}/{}-{}.sif'.format(libdir, img, version_docker)
if not os.path.exists(container) or args.force:
url = CONTAINER_URL.format(ref=version_gitlab, img=img, job=build_job)
print('Downloading container from:', url)
print('Destination:', container)
try:
urllib.request.urlretrieve(url, container)
except:
print('WARNING: failed to retrieve container artifact')
print('Attempting alternative download from docker registry')
cmd = ['singularity pull', '--force', container, DOCKER_REF.format(img=img, tag=version_docker)]
cmd = ' '.join(cmd)
print('Executing:', cmd)
err = os.system(cmd)
if err:
raise ContainerDownloadError()
else:
print('WARNING: Container found at', container)
print(' ---> run with -f to force a re-download')
if not deploy_local:
make_modulefile(args.container, version_docker, moduledir, bindir)
## configure the application launchers
print('Configuring applications launchers: ')
for prog in SHORTCUTS:
app = prog
exe = prog
if type(prog) == tuple:
app = prog[0]
exe = prog[1]
make_launcher(app, container, bindir,
bind=bind_directive,
exe=exe)
print('Container deployment successful!')
#!/bin/bash
## Simple setup script that installs the container
## in your local environment under $PREFIX/local/lib
## and creates a simple top-level launcher script
## that launches the container for this working directory
## with the $EIC_SHELL_PREFIX variable pointing
## to the $PREFIX/local directory
CONTAINER="jug_xl"
VERSION="nightly"
PREFIX="$PWD"
function print_the_help {
echo "USAGE: ./install.sh [-p PREFIX] [-v VERSION]"
echo "OPTIONAL ARGUMENTS:"
echo " -p,--prefix Working directory to deploy the environment (D: $PREFIX)"
echo " -t,--tmpdir Change tmp directory (D: $([[ -z "$TMPDIR" ]] && echo "/tmp" || echo "$TMPDIR"))"
echo " -n,--no-cvmfs Disable check for local CVMFS (D: enabled)"
echo " -c,--container Container version (D: $CONTAINER)"
echo " -v,--version Version to install (D: $VERSION)"
echo " -h,--help Print this message"
echo ""
echo " Set up containerized development environment."
echo ""
echo "EXAMPLE: ./install.sh"
exit
}
while [ $# -gt 0 ]; do
key=$1
case $key in
-p|--prefix)
PREFIX=$(realpath $2)
shift
shift
;;
-t|--tmpdir)
export TMPDIR=$2
export SINGULARITY_TMPDIR=$2
shift
shift
;;
-n|--no-cvmfs)
DISABLE_CVMFS_USAGE=true
shift
;;
-c|--container)
CONTAINER=$2
shift
shift
;;
-v|--version)
VERSION=$2
shift
shift
;;
-h|--help)
print_the_help
exit 0
;;
*)
echo "ERROR: unknown argument: $key"
echo "use --help for more info"
exit 1
;;
esac
done
## create prefix if needed
mkdir -p $PREFIX || exit 1
pushd $PREFIX
if [ ! -d $PREFIX ]; then
echo "ERROR: not a valid directory: $PREFIX"
echo "use --help for more info"
exit 1
fi
echo "Setting up development environment for eicweb/$CONTAINER:$VERSION"
mkdir -p $PREFIX/local/lib || exit 1
function install_singularity() {
SINGULARITY=
## check for a singularity install
## default singularity if new enough
if [ $(type -P singularity ) ]; then
SINGULARITY=$(which singularity)
SINGULARITY_VERSION=`$SINGULARITY --version`
if [ ${SINGULARITY_VERSION:0:1} = 2 ]; then
## too old, look for something else
SINGULARITY=
fi
fi
if [ -z $SINGULARITY ]; then
## first priority: a known good install (this one is on JLAB)
if [ -d "/apps/singularity/3.7.1/bin/" ]; then
SINGULARITY="/apps/singularity/3.7.1/bin/singularity"
## whatever is in the path is next
elif [ $(type -P singularity ) ]; then
SINGULARITY=$(which singularity)
## cvmfs singularity is last resort (sandbox mode can cause issues)
elif [ -f "/cvmfs/oasis.opensciencegrid.org/mis/singularity/bin/singularity" ]; then
SINGULARITY="/cvmfs/oasis.opensciencegrid.org/mis/singularity/bin/singularity"
## not good...
else
echo "ERROR: no singularity found, please make sure you have singularity in your \$PATH"
exit 1
fi
fi
echo " - Found singularity at $SINGULARITY"
## get singularity version
## we only care if is 2.x or not, so we can use singularity --version
## which returns 2.xxxxx for version 2
SINGULARITY_VERSION=`$SINGULARITY --version`
SIF=
if [ ${SINGULARITY_VERSION:0:1} = 2 ]; then
SIF="$PREFIX/local/lib/${CONTAINER}-${VERSION}.simg"
echo "WARNING: your singularity version $SINGULARITY_VERSION is ancient, we strongly recommend using version 3.x"
echo "We will attempt to use a fall-back SIMG image to be used with this singularity version"
if [ -f /gpfs02/eic/athena/${CONTAINER}-${VERSION}.simg ]; then
ln -sf /gpfs02/eic/athena/${CONTAINER}-${VERSION}.simg ${SIF}
else
echo "Attempting last-resort singularity pull for old image"
echo "This may take a few minutes..."
INSIF=`basename ${SIF}`
singularity pull --name "${INSIF}" docker://eicweb/$CONTAINER:$VERSION
mv ${INSIF} $SIF
chmod +x ${SIF}
unset INSIF
fi
## we are in sane territory, yay!
else
## check if we can just use cvmfs for the image
SIF="$PREFIX/local/lib/${CONTAINER}-${VERSION}.sif"
if [ -z "$DISABLE_CVMFS_USAGE" -a -d /cvmfs/singularity.opensciencegrid.org/eicweb/${CONTAINER}:${VERSION} ]; then
SIF="$PREFIX/local/lib/${CONTAINER}-${VERSION}"
## need to cleanup in this case, else it will try to make a subdirectory
rm -rf ${SIF}
ln -sf /cvmfs/singularity.opensciencegrid.org/eicweb/${CONTAINER}:${VERSION} ${SIF}
elif [ -f /cvmfs/eic.opensciencegrid.org/singularity/athena/${CONTAINER}_v${VERSION}.sif ]; then
ln -sf /cvmfs/eic.opensciencegrid.org/singularity/athena/${CONTAINER}_v${VERSION}.sif ${SIF}
elif [ -f /gpfs02/cvmfst0/eic.opensciencegrid.org/singularity/athena/${CONTAINER}_v${VERSION}.sif ]; then
ln -sf /gpfs02/cvmfst0/eic.opensciencegrid.org/singularity/athena/${CONTAINER}_v${VERSION}.sif ${SIF}
## check if we have an internal CI image we will use for testing purposes
elif [ -f $PWD/.gitlab-ci/${CONTAINER}-${VERSION}.sif ]; then
ln -sf $PWD/.gitlab-ci/${CONTAINER}-${VERSION}.sif ${SIF}
## if not, download the container to the system
else
## get the python installer and run the old-style install
## work in temp directory
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
pushd $tmp_dir
wget https://eicweb.phy.anl.gov/containers/eic_container/-/raw/master/install.py
chmod +x install.py
./install.py -f -c $CONTAINER -v $VERSION .
INSIF=lib/`basename ${SIF}`
mv $INSIF $SIF
chmod +x ${SIF}
## cleanup
popd
rm -rf $tmp_dir
unset INSIF
fi
fi
echo $SIF
ls $SIF 2>&1 > /dev/null && GOOD_SIF=1
if [ -z "$SIF" -o -z "$GOOD_SIF" ]; then
echo "ERROR: no singularity image found"
exit 1
else
echo " - Deployed ${CONTAINER} image: $SIF"
fi
## We want to make sure the root directory of the install directory
## is always bound. We also check for the existence of a few standard
## locations (/scratch /volatile /cache) and bind those too if found
echo " - Determining additional bind paths"
BINDPATH=${SINGULARITY_BINDPATH}
echo " --> system bindpath: $BINDPATH"
PREFIX_ROOT="/$(realpath $PREFIX | cut -d "/" -f2)"
for dir in /w /work /scratch /volatile /cache /gpfs /gpfs01 /gpfs02 $PREFIX_ROOT; do
## only add directories once
if [[ ${BINDPATH} =~ $(basename $dir) ]]; then
continue
fi
if [ -d $dir ]; then
echo " --> $dir"
BINDPATH=${dir}${BINDPATH:+,$BINDPATH}
fi
done
## create a new top-level eic-shell launcher script
## that sets the EIC_SHELL_PREFIX and then starts singularity
cat << EOF > eic-shell
#!/bin/bash
## capture environment setup for upgrades
CONTAINER=$CONTAINER
TMPDIR=$TMPDIR
VERSION=$VERSION
PREFIX=$PREFIX
DISABLE_CVMFS_USAGE=${DISABLE_CVMFS_USAGE}
function print_the_help {
echo "USAGE: ./eic-shell [OPTIONS] [ -- COMMAND ]"
echo "OPTIONAL ARGUMENTS:"
echo " -u,--upgrade Upgrade the container to the latest version"
echo " -n,--no-cvmfs Disable check for local CVMFS when updating. (D: enabled)"
echo " -h,--help Print this message"
echo ""
echo " Start the eic-shell containerized software environment (Singularity version)."
echo ""
echo "EXAMPLES: "
echo " - Start an interactive shell: ./eic-shell"
echo " - Upgrade the container: ./eic-shell --upgrade"
echo " - Execute a single command: ./eic-shell -- <COMMAND>"
echo ""
exit
}
UPGRADE=
while [ \$# -gt 0 ]; do
key=\$1
case \$key in
-u|--upgrade)
UPGRADE=1
shift
;;
-n|--no-cvmfs)
DISABLE_CVMFS_USAGE=true
shift
;;
-h|--help)
print_the_help
exit 0
;;
--)
shift
break
;;
*)
echo "ERROR: unknown argument: \$key"
echo "use --help for more info"
exit 1
;;
esac
done
if [ ! -z \${UPGRADE} ]; then
echo "Upgrading eic-shell..."
if [ -z "\$DISABLE_CVMFS_USAGE" -a -d /cvmfs/singularity.opensciencegrid.org/eicweb/\${CONTAINER}:\${VERSION} ]; then
echo ""
echo "Note: You cannot manually update the container as you are using the CVMFS version."
echo " The container will automatically update every 24 hours."
echo " You can override this by setting the '--no-cvmfs' flag, which will"
echo " instantiate a local version."
echo " This is only recommended for expert usage."
echo ""
echo "Exiting without upgrade"
exit 0
fi
FLAGS="-p \${PREFIX} -v \${VERSION}"
if [ ! -z \${TMPDIR} ]; then
FLAGS="\${FLAGS} -t \${TMPDIR}"
fi
if [ ! -z \${DISABLE_CVMFS_USAGE} ]; then
FLAGS="\${FLAGS} --no-cvmfs"
fi
curl https://eicweb.phy.anl.gov/containers/eic_container/-/raw/master/install.sh \
| bash -s -- \${FLAGS}
echo "eic-shell upgrade sucessful"
exit 0
fi
export EIC_SHELL_PREFIX=$PREFIX/local
export SINGULARITY_BINDPATH=$BINDPATH
\${SINGULARITY:-$SINGULARITY} exec \${SINGULARITY_OPTIONS:-} \${SIF:-$SIF} eic-shell \$@
EOF
chmod +x eic-shell
echo " - Created custom eic-shell excecutable"
}
function install_docker() {
## check for docker install
DOCKER=$(which docker)
if [ -z ${DOCKER} ]; then
echo "ERROR: no docker install found, docker is required for the docker-based install"
fi
echo " - Found docker at ${DOCKER}"
IMG=eicweb/${CONTAINER}:${VERSION}
docker pull ${IMG}
echo " - Deployed ${CONTAINER} image: ${IMG}"
## We want to make sure the root directory of the install directory
## is always bound. We also check for the existence of a few standard
## locations (/Volumes /Users /tmp) and bind those too if found
echo " - Determining mount paths"
PREFIX_ROOT="/$(realpath $PREFIX | cut -d "/" -f2)"
MOUNT=""
echo " --> $PREFIX_ROOT"
for dir in /Volumes /Users /tmp; do
## only add directories once
if [[ ${MOUNT} =~ $(basename $dir) ]]; then
continue
fi
if [ -d $dir ]; then
echo " --> $dir"
MOUNT="$MOUNT -v $dir:$dir"
fi
done
echo " - Docker mount directive: '$MOUNT'"
PLATFORM_FLAG=''
if [ `uname -m` = 'arm64' ]; then
PLATFORM_FLAG='--platform linux/amd64'
echo " - Additional platform flag to run on arm64"
fi
## create a new top-level eic-shell launcher script
## that sets the EIC_SHELL_PREFIX and then starts singularity
cat << EOF > eic-shell
#!/bin/bash
## capture environment setup for upgrades
CONTAINER=$CONTAINER
TMPDIR=$TMPDIR
VERSION=$VERSION
PREFIX=$PREFIX
DISABLE_CVMFS_USAGE=${DISABLE_CVMFS_USAGE}
function print_the_help {
echo "USAGE: ./eic-shell [OPTIONS] [ -- COMMAND ]"
echo "OPTIONAL ARGUMENTS:"
echo " -u,--upgrade Upgrade the container to the latest version"
echo " -h,--help Print this message"
echo ""
echo " Start the eic-shell containerized software environment (Docker version)."
echo ""
echo "EXAMPLES: "
echo " - Start an interactive shell: ./eic-shell"
echo " - Upgrade the container: ./eic-shell --upgrade"
echo " - Execute a single command: ./eic-shell -- <COMMAND>"
echo ""
exit
}
UPGRADE=
while [ \$# -gt 0 ]; do
key=\$1
case \$key in
-u|--upgrade)
UPGRADE=1
shift
;;
-h|--help)
print_the_help
exit 0
;;
--)
shift
break
;;
*)
echo "ERROR: unknown argument: \$key"
echo "use --help for more info"
exit 1
;;
esac
done
if [ ! -z \${UPGRADE} ]; then
echo "Upgrading eic-shell..."
docker pull $IMG || exit 1
echo "eic-shell upgrade sucessful"
exit 0
fi
docker run $PLATFORM_FLAG $MOUNT -w=$PWD -it --rm -e EIC_SHELL_PREFIX=$PREFIX/local $IMG eic-shell \$@
EOF
chmod +x eic-shell
echo " - Created custom eic-shell excecutable"
}
## detect OS
OS=`uname -s`
CPU=`uname -m`
case ${OS} in
Linux)
echo " - Detected OS: Linux"
echo " - Detected CPU: $CPU"
if [ "$CPU" = "arm64" ]; then
install_docker
else
install_singularity
fi
;;
Darwin)
echo " - Detected OS: MacOS"
echo " - Detected CPU: $CPU"
install_docker
;;
*)
echo "ERROR: OS '${OS}' not currently supported"
exit 1
;;
esac
popd
echo "Environment setup succesfull"
echo "You can start the development environment by running './eic-shell'"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment