gunnar: utils/ci/ec2 .cvsignore, NONE, 1.1 ec2-init-dev-instance.sh, NONE, 1.1 ec2-kill-dev-instance.sh, NONE, 1.1 ec2.config, NONE, 1.1

cvs at kolab.org cvs at kolab.org
Fri Dec 4 08:35:06 CET 2009


Author: gunnar

Update of /kolabrepository/utils/ci/ec2
In directory doto:/tmp/cvs-serv32245/ci/ec2

Added Files:
	.cvsignore ec2-init-dev-instance.sh ec2-kill-dev-instance.sh 
	ec2.config 
Log Message:
Started a ci (continuous integration) hierarchy.

--- NEW FILE: .cvsignore ---
ec2.local.config
*.pem
.current

--- NEW FILE: ec2-init-dev-instance.sh ---
#!/bin/bash

if [ -f .current ]; then
    echo "You already have an instance running! See file .current"
    exit 1
fi

if [ -f ec2.config ]; then
    source ec2.config
fi

echo "Testing for group \"$SEC_GROUP\" ..."
echo 

ec2-describe-group "${SEC_GROUP}" > /dev/null

if [ "$?" -ne "0" ]; then
    echo "Group \"$SEC_GROUP\" does not exist. Creating it ..."
    echo 
    ec2-add-group "${SEC_GROUP}" -d "Kolab default access permissions."
    ec2-authorize "${SEC_GROUP}" -P tcp -p   22 -s 0.0.0.0/0
    ec2-authorize "${SEC_GROUP}" -P tcp -p   25 -s 0.0.0.0/0
    ec2-authorize "${SEC_GROUP}" -P tcp -p   80 -s 0.0.0.0/0
    ec2-authorize "${SEC_GROUP}" -P tcp -p  110 -s 0.0.0.0/0
    ec2-authorize "${SEC_GROUP}" -P tcp -p  143 -s 0.0.0.0/0
    ec2-authorize "${SEC_GROUP}" -P tcp -p  389 -s 0.0.0.0/0
    ec2-authorize "${SEC_GROUP}" -P tcp -p  443 -s 0.0.0.0/0
    ec2-authorize "${SEC_GROUP}" -P tcp -p  465 -s 0.0.0.0/0
    ec2-authorize "${SEC_GROUP}" -P tcp -p  636 -s 0.0.0.0/0
    ec2-authorize "${SEC_GROUP}" -P tcp -p  993 -s 0.0.0.0/0
    ec2-authorize "${SEC_GROUP}" -P tcp -p  995 -s 0.0.0.0/0
    ec2-authorize "${SEC_GROUP}" -P tcp -p 2000 -s 0.0.0.0/0
    echo 
fi

echo "Testing for keypair \"$SSH_KEY\" ..."
echo 

test -f "${SSH_KEY}.pem"
KEY_PRESENT=$?
ec2-describe-keypairs "${SSH_KEY}" > /dev/null
KEY_AWS=$?

if [ \( "$KEY_AWS" -ne "0" \) -o \( "$KEY_PRESENT" -ne "0" \) ]; then
    echo
    echo "Keypair \"$SSH_KEY\" does not exist. Creating it ..."
    if [ "$KEY_AWS" == "0" ]; then
	ec2-delete-keypair "${SSH_KEY}"
    fi

    if [ "$KEY_PRESENT" == "0" ]; then
	rm "${SSH_KEY}.pem"
    fi

    ec2-add-keypair "${SSH_KEY}" > "${SSH_KEY}.pem"
    chmod 600 "${SSH_KEY}.pem"

    echo 
fi

echo "Launching instance ..."
echo 

RESULT=`ec2-run-instances "${AMI_ID}" -g "${SEC_GROUP}" -k "${SSH_KEY}" | tail -n 1`

INSTANCE=`echo ${RESULT} | awk '{print $2;}'`

if [ "$?" == "0" ]; then
    echo "Successfullly started instance \"$INSTANCE\"!"
    echo
    echo ${INSTANCE} > .current
else
    echo "Failed to start the instance!"
    exit 1
fi

CURRENT_STATUS=""

echo -n "Initializing "

while [ "x$CURRENT_STATUS" != "xOK" ]
do
    CURRENT_STATUS=`ec2-describe-instances "${INSTANCE}" | tail -n 1 | sed -e 's/.*running.*/OK/'`

    sleep 3

    echo -n "."
done

echo

FQDN=`ec2-describe-instances "${INSTANCE}" | tail -n 1 | awk '{print $4;}'`

if [ "$?" == "0" ]; then
    echo
    echo "Instance \"$INSTANCE\" has booted!"
    echo
    echo "You may connect to it using:"
    echo
    echo "ssh -A -i ${SSH_KEY}.pem root@${FQDN}"
    echo
else
    echo "Instance does not respond!"
    exit 1
fi

if [ "x${SSH_CONFIG}" != "x" ]; then
    scp -i ${SSH_KEY}.pem ${SSH_CONFIG} root@${FQDN}:~/.ssh
fi

if [ "x${SSH_KNOWN_HOSTS}" != "x" ]; then
    scp -i ${SSH_KEY}.pem ${SSH_KNOWN_HOSTS} root@${FQDN}:~/.ssh
fi

ssh -A -i ${SSH_KEY}.pem root@${FQDN} "mkdir /CVS"
ssh -A -i ${SSH_KEY}.pem root@${FQDN} "cd /CVS && cvs -d ${CVS_SERVER} co server"
ssh -A -i ${SSH_KEY}.pem root@${FQDN} "cd /CVS && cvs -d ${CVS_SERVER} co utils"

--- NEW FILE: ec2-kill-dev-instance.sh ---
#!/bin/bash

if [ ! -f .current ]; then
    echo "You have no instance running!"
    exit 1
fi

if [ -f ec2.config ]; then
    source ec2.config
fi

INSTANCE=`cat .current`

echo "Terminating instance ..."
echo 

INFO=`ec2-terminate-instances "${INSTANCE}"`

if [ "$?" == "0" ]; then
    echo "Successfullly terminated instance \"$INSTANCE\"!"
    echo
    rm .current
else
    echo "Failed to terminate instance \"$INSTANCE\"!"
    exit 1
fi

echo "Removing keypair \"$SSH_KEY\" ..."
echo 

test -f "${SSH_KEY}.pem"
KEY_PRESENT=$?
ec2-describe-keypairs "${SSH_KEY}" > /dev/null
KEY_AWS=$?

if [ "$KEY_AWS" == "0" ]; then
    ec2-delete-keypair "${SSH_KEY}" > /dev/null
fi

if [ "$KEY_PRESENT" == "0" ]; then
    rm "${SSH_KEY}.pem"
fi

--- NEW FILE: ec2.config ---
#!/bin/bash
#
# CONFIGURATION FILE FOR DEVELOPMENT ON EC2
#
# --
#
# Override the settings described here in ec2.local.config

####
# The path to your private AWS key
#
# You should have reveived this key from your account details on the
# AWS site.

export EC2_PRIVATE_KEY=/home/user/.ec2/MY_SECRET_PRIVATE_KEY.pem

####
# The path to your AWS certificate
#
# You should have reveived this key from your account details on the
# AWS site.

export EC2_CERT=/home/user/.ec2/MY_CERTIFICATE.pem

####
# The AMI ID of the base system that should be used for development
#
# ami-6e2eca07 : Kolab-Server-2.1
# ami-c910f4a0 : Kolab-Server-2.2
# ami-7d23c414 : Kolab-Server-2.2.1-rc1
# ami-412cca28 : Kolab-Server-2.2.2

AMI_ID=ami-412cca28

####
# The security group the instance should be launched in. If the
# specified group does not exist, it will get created with the default
# permissions.
#
# The following permissions are the default:
#
# PERMISSION    ALLOWS  tcp     22      22      FROM    CIDR    0.0.0.0/0
# PERMISSION    ALLOWS  tcp     25      25      FROM    CIDR    0.0.0.0/0
# PERMISSION    ALLOWS  tcp     80      80      FROM    CIDR    0.0.0.0/0
# PERMISSION    ALLOWS  tcp     110     110     FROM    CIDR    0.0.0.0/0
# PERMISSION    ALLOWS  tcp     143     143     FROM    CIDR    0.0.0.0/0
# PERMISSION    ALLOWS  tcp     389     389     FROM    CIDR    0.0.0.0/0
# PERMISSION    ALLOWS  tcp     443     443     FROM    CIDR    0.0.0.0/0
# PERMISSION    ALLOWS  tcp     465     465     FROM    CIDR    0.0.0.0/0
# PERMISSION    ALLOWS  tcp     636     636     FROM    CIDR    0.0.0.0/0
# PERMISSION    ALLOWS  tcp     993     993     FROM    CIDR    0.0.0.0/0
# PERMISSION    ALLOWS  tcp     995     995     FROM    CIDR    0.0.0.0/0
# PERMISSION    ALLOWS  tcp     2000    2000    FROM    CIDR    0.0.0.0/0

SEC_GROUP=kolab

####
# The name of the SSH key used for accessing the instance. It will be
# created if it is either missing on the local disk or not present
# within your AWS account.

SSH_KEY=kolab

####
# Path to your SSH configuration files. If set they will be copied
# over to the new instance.

SSH_CONFIG=""
SSH_KNOWN_HOSTS=""

####
# Location of the Kolab source repository

CVS_SERVER=":pserver:anonymous at intevation.de:/home/kroupware/jail/kolabrepository"


####
# Now load the personal overrides

if [ -f ec2.local.config ]; then
   source ec2.local.config
fi





More information about the commits mailing list