-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathubuntu.sh
130 lines (108 loc) · 2.74 KB
/
ubuntu.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/sh
# If any command fails, we should immediately fail too
set -e
add_to_bash_profile() {
if ! grep --quiet "$1" $PROFILE; then
echo "$1" >> $PROFILE
fi
}
refresh_session_profile() {
if [ -f $PROFILE ]; then
. $PROFILE
fi
}
install_rbenv() {
if ! command -v rbenv >/dev/null; then
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
add_to_bash_profile 'export PATH="$HOME/.rbenv/bin:$PATH"'
add_to_bash_profile 'eval "$(rbenv init -)"'
if ! grep --quiet "gem: --no-document" ~/.gemrc; then
echo "gem: --no-document" >> ~/.gemrc
fi
else
echo "rbenv already installed. Skipping..."
fi
}
install_ruby() {
local version="$1"
eval "$(rbenv init -)"
rbenv install -s "$version"
rbenv global "$version"
rbenv shell "$version"
if ! command -v bundle >/dev/null; then
gem install bundler
rbenv rehash
cores=$(nproc)
bundle config --global jobs $((cores - 1))
bundle config --global path vendor/ruby
bundle config --global bin .bin
add_to_bash_profile 'export PATH=".bin:bin:$PATH"'
fi
}
install_nvm() {
if ! command -v nvm >/dev/null; then
echo "Installing nvm"
curl --silent \
--fail \
--show-error \
--location \
https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
refresh_session_profile
else
echo "nvm already installed. Skipping..."
fi
}
install_yarn() {
if ! command -v yarn >/dev/null; then
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install --no-install-recommends yarn
else
echo "Yarn already installed. Skipping..."
fi
}
install_arcanist() {
if ! [ -d ~/.phabricator ]; then
mkdir ~/.phabricator
git clone https://github.com/phacility/libphutil.git ~/.phabricator/libphutil
git clone https://github.com/phacility/arcanist.git ~/.phabricator/arcanist
add_to_bash_profile 'export PATH="$HOME/.phabricator/arcanist/bin:$PATH"'
fi
}
setup_profile() {
export PROFILE=$1
touch $PROFILE
echo "source $PROFILE" >> ~/.bashrc
}
setup_profile ~/.bash_profile
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
build-essential \
bison \
automake \
autoconf \
pkg-config \
curl \
git \
libffi-dev \
libgdbm-dev \
libncurses5-dev \
libreadline-dev \
libssl-dev \
libyaml-dev \
openssl \
sqlite3 \
libsqlite3-dev \
libssl-dev \
zlib1g \
zlib1g-dev \
php \
php-curl
install_rbenv
install_ruby 2.4.2
install_nvm
nvm install node
install_yarn
install_arcanist