-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript
More file actions
90 lines (78 loc) · 3.33 KB
/
script
File metadata and controls
90 lines (78 loc) · 3.33 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
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
#!/bin/bash
###############################################################################
# Define user settings for rbenv installation. Defaults are normally fine.
###############################################################################
USER_NAME=${USER_NAME-vagrant}
USER_HOME=${USER_HOME-/home/$USER_NAME}
DEFAULT_RUBY=${DEFAULT_RUBY-'2.4.2'}
###############################################################################
# Functions
###############################################################################
# Most of the time we can get by with this DRY wrapper for sudo commands.
as_user() {
echo "$USER_NAME:~$ > ${*}"
su -l $USER_NAME -c "$*"
}
# Install the requested version of Ruby, with Bundler.
install_ruby() {
as_user "rbenv install -s $1"
as_user "RBENV_VERSION=$1 gem install bundler"
}
###############################################################################
# Base System
###############################################################################
apt-get -y update
apt-get -yfV dist-upgrade
###############################################################################
# rbenv & ruby-build, and Rubies
# From https://github.com/sstephenson/rbenv
# and https://github.com/sstephenson/ruby-build
###############################################################################
# Install dependencies.
apt-get install -yfV \
apt-transport-https \
build-essential \
ca-certificates \
curl \
git-core \
libcurl4-openssl-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
libxslt1-dev \
libyaml-dev \
linux-image-extra-$(uname -r) \
linux-image-extra-virtual \
python-software-properties \
software-properties-common \
sqlite3 \
zlib1g-dev \
libffi-dev \
# Remove any leftovers
apt-get -y autoremove
# Install rbenv and ruby-build.
as_user "git clone https://github.com/rbenv/rbenv.git $USER_HOME/.rbenv"
as_user "git clone https://github.com/rbenv/ruby-build.git $USER_HOME/.rbenv/plugins/ruby-build"
# Setup bash to use rbenv for $USER_NAME.
truncate -s 0 $USER_HOME/.bashrc
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> $USER_HOME/.bashrc
echo 'eval "$(rbenv init -)"' >> $USER_HOME/.bashrc
echo 'cd /vagrant' >> $USER_HOME/.bashrc
echo 'gem: --no-document' >> $USER_HOME/.gemrc
# Install Ruby for $USER_NAME.
install_ruby $DEFAULT_RUBY
as_user "/home/$USER_NAME/.rbenv/bin/rbenv global $DEFAULT_RUBY"
# Install Docker (very common use case)
# https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#install-using-the-repository
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update && apt-get install docker-ce
###############################################################################
# EDIT HERE!
# Install any Rubies (other than $DEFAULT_RUBY) required for testing, etc.
###############################################################################
# e.g. `install_ruby 1.9.3`