Skip to content

Instantly share code, notes, and snippets.

@agyemanjp
Last active April 30, 2023 10:48
Show Gist options
  • Save agyemanjp/2ad5696714645bb1323ab5bf8fe006c8 to your computer and use it in GitHub Desktop.
Save agyemanjp/2ad5696714645bb1323ab5bf8fe006c8 to your computer and use it in GitHub Desktop.
cd ~/ && wget -O hypothesize.sh http://bit.ly/3KlasQ7 && chmod +x hypothesize.sh && ./hypothesize.sh
#!/usr/bin/env bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NOCOLOR='\033[0m'
# Install useful base packages
echo -e "\n${YELLOW}Installing base packages ...${NOCOLOR}"
sudo apt update
sudo apt install -y build-essential
echo -e "\n${GREEN}Done${NOCOLOR}"
# Install & configure Git 2.40.0
echo -e "\n${YELLOW}Installing git ...${NOCOLOR}"
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt update
sudo apt install -y git=1:2.40.0-0ppa1~ubuntu18.04.1
git config --global credential.helper "cache --timeout 1800"
sudo git config --global core.filemode false
echo -e "\n${GREEN}Installed $(git -v)${NOCOLOR}"
# Install Node 16.x and related package managers: yarn and pnpm
echo -e "\n${YELLOW}Installing nodejs ...${NOCOLOR}"
wget -O - https://deb.nodesource.com/setup_16.x | sudo bash -
sudo apt install nodejs -y
sudo npm install -g npm yarn pnpm npm-run-all
sudo chown -R $(whoami) ~/.npm
sudo sh -c 'echo NODE_OPTIONS="--max_old_space_size=1536" >> /etc/environment'
echo -e "\n${GREEN}Installed Node $(node -v)${NOCOLOR}"
# Install and configure Postgres
echo -e "\n${YELLOW}Installing Postgres ...${NOCOLOR}"
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt update
sudo apt install -y libpq-dev postgresql postgresql-contrib
sudo -u postgres psql -c "CREATE USER $(whoami) WITH PASSWORD '$(whoami)'"
sudo -u postgres psql -c "ALTER USER $(whoami) WITH SUPERUSER"
createdb $(whoami)
echo -e "\n${GREEN}Installed$(psql --pset pager=off -t -c "select version()")${NOCOLOR}"
# Install and configure R version 4.1.3
echo -e "\n${YELLOW}Installing R ...${NOCOLOR}"
sudo apt install -y gdebi-core libjpeg-dev libpng-dev
export R_VERSION=4.1.3
wget https://cdn.rstudio.com/r/ubuntu-1804/pkgs/r-${R_VERSION}_1_amd64.deb
sudo gdebi --non-interactive r-${R_VERSION}_1_amd64.deb
rm -rf r-${R_VERSION}_1_amd64.deb
sudo ln -s /opt/R/${R_VERSION}/bin/R /usr/local/bin/R
sudo ln -s /opt/R/${R_VERSION}/bin/Rscript /usr/local/bin/Rscript
sudo chown -R $(whoami) /opt/R/${R_VERSION}/lib/R/
sudo usermod -a -G staff $(whoami)
echo -e "\n${GREEN}Installed $(Rscript -e 'cat(R.version.string,"\n")')${NOCOLOR}"
echo -e "\n${YELLOW}Installing base R packages ...${NOCOLOR}"
Rscript -e 'install.packages("pak", repos=sprintf("https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch))'
sudo su - -c "R -e \"install.packages('jsonlite', repos='https://cran.rstudio.com')\""
echo -e "\n${YELLOW}Disabling unattended upgrades and performing cleanup ...${NOCOLOR}"
sudo apt remove unattended-upgrades -y
sudo apt autoremove -y
sudo apt autoclean -y
echo -e "\n${GREEN}Done${NOCOLOR}"
# Install swapspace to enable memory swapping
echo -e "\n${YELLOW}Installng swapspace to enable memory swapping ...${NOCOLOR}"
sudo apt install -y swapspace
echo -e "\n${GREEN}Done${NOCOLOR}"
# echo -e "\n${YELLOW}Installations successful${NOCOLOR}"
read -p "Installations and configurations successful. Press enter to reboot"
sudo reboot now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment