Skip to content

Instantly share code, notes, and snippets.

@godber
Created July 19, 2010 15:26
Show Gist options
  • Save godber/481551 to your computer and use it in GitHub Desktop.
Save godber/481551 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# rebundle.sh - Rebundles, uploads and registers an AMI.
# For blogpost:
# http://blog.crunch.io/user-managed-kernel-amis-from-existing-ubuntu
# Austin Godber <godber@crunch.io>
if [ `id -u` != '0' -o "$AWS_USER_ID" == "" ]; then
echo "ERROR: You must run this with 'sudo -E' or as the root user"
exit 1
fi
arch=i386
prefix=testami
bucket=<your bucket>
# Uncomment this if you want to rerun.
#rm -rf /mnt/${prefix}*
ec2-bundle-vol -r $arch -d /mnt \
-p $prefix \
-u $AWS_USER_ID \
-k /mnt/tmp/pk-*.pem \
-c /mnt/tmp/cert-*.pem \
-s 10240 \
-e /mnt,/tmp,/root/.ssh,/home/ubuntu/.ssh \
--kernel "aki-407d9529"
ec2-upload-bundle \
-b $bucket \
-m /mnt/$prefix.manifest.xml \
-a $AWS_ACCESS_KEY_ID \
-s $AWS_SECRET_ACCESS_KEY
ec2-register --name "$bucket/$prefix" $bucket/$prefix.manifest.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment