Last active
September 6, 2021 09:49
-
-
Save JohnMount/3694b155d2d184d263e4e34c6ae4a943 to your computer and use it in GitHub Desktop.
Configure an Amazon EC2 instance to serve a tunneled RStudio Server instance (from a Unix client)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# on local | |
pempath="$1" | |
ec2target="$2" | |
ssh -T -i "${pempath}" -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@${ec2target} << 'EOBLOCK' | |
# on remote machine | |
sudo apt-get -y update | |
sudo apt-get -y upgrade | |
# https://www.digitalocean.com/community/tutorials/how-to-install-r-on-ubuntu-16-04-2 | |
sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/' | |
sudo apt-get update | |
sudo apt-get -y --allow-unauthenticated install r-base r-base-dev | |
sudo apt-get -y install default-jre default-jdk | |
sudo apt-get -y install gdebi postgresql postgresql-contrib pgadmin3 libpq-dev whois imagemagick | |
sudo apt-get -y install libmagick++-dev libcurl4-openssl-dev | |
sudo apt-get -y install qpdf texlive-latex-base texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra texinfo | |
sudo apt-get -y install emacs | |
wget https://download2.rstudio.org/rstudio-server-1.1.383-amd64.deb | |
sudo gdebi -n rstudio-server-1.1.383-amd64.deb | |
# wget https://download2.rstudio.org/rstudio-server-1.1.442-amd64.deb | |
# sudo gdebi -n rstudio-server-1.1.442-amd64.deb | |
sudo /bin/bash -c "echo 'www-address=127.0.0.1' >> /etc/rstudio/rserver.conf" | |
sudo rstudio-server restart | |
sudo useradd -m -p `mkpasswd -m sha-512 ruser` -s /bin/bash ruser | |
sudo cp -r ~/.ssh ~ruser/.ssh | |
sudo chown -R ruser ~ruser/.ssh | |
sudo -u postgres createuser --superuser ubuntu | |
sudo -u postgres createdb ubuntu | |
sudo -u postgres createuser ruser | |
sudo -u postgres createdb ruser | |
echo "ALTER USER ruser WITH PASSWORD 'ruser';" | sudo -u postgres psql | |
sudo R CMD javareconf | |
EOBLOCK | |
echo "SWITCHING TO TUNNEL MODE" | |
# on local | |
ssh -i "${pempath}" -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -N -L 8787:127.0.0.1:8787 ruser@${ec2target} | |
# visit http://127.0.0.1:8787 user ruser password ruser |
If the remote machine needs a grub update you need to.
- control-C out
- ssh into the machine my hand and run:
ssh ubuntu@MACHINENAME
sudo dpkg --configure -a
sudo apt-get -y upgrade
sudo reboot now
# say yes to any interactive prompts- I leave the GUB "as is" - try the script again
Do you happen to have a similar recipe for building a docker image? Trying to adjust your script was not very successful :(
Sorry, I haven't been working on a project that works this way. Perhaps this project has what you want: https://github.com/rocker-org/rocker-paper
Thanks for the pointer. I have been looking at the Rocker's direction, but so far with no success...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes on how to use the script here.
This configuration includes, R, RStudio Server, Java, PostgreSQL, ImageMagic, and Latex.