Skip to content
Permalink
Newer
Older
100755 59 lines (48 sloc) 1.4 KB
Aug 15, 2016
1
#!/bin/bash
2
3
r_pkgs=( DESeq2 grDevices genefilter biomaRt ggplot2 gplots RColorBrewer )
4
pip_pkgs=( biopython )
5
6
if [[ $(id -u) -ne 0 ]]; then
7
echo "Error: run this script as the root user, not EUID $(id -u)."
8
exit 1
9
fi
10
11
set -e # Make most errors fatal.
12
13
ubuntu_update () {
14
apt-get update
15
apt-get -y upgrade
16
}
17
18
ubuntu_install_r_cran () {
19
cat <<EOF > /etc/apt/sources.list.d/cgi-r-cran.list
20
# Newest R version from CRAN per
21
# https://cran.r-project.org/bin/linux/ubuntu/
22
deb https://cran.fhcrc.org/bin/linux/ubuntu $(lsb_release -cs)/
23
EOF
24
local key=E084DAB9
25
grep -q $key <( apt-key list ) ||
26
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key
Aug 15, 2016
27
apt-get update
28
apt-get -y install r-base-dev
29
}
30
31
python_install_packages() {
32
apt-get -y install python-pip python-dev
Aug 15, 2016
33
pip install --upgrade ${pip_pkgs[@]}
34
}
35
36
r_install_packages() {
37
local pkgs=\"$(sprintf "\",%s\"" "${r_pkgs[@]}")\"
38
R --quiet -vanilla -e <<EOF
39
source("https://bioconductor.org/biocLite.R")
40
biocLite(c(${pkgs:3})
41
EOF
42
}
43
44
main () {
45
ubuntu_update
46
ubuntu_install_r_cran
47
48
python_install_packages
49
50
# Install R libraries in the user home directory so that updating
51
# the libraries later on does not triggering the "unwritable
52
# directory" warning.
53
export r_pkgs
54
export -f r_install packages
55
su cgi_user -c "bash -c r_install_packages"
56
unset r_pkgs r_install_packages
57
}
58
59
main
You can’t perform that action at this time.