-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-rbenv
executable file
·70 lines (54 loc) · 1.85 KB
/
install-rbenv
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
#!/usr/bin/env bash
# Author: [email protected]
# Purpose: Automate the installation of rbenv
#
# Params:
# required ${1} - name of user who rbenv should be installed under
# optional ${2} - alternative home path, defaults to: /home
#
if [ $# -eq 0 ]
then
echo "Error. Must provide username where rbenv should be installed."
echo "Ex. ./install-rbenv typo3"
exit 1
fi
executing_user=$(whoami)
if [[ "${executing_user}" != "root" ]]
then
echo "Error. Must run as root user."
exit 1
fi
if [ ! -r "/etc/lsb-release" ]; then
echo "Cannot read version" >&2
exit 1
fi
. /etc/lsb-release
home_path="/home"
if [ ! -z "${2}" ]
then
home_path=${2}
fi
if [[ "${DISTRIB_RELEASE}" == "18.04" ]]
then
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 software-properties-common libffi-dev
else
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
fi
su - ${1} << EOF
git clone https://github.com/rbenv/rbenv.git ${home_path}/${1}/.rbenv
cd ${home_path}/${1}/.rbenv && src/configure && make -C src
cd ${home_path}/${1}/.rbenv && src/configure && make -C src
echo "export PATH=${home_path}/${1}/.rbenv/bin:$PATH" >> /${home_path}/${1}/.bash_profile
echo 'eval "\$(rbenv init -)"' >> ${home_path}/${1}/.bash_profile
git clone https://github.com/rbenv/ruby-build.git ${home_path}/${1}/.rbenv/plugins/ruby-build
${home_path}/${1}/.rbenv/bin/rbenv init
EOF
cat << EOF
Ok, ok, ok it is done
rbenv and ruby-build are setup for: ${1}
Now \`su - ${1}\`
Check the .ruby-version for the project
Then \`rbenv install x.x.x\`
GROOD, REAL GROOD
EOF
exit 0