Skip to content

Instantly share code, notes, and snippets.

@agyemanjp
Last active April 30, 2023 10:51
Show Gist options
  • Save agyemanjp/72107cbf4c512a64b27c79588e07af38 to your computer and use it in GitHub Desktop.
Save agyemanjp/72107cbf4c512a64b27c79588e07af38 to your computer and use it in GitHub Desktop.
Initialize (or fix) CI Server for Hypothesize
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NOCOLOR='\033[0m'
sudo apt install -y swapspace build-essential
if [ ! -x "$(command -v git)" ]; then
# 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
git config http.postBuffer 524288000
echo -e "\n${GREEN}Installed $(git -v)${NOCOLOR}"
fi
if [ ! -x "$(command -v psql)" ]; then
# 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}"
fi
if [ ! -x "$(command -v R)" ]; then
# 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}"
fi
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')\""
if [ ! -x "$(command -v node)" ]; then
# Install Node 16.x and yarn
echo -e "\n${YELLOW}Installing Nodejs 16.x...${NOCOLOR}"
wget -O - https://deb.nodesource.com/setup_16.x | sudo bash -
sudo apt install nodejs -y
sudo npm install -g npm
sudo npm install -g yarn
# 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}"
fi
if [ ! -x "$(command -v pnpm)" ]; then
echo -e "\n${YELLOW}Installing pnpm${NOCOLOR}"
sudo npm install -g pnpm@latest
fi
if [ ! -x "$(command -v concurrently)" ]; then
echo -e "\n${YELLOW}Installing concurrently${NOCOLOR}"
sudo npm install -g concurrently
fi
if [ ! -x "$(command -v tsc)" ]; then
echo -e "\n${YELLOW}Installing typescript${NOCOLOR}"
sudo npm install -g typescript@4.8.3
fi
if [ ! -x "$(command -v ts-node)" ]; then
echo -e "\n${YELLOW}Installing ts-node${NOCOLOR}"
sudo npm install -g ts-node@8.10.2
fi
# if [ ! -x "$(command -v mocha)" ]; then
# echo -e "\n${YELLOW}Installing mocha${NOCOLOR}"
# sudo npm install -g mocha@10.2.0
# fi
# if [ ! -x "$(command -v del-cli)" ]; then
# echo -e "\n${YELLOW}Installing del-cli${NOCOLOR}"
# sudo npm install -g del-cli@1.1.0
# fi
# if [ ! -x "$(command -v cpy)" ]; then
# echo -e "\n${YELLOW}Installing cpy-cli${NOCOLOR}"
# sudo npm install -g cpy-cli@1.0.1
# fi
# if [ ! -x "$(command -v eslint)" ]; then
# echo -e "\n${YELLOW}Installing eslint${NOCOLOR}"
# sudo npm install -g eslint@7.3.1
# fi
if [ ! -x "$(command -v watch)" ]; then
echo -e "\n${YELLOW}Installing watch${NOCOLOR}"
sudo npm install -g watch@1.0.2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment