maint: adjust copyright on most files: Red Hat, not FSF
[iwhd.git] / dc-register-image
blob585c40d74aa97cebdd5abd02b2ad728bfd53976b
1 #!/bin/bash
3 # Copyright (C) 2010 Red Hat, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Uncomment for debugging.
19 #ECHO=echo
21 bucket=$1; shift
22 object=$1; shift
23 api_key=$1; shift
24 api_secret=$1; shift
25 cert_file=$1; shift
26 key_file=$1; shift
27 api_uid=$1; shift
28 ami_bkt=$1; shift
29 kernel=$1; shift
30 ramdisk=$1; shift
32 # TBD: figure out what to do about these paths.
33 export EC2_HOME=~/jdarcy/ec2-api-tools-1.3-53907
34 export PATH=$PATH:$EC2_HOME/bin
35 export JAVA_HOME=/usr
37 tmpdir=$(mktemp -d -p $PWD/$bucket)
38 trap "rm -rf $tmpdir" EXIT
40 bundle_args="--batch --arch x86_64 -c $cert_file -k $key_file -u $api_uid"
41 if [ "$kernel" != "_default_" ]; then
42 bundle_args="$bundle_args --kernel $kernel"
44 if [ "$ramdisk" != "_default_" ]; then
45 bundle_args="$bundle_args --ramdisk $ramdisk"
47 $ECHO ec2-bundle-image -i $bucket/$object -d $tmpdir $bundle_args
48 if [ $? != 0 ]; then
49 echo "ERROR bundling_failed"
50 echo ec2-bundle-image -i $bucket/$object -d $tmpdir $bundle_args
51 exit 1
54 upload_args="--batch --retry -b $ami_bkt -a $api_key -s $api_secret"
55 $ECHO ec2-upload-bundle -m $tmpdir/$object.manifest.xml $upload_args
56 if [ $? != 0 ]; then
57 echo "ERROR uploading_failed"
58 echo ec2-upload-bundle -m $tmpdir/$object.manifest.xml $upload_args
59 exit 1
62 register_args="-C $cert_file -K $key_file"
63 $ECHO ec2-register $register_args $ami_bkt/$object.manifest.xml -n $object
64 if [ $? != 0 ]; then
65 echo "ERROR registration_failed"
66 echo ec2-register $register_args $ami_bkt/$object.manifest.xml -n $object
67 exit 1