-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoststart.sh
executable file
·62 lines (46 loc) · 1.86 KB
/
poststart.sh
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
#!/usr/bin/env bash
# copy example notebooks
TMP_NOTEBOOKS=/tmp/example-notebooks.zip
wget --quiet -O $TMP_NOTEBOOKS https://github.com/cellgeni/notebooks/archive/master.zip
unzip $TMP_NOTEBOOKS -d /tmp
rm /tmp/notebooks-master/.gitignore /tmp/notebooks-master/LICENSE /tmp/notebooks-master/README.md
cp -Rf /tmp/notebooks-master/. .
rm -rf $TMP_NOTEBOOKS /tmp/notebooks-master/
# copy default run commands but provide a way for users to keep their own config
if [ ! -f .keep-local-conf ]; then
# .condarc: set env_prompt, channels, envs_dirs,create_default_packages
cp /config/.condarc /home/jovyan/
# .Rprofile: set binary package repo
cp /config/.Rprofile /home/jovyan/
fi
# .bashrc: activate myenv by default
if [ ! -f .bashrc ]; then
echo 'source activate myenv' > .bashrc
else
grep -qF 'source activate myenv' .bashrc || echo 'source activate myenv' >> .bashrc
fi
# .bash_profile: make login shells source .bashrc
if [ ! -f .bash_profile ]; then
echo "source ~/.bashrc" > .bash_profile
else
grep -qF 'source ~/.bashrc' .bash_profile || echo 'source ~/.bashrc' >> .bash_profile
fi
# create default environment 'myenv'
if [ ! -d my-conda-envs/myenv ]; then
conda create --clone base --name myenv
source activate myenv
fi
Rscript -e 'dir.create(path = Sys.getenv("R_LIBS_USER"), showWarnings = FALSE, recursive = TRUE)'
Rscript -e '.libPaths( c( Sys.getenv("R_LIBS_USER"), .libPaths() ) )'
Rscript -e 'IRkernel::installspec()'
# create matching folders to mount the farm
if [ ! -d /nfs ] || [ ! -d /lustre ] || [ ! -d /warehouse ]; then
sudo mkdir -p /nfs
sudo mkdir -p /lustre
sudo mkdir -p /warehouse
fi
# set env vars for nbresuse limits
export MEM_LIMIT=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes)
CPU_NANOLIMIT=$(cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us)
export CPU_LIMIT=$(($CPU_NANOLIMIT/100000))
export USER=jovyan