-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
upgrade_ruby.sh
executable file
·42 lines (34 loc) · 997 Bytes
/
upgrade_ruby.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
#!/bin/bash --login
# USE THIS SCRIPT WHEN UPGRADING RUBY
if [[ -d '/opt/pwn' ]]; then
pwn_root='/opt/pwn'
else
pwn_root="${PWN_ROOT}"
fi
function usage() {
echo $"Usage: $0 <new ruby version e.g. 2.4.4> <optional bool running from build_pwn_gem.sh>"
exit 1
}
source /etc/profile.d/rvm.sh
new_ruby_version=$1
if [[ $2 != '' ]]; then
old_ruby_version=$2
else
old_ruby_version=`cat ${pwn_root}/.ruby-version`
fi
ruby_gemset=`cat ${pwn_root}/.ruby-gemset`
if [[ $# < 1 ]]; then
usage
fi
# Upgrade RVM
curl -sSL https://rvm.io/mpapis.asc | sudo gpg2 --import -
curl -sSL https://rvm.io/pkuczynski.asc | sudo gpg2 --import -
export rvmsudo_secure_path=1
rvmsudo rvm get stable
rvm reload
# Install New Version of RubyGems & Ruby
cd $pwn_root && ./vagrant/provisioners/gem.sh
rvmsudo rvm install ruby-$new_ruby_version
echo $new_ruby_version > $pwn_root/.ruby-version
cd / && cd $pwn_root && rvm use $new_ruby_version@$ruby_gemset && ./build_pwn_gem.sh
rvmsudo gem pristine --all