Last active
August 29, 2015 14:01
-
-
Save yamishi13/b2e48ecc192a78ebc960 to your computer and use it in GitHub Desktop.
ruboto_env_installer
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 | |
environment="server" | |
java=1 | |
# parse arguments for environment settings | |
while [ $# -gt 0 ] ; do | |
case $1 in | |
-e | --environment) environment=$2 ; shift 2 ;; | |
-n | --no-java) java=0 ; shift 1 ;; | |
*) echo "$1 is an unrecognized argument" ; shift 1 ;; | |
esac | |
done | |
# verify environment value | |
if [ "$environment" == "server" ] ; then | |
echo "using bash_profile file" | |
environment=".bash_profile" | |
elif [ "$environment" == "desktop" ] ; then | |
echo "using bashrc file" | |
environment=".bashrc" | |
else | |
echo "Unvalid environment value, using server as default value" >> /dev/stderr | |
environment="server" | |
fi | |
# check it's not being run as root or sudo | |
if [ $EUID -eq 0 ] ; then | |
echo "Even tough this script uses sudo it should not be run as root." >> /dev/stderr | |
exit 1 | |
fi | |
# update references | |
sudo apt-get update | |
# install some basic packages | |
sudo apt-get install vim git python-software-properties build-essential -y | |
# install oracle java 7 jdk if it's not already installed | |
if [ $java -eq 1 ] ; then | |
if ! hash java 2>/dev/null ; then | |
sudo add-apt-repository ppa:webupd8team/java -y | |
sudo apt-get update | |
echo debconf shared/accepted-oracle-license-v1-1 select true | \ | |
sudo debconf-set-selections | |
echo debconf shared/accepted-oracle-license-v1-1 seen true | \ | |
sudo debconf-set-selections | |
while ! hash java 2>/dev/null ; do | |
sudo apt-get install oracle-java7-installer -y | |
done | |
fi | |
fi | |
# install rbenv and jruby 1.7.12 if not installed already and select jruby as global ruby installation | |
if ! hash rbenv 2>/dev/null ; then | |
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv | |
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/$environment | |
echo 'eval "$(rbenv init -)"' >> ~/$environment | |
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build | |
rbenv rehash | |
rbenv install jruby-1.7.12 | |
rbenv rehash | |
fi | |
# install ruboto | |
gem install ruboto | |
# test ruboto setup | |
ruboto setup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment