Created
July 19, 2010 15:26
-
-
Save godber/481553 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# prep.sh - Prepares an Ubuntu AMI for Rebundling | |
# For blogpost: | |
# http://blog.crunch.io/user-managed-kernel-amis-from-existing-ubuntu | |
# Austin Godber <[email protected]> | |
if [ `id -u` != '0' ]; then | |
echo "ERROR: You must run this with 'sudo -E' or as the root user" | |
exit 1 | |
fi | |
# Adding the multiverse repo for the ec2-{api,ami}-tools | |
sed -i 's/universe/universe multiverse/' /etc/apt/sources.list | |
# Adding lucid partner repo to get sun jre | |
echo 'deb http://archive.canonical.com/ubuntu lucid partner' >> \ | |
/etc/apt/sources.list | |
apt-get update | |
apt-get install -y sun-java6-jre ec2-api-tools ec2-ami-tools | |
apt-get clean | |
mkdir /mnt/tmp | |
cat > /mnt/tmp/environment <<END | |
export AWS_USER_ID='<your-value>' | |
export AWS_ACCESS_KEY_ID='<your-value>' | |
export AWS_SECRET_ACCESS_KEY='<your-value>' | |
# /mnt/tmp/cert-...pem | |
export EC2_CERT=<path-to-cert-file> | |
# /mnt/tmp/pk-...pem | |
export EC2_PRIVATE_KEY=<path-to-pk-file> | |
END | |
chown -R ubuntu:ubuntu /mnt/tmp | |
ip=`wget -q -O - http://169.254.169.254/latest/meta-data/public-ipv4` | |
cat <<MSG | |
================================================================= | |
Now SCP your AWS Public Key and Cert to the /mnt/tmp/ directory: | |
scp pk-*.pem cert-*.pem ubuntu@${ip}:/mnt/tmp/ | |
Edit the generated environment template: /mnt/tmp/environment | |
nano /mnt/tmp/environment | |
Substitute your AWS credentials. | |
================================================================= | |
MSG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment