-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathupgrade_ruby.sh
More file actions
executable file
·46 lines (38 loc) · 1.1 KB
/
upgrade_ruby.sh
File metadata and controls
executable file
·46 lines (38 loc) · 1.1 KB
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
#!/bin/bash --login
# USE THIS SCRIPT WHEN UPGRADING RUBY
if [[ $MESHTASTIC_ROOT == '' ]]; then
if [[ ! -d '/opt/meshtastic' ]]; then
meshtastic_root=$(pwd)
else
meshtastic_root='/opt/meshtastic'
fi
else
meshtastic_root="${MESHTASTIC_ROOT}"
fi
function usage() {
echo $"Usage: $0 <new ruby version e.g. 2.4.4> <optional bool running from build_gem.sh>"
exit 1
}
if [[ -f '/etc/profile.d/rvm.sh' ]]; then
source /etc/profile.d/rvm.sh
fi
new_ruby_version=$1
if [[ $2 != '' ]]; then
old_ruby_version=$2
else
old_ruby_version=`cat ${meshtastic_root}/.ruby-version`
fi
ruby_gemset=`cat ${meshtastic_root}/.ruby-gemset`
if [[ $# < 1 ]]; then
usage
fi
# Upgrade RVM
export rvmsudo_secure_path=1
# Keep this command to pull master to avoid unknown ruby interpreter error when using latest version of Ruby.
rvmsudo rvm get master
rvm reload
# Install New Version of RubyGems & Ruby
cd $meshtastic_root && ./upgrade_gem.sh
rvmsudo rvm install ruby-$new_ruby_version
echo $new_ruby_version > $meshtastic_root/.ruby-version
cd $meshtastic_root && rvm use $new_ruby_version@$ruby_gemset && ./build_gem.sh