# Follow the guide in the text file attached to install software required to develop a rails application on Ubuntu
set -e # terminate on error for shell script
# Installing MongoDB on Ubuntu
# The 10gen repository provides the mongo-10gen package, which contains the latest stable release.
# Import 10gen public GPG Key by issuing this command
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
# Create 10gen packages list using the following command.
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
# Add MariaDB Repository
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository "deb [arch=amd64] http://mirrors.bestthaihost.com/mariadb/repo/10.1/ubuntu "$(lsb_release -sc)" main"
# Make sure the system is up-to-date.
sudo apt-get update
sudo apt-get upgrade -y
# System restart may be required.
# add-apt-repository requires python-software-properties
sudo apt-get install -y python-software-properties
# Add Redis repository
sudo apt-add-repository -y ppa:chris-lea/redis-server
sudo apt-get update
# Installing Rails development workstation
sudo apt-get install -y aptitude autoconf automake bison build-essential curl firefox gawk git-core imagemagick libc6-dev libffi-dev libgdbm-dev libgmp10-dev libmagickcore-dev libmagickwand-dev libncurses5-dev libqt4-dev libqtwebkit-dev libreadline6 libreadline6-dev libruby libssl-dev libtool libxcb-render-util0 libxcb-xkb1 libxkbcommon-x11-0 libxml2-dev libxslt1-dev libyaml-dev ncurses-base openssh-server openssl screen subversion tcl8.5 vim-gnome wget xvfb zlib1g zlib1g-dev
# Install Atom Text Editor
wget -nv https://atom-installer.github.com/v1.10.2/atom-amd64.deb
sudo dpkg -i atom-amd64.deb
# Install Sublimetext
wget -nv https://download.sublimetext.com/sublime-text_build-3126_amd64.deb
sudo dpkg -i sublime-text_build-3126_amd64.deb
# Install a choice of database backend
sudo apt-get install -y mongodb-org redis-server libsqlite3-dev sqlite3
# sudo apt-get install -y mongodb-org
# sudo apt-get install -y redis-server
# sudo apt-get install -y libsqlite3-dev sqlite3
# Install MariaDB
echo "mariadb-server-10.1 mysql-server/root_password password \"\"" | sudo debconf-set-selections
echo "mariadb-server-10.1 mysql-server/root_password_again password \"\"" | sudo debconf-set-selections
sudo apt-get install -y libmariadbclient-dev mariadb-server mysql-workbench
# Install PostgreSQL
# sudo apt-get install -y postgresql postgresql-client libpq-dev
# sudo pg_createcluster 9.1 main --start
# sudo -u postgres createuser --superuser $USER
# psql -c "alter user $USER with password '$USER'"
# Install Ruby with RVM or skip to line 59 for native Ruby installation
# See http://rvm.io/rvm/install for rvm installation
# rvm install current stable (rvm should install the current Ruby stable for you)
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -L https://get.rvm.io | bash -s stable
# rvm assumes you're on Mac OS X so it puts commands in the .bash_profile instead of .bashrc. Do the following to append the command to .bashrc
echo "PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting" >> ~/.bashrc
echo "[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*" >> ~/.bashrc
# Load RVM or reset the Terminal
source ~/.bashrc
source ~/.rvm/scripts/rvm
rvm install 2.4.0
rvm use 2.4.0 --default
# We have the internet. We don't need to download all the documentations.
echo "install: --no-rdoc --no-ri" >> ~/.gemrc
echo "update: --no-rdoc --no-ri" >> ~/.gemrc
gem install bundler rails therubyracer
# Install Oracle Java for Solr
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
java -version
#====
# Native Ruby Installation
# cd ~
# curl -O http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz
# tar xzf ruby-2.1.2.tar.gz
# cd ruby-2.1.2
# ./configure
# make
# sudo make install
# install rubygems manually
# cd ~
# curl -O http://production.cf.rubygems.org/rubygems/rubygems-2.3.0.tgz
# tar xzf rubygems-2.3.0.tgz
# cd rubygems-2.3.0
# sudo ruby setup.rb
# We have the internet. We don't need to download all the documentations.
# echo "install: --no-rdoc --no-ri" >> ~/.gemrc
# echo "update: --no-rdoc --no-ri" >> ~/.gemrc
# sudo gem install bundler rails therubyracer
#====
# In any new Rails project, a JavaScript runtime needs to be installed.
# Add gem 'therubyracer' to Gemfile
# Install Jenkins if needed
# sudo apt-get install jenkins
# Phantomjs
# Download phantomjs from http://phantomjs.org/download.html
# wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2
# tar jxf phantomjs-1.9.7-linux-x86_64.tar.bz2
# sudo cp phantomjs-1.9.2-linux-x86_64/bin/phantomjs /usr/local/bin/
# phantomjs -v #should print the version number, 1.9.2
# Cleanup unused packages
sudo apt-get autoremove -y
sudo apt-get autoclean