-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
65 lines (56 loc) · 1.91 KB
/
bootstrap.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
#!/usr/bin/env bash
set -xe
cd /tmp
apt-get update
apt-get upgrade -y
update-rc.d puppet disable
service puppet stop || true
update-rc.d chef-client disable
service chef-client stop || true
kill `cat /var/run/chef/client.pid` || true
if ! grep "127.0.0.1 $(hostname)" /etc/hosts; then
echo "127.0.0.1 $(hostname)" >>/etc/hosts
fi
# Setup swap
if ! grep '^/dev/sdb\b' /etc/fstab; then
mkswap -f /dev/sdb
echo "/dev/sdb none swap sw 0 0" >>/etc/fstab
swapon /dev/sdb
fi
# Setup /var/lib/docker filesystem
# quadruple the usual number of inodes, since overlay creates a lot of files
if ! grep '^/dev/sdc\b' /etc/fstab; then
mkfs -F -t ext4 -i 4096 /dev/sdc
echo "/dev/sdc /var/lib/docker ext4 defaults,nofail 0 2" >>/etc/fstab
(which docker && service docker stop) || true
rm -rf /var/lib/docker
mkdir -p /var/lib/docker
mount /var/lib/docker
(which docker && service docker start) || true
fi
# Install Docker
if ! which docker; then
wget -qO- https://get.docker.com/ | sh
gpasswd -a vagrant docker
service docker stop
rm -rf /var/lib/docker/*
echo 'DOCKER_OPTS="-s overlay -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"' >>/etc/default/docker
# This is a workaround for docker not using /etc/default/docker on vivid
# (from http://nknu.net/how-to-configure-docker-on-ubuntu-15-04/)
mkdir -p /etc/systemd/system/docker.service.d
cat >/etc/systemd/system/docker.service.d/ubuntu.conf <<'EOF'
[Service]
EnvironmentFile=/etc/default/docker
ExecStart=
ExecStart=/usr/bin/docker daemon -H fd:// $DOCKER_OPTS
EOF
systemctl daemon-reload
service docker start
fi
# Install stack
if ! which stack; then
wget -qO- https://s3.amazonaws.com/download.fpcomplete.com/ubuntu/fpco.key | sudo apt-key add -
echo 'deb http://download.fpcomplete.com/ubuntu wily main'|sudo tee /etc/apt/sources.list.d/fpco.list
apt-get update
apt-get install -y stack
fi