Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.

Commit a40f093

Browse files
committed
ec2builid.sh: altered find-instance logic
Find-instance now always waits for a running instance. This script is really just focused on running a single AMI per invocation, which should simplify much of the logic.
1 parent 0f64790 commit a40f093

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

ec2build.sh

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ INSTANCES=$HOME/ec2build-instances.txt
2020
VOLUMES=$HOME/ec2build-volumes.txt
2121

2222
AMI_UBUNTU_10_04_64BIT=ami-fd4aa494
23-
AMI_BEAGLEBOARD_VALIDATION=ami-3b719a52
23+
AMI_BEAGLEBOARD_VALIDATION=ami-954fa4fc
2424
if [ "x$DEFAULT_AMI" = "x" ]; then DEFAULT_AMI=$AMI_BEAGLEBOARD_VALIDATION; fi
2525
# MACH_TYPEs are m1.large, m2.4xlarge, etc.
2626
MACH_TYPE=m1.xlarge
@@ -33,21 +33,24 @@ TMPFS_DIR=$HOME/angstrom-setup-scripts
3333
THIS_FILE=$0
3434

3535
# Clear any local vars
36-
AMI=
36+
AMI=""
37+
INSTANCE=""
38+
MACH_NAME=""
3739

3840
# Additional parameters for initiating host
3941
function find-instance {
4042
AMI=$1
4143
if [ "x$AMI" = "x" ]; then AMI=$DEFAULT_AMI; fi
42-
if [ "x$INSTANCE" = "x" ];
43-
then
44+
while
45+
[ "x$INSTANCE" == "x" ]
46+
do
4447
#ec2-describe-instances | tee $INSTANCES;
4548
ec2-describe-instances > $INSTANCES;
4649
INSTANCE=`perl -ne '/^INSTANCE\s+(\S+)\s+'${AMI}'\s+(\S+)\s+\S+\s+running\s+/ && print "$1"' $INSTANCES`
4750
MACH_NAME=`perl -ne '/^INSTANCE\s+(\S+)\s+'${AMI}'\s+(\S+)\s+\S+\s+running\s+/ && print "$2";' $INSTANCES`
48-
fi
49-
echo INSTANCE=$INSTANCE;
50-
echo MACH_NAME=$MACH_NAME;
51+
done
52+
echo "INSTANCE=$INSTANCE";
53+
echo "MACH_NAME=$MACH_NAME";
5154
}
5255

5356
function make-keypair {
@@ -65,14 +68,7 @@ ec2-run-instances $AMI -k $KEYPAIR
6568
else
6669
ec2-run-instances $AMI -k $KEYPAIR -t $MACH_TYPE
6770
fi
68-
69-
INSTANCE=""
70-
MACH_NAME=""
71-
while
72-
[ "x$INSTANCE" == "x" ]
73-
do
74-
find-instance $AMI;
75-
done
71+
find-instance $AMI
7672
}
7773

7874
function authorize-ssh {
@@ -100,17 +96,13 @@ add-sshkey-ami
10096
ssh -i $KEYPAIR_FILE $USER@$MACH_NAME $2 $3 $4 $5 $6 $7 $8 $9
10197
}
10298

103-
function copy-files {
99+
function remote {
104100
find-instance $AMI
105101
ssh -i $KEYPAIR_FILE $USER@$MACH_NAME 'mkdir -p $HOME/secret; chmod 700 $HOME/secret'
106102
scp -i $KEYPAIR_FILE $EC2_CERT $USER@$MACH_NAME:secret/cert.pem
107103
scp -i $KEYPAIR_FILE $EC2_PRIVATE_KEY $USER@$MACH_NAME:secret/pk.pem
108104
scp -i $KEYPAIR_FILE $HOME/secret/setup_env.sh $USER@$MACH_NAME:secret/setup_env.sh
109105
scp -i $KEYPAIR_FILE $THIS_FILE $USER@$MACH_NAME:ec2build.sh
110-
}
111-
112-
function remote {
113-
copy-files
114106
ssh-ami $AMI ./ec2build.sh $1 $2 $3 $4 $5 $6 $7
115107
}
116108

@@ -369,12 +361,13 @@ gzip -c $SD_IMG > $SD_IMG.gz
369361
popd
370362
}
371363

364+
# about 30-40 minutes
372365
function build-beagleboard-validation-ami {
373366
DEFAULT_AMI=$AMI_UBUNTU_10_04_64BIT
374367
run-ami
375368
remote enable-oe
376369
remote enable-s3fuse
377-
remote enable-mksdimg
370+
remote enable-sd
378371
remote enable-ec2
379372
remote bundle-vol
380373
halt-ami
@@ -406,7 +399,7 @@ remote build-sd
406399
remote rsync-downloads
407400
# about 50 minutes
408401
remote rsync-deploy
409-
halt-ami
402+
#halt-ami
410403
}
411404

412405
time $*

0 commit comments

Comments
 (0)