1#!/usr/bin/env bash 2 3# amend MOTD 4echo "Load balanced: /etc/rstudio/load-balancer" >> /etc/motd 5 6# set up cluster node config file 7cp /rstudio/vagrant/load-balancer /etc/rstudio/load-balancer 8 9# create secure cookie key (keep dev copy accessible) 10apt-get install -y uuid 11echo `uuid` > /rstudio/vagrant/secure-cookie-key 12chown vagrant /rstudio/vagrant/secure-cookie-key 13cp /rstudio/vagrant/secure-cookie-key /etc/rstudio/secure-cookie-key 14chmod 0600 /etc/rstudio/secure-cookie-key 15 16# configure primary machine for load balancing 17ssh -i /rstudio/vagrant/vagrant_key_rsa -o StrictHostKeyChecking=no vagrant@192.168.55.101 "sudo /rstudio/vagrant/provision-primary-load.sh" 18 19# attach to NFS client 20/rstudio/vagrant/provision-nfs-client.sh 21 22# add users; use NFS home directories 23apt-get install -y whois 24for userdetails in `cat /rstudio/vagrant/rstudiousers.txt` 25do 26 user=`echo $userdetails | cut -f 1 -d ,` 27 passwd=`echo $userdetails | cut -f 2 -d ,` 28 useradd --base-dir /primary/home -p `mkpasswd $passwd` $user 29done 30 31# configure shared storage 32echo "server-shared-storage-path=/primary/home/shared-storage" >> /etc/rstudio/rserver.conf 33 34# TODO Should we route /vagrant's home dir via NFS, too? Needed if we want to 35# be able to have load-balanced sessions as the vagrant user. 36 37# perform remainder of the install script as regular user 38sudo --login --set-home -u vagrant /rstudio/vagrant/provision-balancer-user.sh 39 40