-
Notifications
You must be signed in to change notification settings - Fork 5
/
bioconductor
executable file
·98 lines (75 loc) · 2.54 KB
/
bioconductor
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
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
## version is RELEASE_X_Y
version=$1
## either rstudio or bash
envtype=$2
## defaults to 8787
port=$3
GVER=`echo "$version" | grep -E "^[3-4]\.[0-9]{1,2}.*"`
if [ -z "${version// }" ] || [[ $version != RELEASE_* ]] && ([[ $version != devel* ]] && [ -z "${GVER// }" ]); then
echo "Enter either 'devel*', 'X.Y', or 'RELEASE_X_Y' version"
exit 1
fi
if [ -z "${envtype// }" ]; then
echo "Empty 'envtype' using default: rstudio"
envtype="rstudio"
elif [ $envtype == "shell" ]; then
envtype="bash"
fi
if [[ $envtype != "rstudio" && $envtype != "bash" ]]; then
echo "Enter either 'rstudio' or 'bash' environment type"
exit 2
fi
if [ -z "${port// }" ]; then
port=8787
fi
biocdocker=bioconductor/bioconductor_docker:"$version"
docker pull $biocdocker
DOCKER_RPKGS="$HOME/.docker-$version-packages"
DOCKER_HOME="$HOME/dockerhome"
R_LIBS='/usr/local/lib/R/host-site-library:/usr/local/lib/R/site-library:/usr/local/lib/R/library'
mkdir -p "$DOCKER_RPKGS"
mkdir -p "$DOCKER_HOME"
if [ ! -f "$DOCKER_HOME"/.Renviron ]; then
echo "R_LIBS=$R_LIBS" > $DOCKER_HOME/.Renviron
fi
TOKEN_EXP='GITHUB_[P|T].*'
GPAT=`grep "$TOKEN_EXP" ~/.Renviron`
GRENV=`grep "$TOKEN_EXP" $DOCKER_HOME/.Renviron`
if [ ! -z "${GPAT// }" ] && [ -z "${GRENV// }" ]; then
echo $GPAT >> $DOCKER_HOME/.Renviron
fi
HLIBUSER=`grep "R_LIBS_USER" ~/.Renviron`
if [ -z "${HLIBENV// }" ]; then
echo "R_LIBS_USER=/usr/local/lib/R/host-site-library" >> $DOCKER_HOME/.Renviron
fi
copy_config() {
for arg in "$@"; do
FILE="$HOME/$arg"
if [ -e ${FILE} ] && [ ! -e $DOCKER_HOME/$arg ]; then
cat $FILE > $DOCKER_HOME/$arg
fi
done
}
copy_config .Rprofile .gitconfig .inputrc
echo "Installed packages will go in host directory: $DOCKER_RPKGS"
echo "RStudio home directory will be mounted on host directory: $DOCKER_HOME"
echo $envtype
if [ $envtype == "rstudio" ]; then
echo "Open RStudio running Bioconductor version $version at http://localhost:$port"
fi
if [ $envtype == "rstudio" ]; then
docker run -e PASSWORD=bioc \
-v $DOCKER_HOME:/home/rstudio \
-v $DOCKER_RPKGS:/usr/local/lib/R/host-site-library \
-e USERID=$UID \
-p $port:8787 \
$biocdocker \
bash -c 'chown -R rstudio /home/rstudio; chown -R rstudio /usr/local/lib/R/host-site-library; /init'
elif [ $envtype == "bash" ]; then
docker run -ti --user rstudio \
-v $DOCKER_HOME:/home/rstudio \
-v $DOCKER_RPKGS:/usr/local/lib/R/host-site-library \
-w /home/rstudio \
$biocdocker bash
fi