The long-promised type cleanup. Eval always returns 0 or 1. String_value
[iwhd.git] / dc-register-image
blob38d59c3cd1bff714a97f180e1145a58a3d45ffa2
1 #!/bin/bash
3 # Uncomment for debugging.
4 #ECHO=echo
6 bucket=$1; shift
7 object=$1; shift
8 api_key=$1; shift
9 api_secret=$1; shift
10 cert_file=$1; shift
11 key_file=$1; shift
12 api_uid=$1; shift
13 ami_bkt=$1; shift
14 kernel=$1; shift
15 ramdisk=$1; shift
17 # TBD: figure out what to do about these paths.
18 export EC2_HOME=~/jdarcy/ec2-api-tools-1.3-53907
19 export PATH=$PATH:$EC2_HOME/bin
20 export JAVA_HOME=/usr
22 tmpdir=$(mktemp -d -p $PWD/$bucket)
23 trap "rm -rf $tmpdir" EXIT
25 bundle_args="--batch --arch x86_64 -c $cert_file -k $key_file -u $api_uid"
26 if [ "$kernel" != "_default_" ]; then
27 bundle_args="$bundle_args --kernel $kernel"
29 if [ "$ramdisk" != "_default_" ]; then
30 bundle_args="$bundle_args --ramdisk $ramdisk"
32 $ECHO ec2-bundle-image -i $bucket/$object -d $tmpdir $bundle_args
33 if [ $? != 0 ]; then
34 echo "ERROR bundling_failed"
35 echo ec2-bundle-image -i $bucket/$object -d $tmpdir $bundle_args
36 exit 1
39 upload_args="--batch --retry -b $ami_bkt -a $api_key -s $api_secret"
40 $ECHO ec2-upload-bundle -m $tmpdir/$object.manifest.xml $upload_args
41 if [ $? != 0 ]; then
42 echo "ERROR uploading_failed"
43 echo ec2-upload-bundle -m $tmpdir/$object.manifest.xml $upload_args
44 exit 1
47 register_args="-C $cert_file -K $key_file"
48 $ECHO ec2-register $register_args $ami_bkt/$object.manifest.xml -n $object
49 if [ $? != 0 ]; then
50 echo "ERROR registration_failed"
51 echo ec2-register $register_args $ami_bkt/$object.manifest.xml -n $object
52 exit 1