-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathprepare-node-image.sh
More file actions
executable file
·79 lines (64 loc) · 2.51 KB
/
prepare-node-image.sh
File metadata and controls
executable file
·79 lines (64 loc) · 2.51 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
#!/bin/bash -ex
#
# Prepare a Deis image for Rackspace.
#
# Instructions:
#
# 1. Create a server using the Ubuntu 12.04 LTS image,
# performance1-2, 2GB performance server
# 2. SSH in as root with the password shown, then install the 3.11 kernel with:
# apt-get update && apt-get install -yq linux-image-generic-lts-saucy linux-headers-generic-lts-saucy && reboot
# 3. After reboot is complete, SSH in and `uname -r` to confirm kernel is 3.11
# 4. Run this script (as root) to optimize the image for fast boot times
# 5. Create a new image from the server named "deis-node-image".
# 6. Distribute the image to other regions
# 7. Create/update your Deis flavors to use your new images
#
# Remove old kernel(s)
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
# Add the Docker repository key to your local keychain
# using apt-key finger you can check the fingerprint matches 36A1 D786 9245 C895 0F96 6E92 D857 6A8B A88D 21E9
curl https://get.docker.io/gpg | apt-key add -
# Add the Docker repository to your apt sources list.
echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
# upgrade to latest packages
apt-get update
apt-get dist-upgrade -yq
# install latest pip
wget -q https://raw.github.com/pypa/pip/1.5.4/contrib/get-pip.py && \
python get-pip.py && \
rm get-pip.py
# install required packages
apt-get install lxc-docker-0.8.0 fail2ban curl git inotify-tools make -yq
# wait for docker to start
while [ ! -e /var/run/docker.sock ] ; do
inotifywait -t 2 -e create $(dirname /var/run/docker.sock)
done
# pull current docker images
docker pull deis/data:latest
docker pull deis/discovery:latest
docker pull deis/registry:latest
docker pull deis/cache:latest
docker pull deis/logger:latest
docker pull deis/database:latest
docker pull deis/controller:latest
docker pull deis/builder:latest
# install chef 11.x deps
apt-get install -yq ruby1.9.1 ruby1.9.1-dev make
update-alternatives --set ruby /usr/bin/ruby1.9.1
update-alternatives --set gem /usr/bin/gem1.9.1
# clean and remove old packages
apt-get clean
apt-get autoremove -yq
# reset cloud-init
rm -rf /var/lib/cloud
# purge SSH authorized keys
rm -f /home/ubuntu/.ssh/authorized_keys
rm -f /root/.ssh/authorized_keys
# remove /etc/chef so contents can't intefere with
# node being converged (i.e. old keys)
rm -f /etc/chef/*
# purge /var/log
find /var/log -type f | xargs rm
# flush writes to block storage
sync