Created
August 27, 2016 19:04
-
-
Save JKobyP/178204760a6382ba595caa7cdcf2f6df to your computer and use it in GitHub Desktop.
A rough startup script for The Jolly Advisor - tested on a fresh ubuntu install, theoretically good for any debian system.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check arguments | |
if [ $# -eq 0 ]; then | |
echo Error: Please include your github username as an argument | |
exit | |
fi | |
# Check package manager | |
which apt-get 2> /dev/null | |
if [ "$?" != "0" ]; then | |
echo Error: non-debian systems are unsupported | |
exit 1 | |
fi | |
# Warning message | |
read -p "***** This script assumes that github.com/$1/the_jolly_advisor is a valid | |
repository - double check that before continuing. | |
This script will install Ruby (and ruby libraries), postgres, and | |
The Jolly Advisor onto your computer. It may take up to an hour. Are you sure | |
you want to proceed? [y/N] | |
" -r | |
echo | |
if [[ ! $REPLY =~ ^[Yy]$ ]] | |
then | |
exit 1 | |
fi | |
which git 2> /dev/null | |
if [ "$?" != "0" ]; then | |
sudo apt-get -y install git | |
fi | |
# The Jolly Advisor code | |
if [ -d "the_jolly_advisor" ]; then | |
echo "*****We've determined that you've already installed The Jolly Advisor in | |
the directory, so we're skipping that step." | |
else | |
echo *****Obtaining The Jolly Advisor source code... | |
git clone http://github.com/$1/the_jolly_advisor.git | |
fi | |
if [ "$?" != "0" ]; then | |
echo "Error: Problem cloning the jolly advisor - is there a valid fork under the | |
specified username?" | |
exit 1 | |
fi | |
cd the_jolly_advisor | |
echo | |
echo "*****Successfully obtained the jolly advisor." | |
# RVM and ruby | |
which rvm 2> /dev/null | |
if [ "$?" = "0" ]; then | |
set -e | |
echo "*****We've determined that you've already installed RVM, so we're skipping that step." | |
else | |
set -e | |
echo *****Installing RVM... | |
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 | |
\curl -sSL https://get.rvm.io | bash -s stable | |
source $HOME/.rvm/scripts/rvm | |
fi | |
echo | |
echo "*****Installing Ruby 2.3.0..." | |
rvm install ruby-2.3.0 | |
gem install bundler | |
# Postgres | |
echo | |
echo "*****Installing postgres..." | |
sudo apt-get -y install postgresql | |
echo | |
echo "*****Postgres has installed successfully. Please follow the steps below." | |
echo "Run \$ createuser --interactive" | |
echo "Follow the steps to create a privileged user, use your login | |
username." | |
echo "Run \$ createdb the_jolly_advisor_development; createdb the_jolly_advisor_test; exit" | |
sudo su - postgres | |
read -p "*****Did any errors occur while configuring postgres? [Y/n] " -r | |
if [[ ! $REPLY =~ ^[Nn]$ ]] | |
then | |
exit 1 | |
fi | |
# Bundle | |
## Sometimes the system will require libpq-dev to be installed first | |
echo | |
echo *****installing dependencies before bundling... | |
sudo apt-get install -y libpq-dev | |
echo | |
echo "*****Running bundle..." | |
bundle | |
# DB Migrations and rails | |
echo | |
echo "*****Migrating the DB and importing from SIS..." | |
rake db:migrate | |
rails r "require 'sis_importer';SISImporter.import_sis" | |
echo "*****The installer has completed successfully! | |
run \$ source $HOME/.rvm/scripts/rvm | |
and then start your local server with \$ rails s" |
line 101 has a rake task. I think it's rake import_sis
or something like that
Maybe allow users to specify a directory so it doesn't have to go to ~/the_jolly_advisor ?
Also, you should look into optparse
for specifying options
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure that
rvm install xxx
sets that as the active version right away, sogem
on the next line might not be the version thatrvm
just installed