Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
## =============================================================================
## Setup (if needed) and start a development shell environment on Linux or MacOS
## =============================================================================
## make sure we launch this script from the project root directory
PROJECT_ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/..
pushd ${PROJECT_ROOT}
## We do not load the global development environment here, as this script is
## to be executed on a "naked" system outside of any container
## =============================================================================
## Step 1: Parse command line options
## do we want to force-update the container (only affects Linux)
## default: we do not want to do this.
FORCE_UPDATE=
function print_the_help {
echo "USAGE: ./util/start_dev_shell [-f]"
echo "OPTIONS:"
echo " -f,--force Force-update container (Only affects Linux)"
echo " -h,--help Print this message"
echo ""
echo " This script will setup and launch a containerized development
environment"
exit
}
while [ $# -gt 0 ]
do
key="$1"
case $key in
-f|--force)
FORCE_UPDATE="true"
shift # past value
;;
-h|--help)
print_the_help
shift
;;
*) # unknown option
echo "unknown option $1"
exit 1
;;
esac
done
## get OS type
OS=`uname -s`
## =============================================================================
## Step 2: Update container and launch shell
echo "Launching a containerized development shell"
case ${OS} in
Linux)
echo " - Detected OS: Linux"
## Use the same prefix as we use for other local packages
export PREFIX=.local/lib
if [ ! -f $PREFIX/juggler_latest.sif ] || [ ! -z ${FORCE_UPDATE} ]; then
echo " - Fetching singularity image"
mkdir -p $PREFIX
wget https://eicweb.phy.anl.gov/eic/juggler/-/jobs/artifacts/master/raw/build/juggler.sif?job=singularity:latest -O $PREFIX/juggler_latest.sif
fi
echo " - Using singularity to launch shell..."
singularity exec $PREFIX/juggler_latest.sif eic-shell
;;
Darwin)
echo " - Detector OS: MacOS"
echo " - Syncing docker container"
docker pull sly2j/juggler:latest
echo " - Using docker to launch shell..."
docker run -v /Users:/Users -w=$PWD -i -t --rm sly2j/juggler:latest eic-shell
;;
*)
echo "ERROR: dev shell not available for this OS (${OS})"
exit 1
esac
## =============================================================================
## Step 3: All done
echo "Exiting development environment..."