-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap_ruby_stable.sh
More file actions
executable file
·55 lines (42 loc) · 1.43 KB
/
bootstrap_ruby_stable.sh
File metadata and controls
executable file
·55 lines (42 loc) · 1.43 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
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Download, configure and install Ruby and Bundler
# https://github.com/infertux/ruby-bootstrap
set -euo pipefail
VERSION="4.0.0"
SHA256="2e8389c8c072cb658c93a1372732d9eac84082c88b065750db1e52a5ac630271"
[ "${1:-}" = "--force" ] && FORCE=1 || FORCE=""
[ $UID -eq 0 ] || {
echo "Root required"
exit 1
}
# Install Ruby and Bundler if they are missing or the force flag is set
if [ -n "$FORCE" ] || ! command -v ruby >/dev/null; then
# Dependency list:
# - wget: to fetch Ruby and pretty useful anyway
# - gcc & make: to compile Ruby
# - various libs: libraries for Ruby
if [ -f /etc/debian_version ]; then
apt-get update
apt-get install -y wget gcc make libffi-dev libreadline-dev libssl-dev libyaml-dev zlib1g-dev
elif [ -f /etc/redhat-release ]; then
yum install -y wget gcc make openssl-devel readline-devel zlib-devel
fi
cd /tmp
wget https://cache.ruby-lang.org/pub/ruby/${VERSION%.*}/ruby-${VERSION}.tar.gz
echo "${SHA256} ruby-${VERSION}.tar.gz" | sha256sum -c -
tar --no-same-owner -xf ruby-${VERSION}.tar.gz
pushd ruby-${VERSION}
./configure --disable-install-doc
cpus=$(grep -c processor /proc/cpuinfo)
make -j "$cpus"
make install
popd
rm -rf ruby-${VERSION}.tar.gz ruby-${VERSION}
ln -sfv /usr/local/bin/ruby /bin/ruby
ln -sfv /usr/local/bin/gem /bin/gem
ln -sfv /usr/local/bin/bundle /bin/bundle
ruby -v
gem -v
bundle -v
fi
echo "All good to go, happy Rubying!"