-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathprepare-ubuntu-ami.sh
More file actions
executable file
·58 lines (46 loc) · 1.54 KB
/
prepare-ubuntu-ami.sh
File metadata and controls
executable file
·58 lines (46 loc) · 1.54 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
#!/bin/bash -ex
#
# Prepare a Deis-optimized AMI from a vanilla Ubuntu 12.04
#
# Instructions:
#
# 1. Launch a vanilla Ubuntu 12.04 instance (64-bit with an EBS root volume)
# 2. SSH in and install the 3.8 kernel with:
# apt-get update && apt-get install -yq linux-generic-lts-raring && reboot
# 3. After reboot is complete, SSH in and `uname -r` to confirm kernel is 3.8
# 4. Run this script (as root!) to optimize the image for fast boot times
# 5. Create a new AMI from the root volume
# 6. Distribute the AMI to other regions using `ec2-copy-image`
# 7. Create/update your Deis flavors to use your new AMIs
#
# add docker ppa
apt-add-repository ppa:dotcloud/lxc-docker -y
# upgrade to latest packages
apt-get update
apt-get dist-upgrade -yq
# install required packages
apt-get install lxc-docker curl git python-setuptools python-pip -yq
# create buildstep docker image
git clone https://github.com/opdemand/buildstep.git
cd buildstep
./build.sh ./stack deis/buildstep
cd ..
rm -rf buildstep
# 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
# ssh host keys are automatically regenerated
# on system boot by ubuntu cloud init
# purge /var/log
find /var/log -type f | xargs rm
# flush writes to block storage
sync