-
Notifications
You must be signed in to change notification settings - Fork 5
/
install_rbenv.sh
executable file
·77 lines (51 loc) · 2.36 KB
/
install_rbenv.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
SCRIPT_NAME=$(basename $BASH_SOURCE)
SCRIPT_LOGFILE="./logs/"$(basename -s .sh $BASH_SOURCE)".log"
SCRIPT_ENVFILE="./logs/"$(basename -s .sh $BASH_SOURCE)".env"
mkdir -p ./logs && chmod 755 ./logs
echo "running "$SCRIPT_NAME
# tested: works on ubuntu 14.04.3 gnome
if grep -Fxq '# installed by ubuntu-desktop-post-install/install_rbenv.sh #' ~/.bashrc
then
echo " rbenv already installed"
else
# https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-14-04
echo " installing dependencies"
sudo apt-get -y install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev >> $SCRIPT_LOGFILE
echo " cloning rbenv"
cd
rm -rf .rbenv
git clone -q git://github.com/sstephenson/rbenv.git .rbenv
git clone -q git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo "gem: --no-document" > ~/.gemrc
echo '' >> ~/.bashrc
echo '#' >> ~/.bashrc
echo '# rbenv' >> ~/.bashrc
echo '#' >> ~/.bashrc
echo '# installed by ubuntu-desktop-post-install/install_rbenv.sh #' >> ~/.bashrc
echo '#' >> ~/.bashrc
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
echo '' >> ~/.bashrc
# update env file, so the parent shell can update its env too
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> $SCRIPT_ENVFILE
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> $SCRIPT_ENVFILE
echo " !!! PLEASE LOGOUT AND LOGIN AGAIN AFTER INSTALLATION FINISHES"
echo " run 'rbenv install -v 2.2.2' to install ruby"
echo " run 'rbenv global 2.2.2' to set 2.2.2 as default global ruby version"
#echo " installing ruby 2.2.2 (will take few minutes)"
#exec bash -c "rbenv install -v 2.2.2 &> /dev/null; rbenv global 2.2.2 &> /dev/null; rbenv rehash &> /dev/null"
# @example: install ror and bundler
# gem install bundler && rbenv rehash;
# gem install rails && rbenv rehash;
# @example: install new ruby version
# rbenv install -v X.X.X
# @example: create rails app
# cd ~/Desktop
# nvm use 0.12.7 # you have to specify what node version to use in current shell instance
# rails new testapp
# cd testapp
# rake db:create
# rails server
fi