AmazonEC2: start-ec2-instance

File start-ec2-instance, 1.4 KB (added by simonmar, 3 years ago)
Line 
1#!/bin/sh
2
3# ami-2675974f = Ubuntu 9.10 server i386 5Gb EBS
4# ami-916c81f8 = my snapshot: Ubuntu 9.10 server i386 5Gb EBS
5AMI=ami-916c81f8
6
7USER=ubuntu
8KEY=simonmar-us-east-keypair
9
10PWD=`pwd`
11
12# ec2-run-instances ami-916c81f8 -b /dev/sdc=ephemeral0 -k simonmar-us-east-keypair -t m1.small
13
14ec2-request-spot-instances \
15  ${AMI} \
16  --price 0.08 \
17  --type one-time \
18  -k ${KEY} \
19  -t c1.medium
20
21# This doesn't work; it seems to be already enabled in my snapshot
22#  -b /dev/sdc=ephemeral0 \
23
24echo -n waiting for instance startup...
25while true; do
26   instance=`ec2-describe-instances | grep "${AMI}.*running"`
27   if [ "$instance" != "" ]; then break; fi
28   sleep 1
29   echo -n .
30done
31
32EC2_HOST=`echo $instance | cut -d ' ' -f 4`
33
34echo ${EC2_HOST}
35
36cp ~/.ssh/config ~/.ssh/config.old
37sed <~/.ssh/config >~/.ssh/config.new "s|Hostname ec2.*amazonaws.com|Hostname ${EC2_HOST}|;s|IdentityFile .*pem|IdentityFile ${PWD}/${KEY}.pem|"
38mv ~/.ssh/config.new ~/.ssh/config
39chmod 600 ~/.ssh/config
40
41# copy some files up
42if test -f ~/.screenrc; then
43  scp prep_instance validate ~/.screenrc ec2:
44fi
45
46# prep the instance (mount the ephemeral drive etc.)
47ssh ec2 sh prep_instance
48
49echo "to log in:              ssh ec2"
50echo "to log in with screen:  ssh -t ec2 screen -R"
51echo "to push patches to EC2: ./darcs-all --checked-out -r ec2:ghc push"
52echo "to validate GHC:        ssh ec2 sh validate"
53echo "to shut down:           ssh ec2 sudo halt"