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
from boto.s3.connection import S3Connection | |
from boto.s3.key import Key | |
bucketname = 'testbucket' | |
keyname = 'testkey' | |
conn = S3Connection() | |
bucket = None | |
## get bucket or create it | |
try: |
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
#!/bin/sh | |
EC2_MODULE="2.6.21.7-2.fc8xen-ec2-v1.0" ## set the ec2 module | |
SCRIPT_DIR="/var/awsscripts" ## scripts to setup the amazon stuff, will be copied to the image | |
IMAGE_DIR="/var/awsimage" ## directory to store the img file and ami image in | |
RELEASEVER=11 |
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
## Setup image | |
dd if=/dev/zero of="$IMAGE_DIR/$IMG_FILE" bs=1M count="$IMAGE_SIZE" | |
/sbin/mke2fs -F -j "$IMAGE_DIR/$IMG_FILE" | |
mkdir "/mnt/$BASE_NAME" | |
mount -o loop "$IMAGE_DIR/$IMG_FILE" "/mnt/$BASE_NAME" |
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
## setup repo | |
rm -f ./yum.all.repo | |
DIR="/etc/yum.repos.d" | |
SUFFIX="repo" | |
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
## kernel-xen | |
if [ ! -f "ec2-modules-$EC2_MODULE.tgz" ]; then | |
wget "http://ec2-downloads.s3.amazonaws.com/ec2-modules-$EC2_MODULE.tgz" | |
fi | |
tar zxvf "ec2-modules-$EC2_MODULE.tgz" -C "/mnt/$BASE_NAME" |
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
## update ssh file | |
echo " GSSAPIAuthentication yes" >> "/mnt/$BASE_NAME/etc/ssh/sshd_config" | |
echo " Protocol 2" >> "/mnt/$BASE_NAME/etc/ssh/sshd_config" | |
echo " X11Forwarding yes " >> "/mnt/$BASE_NAME/etc/ssh/sshd_config" | |
echo " AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES " >> "/mnt/$BASE_NAME/etc/ssh/sshd_config" |
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
## Update more packages | |
yum -c yum.all.repo --installroot="/mnt/$BASE_NAME" -y erase cups ## erase printing, can do more customization here as well | |
yum -c yum.all.repo --installroot="/mnt/$BASE_NAME" -y install fuse-devel fuse fuse-encfs fuse-libs fuse-sshfs java-1.6.0-openjdk xen-runtime ruby | |
## update services | |
/usr/sbin/chroot "/mnt/$BASE_NAME" /sbin/chkconfig --level 1345 sshd --add |
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
ec2-bundle-image --image "$IMAGE_DIR/$IMG_FILE" --prefix "$BASE_NAME" --cert "$EC2_CERT" --privatekey "$EC2_PRIVATE_KEY" --user "$AWS_USER" --destination "$IMAGE_DIR" --arch "$ARCH" | |
ec2-upload-bundle --manifest "$IMAGE_DIR/$BASE_NAME.manifest.xml" --bucket "$BUCKET_NAME" --access-key "$AWS_ACCESS_KEY_ID" --secret-key "$AWS_SECRET_ACCESS_KEY" |
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
#!/bin/sh | |
# $Rev: 45452 $ | |
# This script will be executed *after* all the other init scripts. | |
# You can put your own initialization stuff in here if you don't | |
# want to do the full Sys V style init stuff. | |
echo "-----VERSION : ""\$Rev: 45452 $""-----" | |
# Stuff we want to do once at launch and never again: | |
if [ -f "/root/firstrun" ]; then | |
# Update AMI tools to the latest version: | |
# [ -x "/usr/local/sbin/update-tools.sh" ] && /usr/local/sbin/update-tools.sh |
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
#!/bin/bash | |
# Version : $Rev: 45328 $ | |
# root's public keys | |
PUB_KEY_URI=http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key | |
# PUB_KEY_URI=http://169.254.169.254/1.0/meta-data/public-keys/0/openssh-key | |
PUB_KEY_FROM_HTTP=/tmp/openssh_id.pub | |
PUB_KEY_FROM_EPHEMERAL=/mnt/openssh_id.pub | |
ROOT_AUTHORIZED_KEYS=/root/.ssh/authorized_keys | |
OlderNewer