Skip to content

Instantly share code, notes, and snippets.

@david-hammond
david-hammond / postgres_ubuntu.sh
Last active May 20, 2021 03:47
base database server setup
#!/bin/bash
sudo apt update
sudo apt upgrade -y
sudo apt install postgresql postgresql-contrib -y
#To allow database to be accessed remotely follow this https://linuxize.com/post/how-to-install-postgresql-on-ubuntu-18-04/
#you need to edit the follwoing 2 files using vim - the most difficult part, vim instructions here https://vim.rtorr.com/
#sudo vim /etc/postgresql/10/main/postgresql.conf
sudo sed -i s/"#listen_addresses = 'localhost'"/"listen_addresses = '*' "/g /etc/postgresql/12/main/postgresql.conf
#sudo vim /etc/postgresql/10/main/pg_hba.conf
sudo sed -i '96s@127.0.0.1/32@0.0.0.0/0@' /etc/postgresql/12/main/pg_hba.conf
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.6
Comment: Hostname: keyserver.ubuntu.com
mQENBEy9tcUBCACnWQfqdrcz7tQL/iCeWDYSYPwXpPMUMLE721HfFH7d8ErunPKPIwq1v4Cr
NmMjcainofbu/BfuZESSK1hBAItOk/5VTkzCJlzkrHY9g5v+XlBMPDQC9u4AE/myw3p52+0N
XsnBz+a35mxJKMl+9v9ztvueA6EmLr2xaLf/nx4XwXUMSi1Lp8i8XpAOz/Xg1fspPMRhuDAG
YDnOh4uH1jADGoqYaPMty0yVEmzx74qvdIOvfgj16A/9LYXk67td6/JQ5LFCZmFsbahAsqi9
inNgBZmnfXO4m4lhzeqNjJAgaw7Fz2zqUmvpEheKKClgTQMWWNI9Rx1L8IKnJkuKnpzHABEB
AAG0I01pY2hhZWwgUnV0dGVyIDxtYXJ1dHRlckBnbWFpbC5jb20+iQE+BBMBAgAoAhsjBgsJ
#!/bin/bash
sudo apt upgrade -y
sudo apt install postgresql postgresql-contrib -y
sudo apt install vim -y
#To allow database to be accessed remotely follow this https://linuxize.com/post/how-to-install-postgresql-on-ubuntu-18-04/
#you need to edit the follwoing 2 files using vim - the most difficult part, vim instructions here https://vim.rtorr.com/
#sudo vim /etc/postgresql/10/main/postgresql.conf
sudo sed -i s/"#listen_addresses = 'localhost'"/"listen_addresses = '*' "/g /etc/postgresql/10/main/postgresql.conf
#sudo vim /etc/postgresql/10/main/pg_hba.conf
sudo sed -i '92s@127.0.0.1/32@0.0.0.0/0@' /etc/postgresql/10/main/pg_hba.conf
sudo su - -c "R -e \"install.packages('devtools', repos='http://cran.rstudio.com/')\""
sudo su - -c "R -e \"install.packages('tidyverse', repos='http://cran.rstudio.com/')\""
sudo su - -c "R -e \"install.packages('pacman', repos='http://cran.rstudio.com/')\""
sudo su - -c "R -e \"install.packages('ProjectTemplate', repos='http://cran.rstudio.com/')\""
sudo su - -c "R -e \"install.packages('rio', repos='http://cran.rstudio.com/')\""
@david-hammond
david-hammond / daveserver.sh
Last active February 13, 2018 01:59
Reproducible server
# after installing centos7 Compute Machine option
sudo yum install epel-release -y
sudo yum update -y
sudo yum install net-tools -y
sudo shutdown -r now
sudo yum install R -y
sudo yum install wget -y
wget https://download2.rstudio.org/rstudio-server-rhel-1.1.419-x86_64.rpm
sudo yum install rstudio-server-rhel-1.1.419-x86_64.rpm -y
sudo systemctl status rstudio-server.service
sudo yum install epel-release
sudo yum update
sudo shutdown -r now
sudo yum install R -y
cd
wget https://download2.rstudio.org/rstudio-server-rhel-1.0.136-x86_64.rpm
sudo yum install --nogpgcheck rstudio-server-rhel-1.0.136-x86_64.rpm -y
sudo systemctl status rstudio-server.service
sudo systemctl enable rstudio-server.service
sudo firewall-cmd --permanent --zone=public --add-port=8787/tcp
@david-hammond
david-hammond / RstudioServerSetup.sh
Created January 30, 2018 01:00 — forked from kdkorthauer/RstudioServerSetup.sh
Bash script to set up R, install a few R packages, and get Rstudio Server running on ubuntu.
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list'
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install r-base libapparmor1 libcurl4-gnutls-dev libxml2-dev libssl-dev gdebi-core
sudo apt-get install libcairo2-dev
sudo apt-get install libxt-dev
sudo apt-get install git-core
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
@david-hammond
david-hammond / ipak.R
Last active January 26, 2018 05:50 — forked from stevenworthington/ipak.R
Install and load multiple R packages at once
# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
@david-hammond
david-hammond / .Rbuildignore
Created July 24, 2017 23:08 — forked from dsparks/Hmisc_bezier.R
Economics-style graphs
^.*\.Rproj$
^\.Rproj\.user$