Skip to content

Instantly share code, notes, and snippets.

@CHTJonas
Last active September 26, 2020 21:41
Show Gist options
  • Save CHTJonas/3084714c3c310b7b8ec29c7cb6ba1225 to your computer and use it in GitHub Desktop.
Save CHTJonas/3084714c3c310b7b8ec29c7cb6ba1225 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script should be run as root"
exit 1
fi
# Install system utilities to make our lives easier
apt install -y mosh byobu wget curl htop nano vim
apt install -y software-properties-common apt-transport-https
apt install -y git make zip unzip pigz zstd binutils moreutils rename rsync
apt install -y dnsutils net-tools traceroute mtr-tiny whois pv netcat-openbsd socat
# Install build dependencies
apt install -y build-essential libssl-dev libreadline-dev zlib1g-dev libyaml-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev libffi-dev
# Install Ruby
mkdir -p /opt/embedded
git clone https://github.com/rbenv/ruby-build.git /tmp/ruby-build
PREFIX=/opt/embedded/ruby-build /tmp/ruby-build/install.sh
/opt/embedded/ruby-build/bin/ruby-build 2.6.6 /opt/embedded/ruby
rm -rf /tmp/ruby-build
# Install NodeJS
curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
echo "deb https://deb.nodesource.com/node_12.x stretch main" | tee /etc/apt/sources.list.d/nodesource.list
apt update && apt install -y nodejs
# Install YARN
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt update && apt install -y yarn
# Install Postgres
echo "deb https://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list
curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt update && apt install -y postgresql-common postgresql-13 libpq-dev
# Install Redis from source
mkdir /tmp/redis && cd /tmp/redis
wget https://download.redis.io/redis-stable.tar.gz
tar -xzvf redis-stable.tar.gz
cd redis-stable/
make
make install
utils/install_server.sh
cd && rm -rf /tmp/redis
# Create a user account with which to run the application
useradd -r -d /home/roombooking -m -s /usr/sbin/nologin roombooking
sudo -u postgres createuser roombooking -s
# Install application code
cd /opt/
git clone https://github.com/CHTJonas/roombooking.git
chown -R roombooking:roombooking roombooking/
cd roombooking/
sudo -Hu roombooking touch .prod
sudo -Hu roombooking bundle install --deployment --without development test
sudo -Hu roombooking bin/install
sudo -Hu roombooking procodile start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment