Skip to content
Permalink
Browse files

ENH: Initial commit

  • Loading branch information
pan14001 committed Aug 15, 2016
0 parents commit 4244d9353ceaa9d186c892b28a3eb369c56b1658
Showing with 130 additions and 0 deletions.
  1. +74 −0 README.md
  2. +56 −0 cgi-updater-payload.sh
@@ -0,0 +1,74 @@
## Update CGI computers remotely

Updates Ubuntu 14.04 computers with latest version of R, RStudio, R
libraries, Python and BioPython, for bioinformatics training.


### Remote computer requirements:

- ClusterShell
- ssh key authentication for all 10 laptops
- Wired connection (wireless in the building is flaky)

### Usage

Setup your `/etc/hosts` and map the target laptops as e.g. cgi01,
cgi02, etc. The Ubuntu machines don't have openssh-server installed
on them, so install it, copy the keys, and then disable password
authentication.

``sh
# On the laptops
local$ sudo apt-get update && sudo apt-get -y install openssh-server
local$ sudo sed -i 's/#Pass.*/PasswordAuthentication no/' /etc/ssh/sshd_config
Then create an ssh keys and copy it over:
```sh
remote$ idf=~/.ssh/id_rsa-cgi-202
remote$ ssh-keygen -f $idf -N ""
remote$ for host in cgi{01..10}; do ssh-copy-id -i $idf cgi_user@$host; done
```

Add the identity file to your `~/.ssh/config`

```
Host cgi*
IdentityFile ~/.ssh/id_rsa-cgi-202
User cgi_user
```

Test that the keys work with:

```sh
remote$ alias clush="clush -B -w cgi[01-10]"
remote$ type clush # verify alias
remote$ clush id -u
1000
```

On each computer, locally restart SSH server for the disabled password
authentication to take effect.

```sh
local$ sudo service ssh restart
```

Running sudo remotely is a pain, so use the same key for remote root
access.

```sh
local$ sudo mkdir -p /root/.ssh
local$ sudo sh -c "echo $(tail -1 ~/.ssh/authorized_keys) >> /root/.ssh/authorized_keys"
local$ sudo cat /root/.ssh/authorized_keys
```

In the present configuration, commands are normally executed as
cgi_user. To execute as root, use the `-l root` option of `clush`:

```sh
remote$ clush -l root id -u
0
remote$ clush -l root --copy cgi-updater-payload.sh --dest /root/
remote$ clush -l root ./cgi-updater-payload.sh
```
@@ -0,0 +1,56 @@
#!/bin/bash

r_pkgs=( DESeq2 grDevices genefilter biomaRt ggplot2 gplots RColorBrewer )
pip_pkgs=( biopython )

if [[ $(id -u) -ne 0 ]]; then
echo "Error: run this script as the root user, not EUID $(id -u)."
exit 1
fi

set -e # Make most errors fatal.

ubuntu_update () {
apt-get update
apt-get -y upgrade
}

ubuntu_install_r_cran () {
cat <<EOF > /etc/apt/sources.list.d/cgi-r-cran.list
# Newest R version from CRAN per
# https://cran.r-project.org/bin/linux/ubuntu/
deb https://cran.fhcrc.org/bin/linux/ubuntu $(lsb_release -cs)/
EOF
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
apt-get update
apt-get -y install r-base-dev
}

python_install_packages() {
pip install --upgrade ${pip_pkgs[@]}
}

r_install_packages() {
local pkgs=\"$(sprintf "\",%s\"" "${r_pkgs[@]}")\"
R --quiet -vanilla -e <<EOF
source("https://bioconductor.org/biocLite.R")
biocLite(c(${pkgs:3})
EOF
}

main () {
ubuntu_update
ubuntu_install_r_cran

python_install_packages

# Install R libraries in the user home directory so that updating
# the libraries later on does not triggering the "unwritable
# directory" warning.
export r_pkgs
export -f r_install packages
su cgi_user -c "bash -c r_install_packages"
unset r_pkgs r_install_packages
}

main

0 comments on commit 4244d93

Please sign in to comment.
You can’t perform that action at this time.