Skip to content

Instantly share code, notes, and snippets.

@AzamatJumabekov
Last active December 9, 2016 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AzamatJumabekov/9d7157f4dbedc54d7434b83137c0e53e to your computer and use it in GitHub Desktop.
Save AzamatJumabekov/9d7157f4dbedc54d7434b83137c0e53e to your computer and use it in GitHub Desktop.
Beelibrary project's production environment setup
#!/bin/bash
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo /bin/sh -c 'echo /swapfile none swap sw 0 0 >> /etc/fstab'
free -m
echo "======================================="
echo "===========Added 2GB Swapfile=========="
echo "======================================="
adduser deploy
sudo echo "deploy ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers
echo "======================================="
echo "============added new user============="
echo "======================================="
apt-get -y update
apt-get -y upgrade
apt install -y git nodejs curl
echo "======================================="
echo "=======installed git nodejs curl======="
echo "======================================="
sudo apt-get -y install imagemagick
echo "======================================="
echo "=========installed imagemagick========="
echo "======================================="
sudo apt-get -y install nginx
sudo rm /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
sudo service nginx restart
echo "======================================="
echo "===========installed nginx============="
echo "======================================="
sudo apt-get -y install default-jre
echo "======================================="
echo "=============installed java============"
echo "======================================="
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.0.0.deb
sudo dpkg -i elasticsearch-5.0.0.deb
echo "======================================="
echo "========installed elasticsearch========"
echo "======================================="
sleep 2
sudo service elasticsearch start
sudo apt-get install -y postgresql postgresql-contrib
sudo apt-get install -y libpq-dev
echo "======================================="
echo "=========installed postgresql=========="
echo "======================================="
runuser -l deploy -c "curl -sSL https://rvm.io/mpapis.asc | gpg --import -"
runuser -l deploy -c "\curl -sSL https://get.rvm.io | bash -s stable"
runuser -l deploy -c "rvm install 2.3.0"
runuser -l deploy -c "rvm use 2.3.0 --default"
echo "======================================="
echo "=====installed rvm, installed ruby====="
echo "======================================="
runuser -l deploy -c "gem install bundler"
echo "======================================="
echo "=========installed gem bundler========="
echo "======================================="
runuser -l deploy -c "sudo -u postgres createuser --interactive"
runuser -l deploy -c "createdb deploy"
runuser -l deploy -c "createdb beelibrary_production"
cd /home/deploy
runuser -l deploy -c "wget https://raw.githubusercontent.com/puma/puma/master/tools/jungle/upstart/puma-manager.conf"
runuser -l deploy -c "wget https://raw.githubusercontent.com/puma/puma/master/tools/jungle/upstart/puma.conf"
runuser -l deploy -c "ssh-keygen"
echo "START>>"
runuser -l deploy -c "cat ~/.ssh/id_rsa.pub"
echo "<<END"
echo
echo "Add this key to 'Deploy keys' on https://github.com/user-name/project-name/settings/keys"
echo
echo "Now edit puma.conf and puma-manager.conf, change setuid, setgid to deploy"
echo "To copy them run 'sudo cp puma.conf puma-manager.conf /etc/init' from deploy user"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment