1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-29 03:27:05 +00:00
mailinabox/ec2/start_instance.sh

36 lines
968 B
Bash
Raw Normal View History

2013-08-21 13:37:33 +00:00
if [ -z "$EC2_KEYPAIR_NAME" ]; then
EC2_KEYPAIR_NAME=mykey
fi
UBUNTU_CONFIG="us-east-1 13.04 amd64 instance-store"
export AMI=`curl -s http://cloud-images.ubuntu.com/locator/ec2/releasesTable | python3 tools/get_ubuntu_ami.py $UBUNTU_CONFIG`
ec2-create-group -d "mailinabox" "mailinabox"
2013-08-21 20:53:22 +00:00
for PORT in 25 53 587 993; do ec2-authorize mailinabox -P tcp -p $PORT -s 0.0.0.0/0; done
for PORT in 53; do ec2-authorize mailinabox -P udp -p $PORT -s 0.0.0.0/0; done
2013-08-21 13:37:33 +00:00
ec2run $AMI -k $EC2_KEYPAIR_NAME -t m1.small -z $AWS_AZ -g mailinabox > instance.info
export INSTANCE=`cat instance.info | grep INSTANCE | awk {'print $2'}`
2013-08-21 13:37:33 +00:00
echo Started instance $INSTANCE
sleep 5
while [ 1 ]
do
2013-08-21 13:37:33 +00:00
export INSTANCE_IP=`ec2-describe-instances $INSTANCE | grep INSTANCE | awk {'print $14'}`
if [ -z "$INSTANCE_IP" ]
then
echo "Waiting for $INSTANCE to start..."
else
2013-08-21 13:37:33 +00:00
break
fi
sleep 6
done
2013-08-21 13:37:33 +00:00
# Give SSH time to start.
sleep 5
echo New instance has IP: $INSTANCE_IP