From 4244d9353ceaa9d186c892b28a3eb369c56b1658 Mon Sep 17 00:00:00 2001 From: Pariksheet Nanda Date: Mon, 15 Aug 2016 14:45:42 -0400 Subject: [PATCH] ENH: Initial commit --- README.md | 74 ++++++++++++++++++++++++++++++++++++++++++ cgi-updater-payload.sh | 56 ++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 README.md create mode 100755 cgi-updater-payload.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..8fdce39 --- /dev/null +++ b/README.md @@ -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 +``` diff --git a/cgi-updater-payload.sh b/cgi-updater-payload.sh new file mode 100755 index 0000000..757aae5 --- /dev/null +++ b/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 < /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 <