-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcreate-openSUSE-AMIs.sh
executable file
·63 lines (55 loc) · 1.44 KB
/
create-openSUSE-AMIs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
#
# Simple bash script for creating public openSUSE AMIs in all Amazon EC2
# regions, from a Studio built openSUSE image.
#
# It assumes that the image tarball is in the form
# 'Amazon_Machine_Image_AMI_12.1_32bit.i686-3.0.0.ec2.tar.gz', and parses the
# filename to extract the openSUSE version (eg. 12.2), image version (eg.
# 4.0.0) and architecture (i686 or x86_64).
#
# See https://github.com/susestudio/susestudio-ec2 for details and examples.
#
# Author: James Tan <jatan@suse.com>
usage() {
echo >&2 "Usage: create-openSUSE-AMIs TARBALL"
echo >&2 " where TARBALL is in the form 'Amazon_Machine_Image_AMI_12.1_32bit.i686-3.0.0.ec2.tar.gz'"
}
if [ $# -eq 0 ]; then
usage
exit 1
fi
tarball=$1
arch=${tarball%%-*}
arch=${arch%%-*}
arch=${arch##*.}
[ "$arch" = "i686" ] && arch=i386
version=${tarball%%.ec2.tar.gz}
version=${version##*-}
base=${tarball#*Amazon_Machine_Image_AMI_*}
base=${base%%_*}
echo " tarball: $tarball"
echo " base: $base"
echo " arch: $arch"
echo " version: $version"
for region in \
ap-northeast-1 \
ap-southeast-1 \
eu-west-1 \
sa-east-1 \
us-east-1 \
us-west-1 \
us-west-2
do
name="openSUSE-$base-v$version.$arch"
echo
echo "Creating $name in $region..."
./susestudio/create_ami.sh.in \
--tarball $tarball \
--region $region \
--name $name \
--base $base \
--arch $arch \
--test_ami \
--public 2>&1 | tee upload_images.log
done