Skip to content
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
  2. +56 −0
@@ -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

# 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:
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:

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

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

local$ sudo service ssh restart

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

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`:

remote$ clush -l root id -u
remote$ clush -l root --copy --dest /root/
remote$ clush -l root ./
@@ -0,0 +1,56 @@

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

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
deb $(lsb_release -cs)/
apt-key adv --keyserver --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

main () {


# 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


0 comments on commit 4244d93

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