... | ... |
@@ -1,12 +1,9 @@ |
1 | 1 |
#!/usr/bin/env bash |
2 | 2 |
|
3 | 3 |
# Make sure that we have the proper version of ubuntu (only works on natty/oneiric) |
4 |
-UBUNTU_VERSION=`cat /etc/lsb-release | grep CODENAME | sed 's/.*=//g'` |
|
5 |
-if [ ! "oneiric" = "$UBUNTU_VERSION" ]; then |
|
6 |
- if [ ! "natty" = "$UBUNTU_VERSION" ]; then |
|
7 |
- echo "This script only works with oneiric and natty" |
|
8 |
- exit 1 |
|
9 |
- fi |
|
4 |
+if ! egrep -q "oneiric|natty" /etc/lsb-release; then |
|
5 |
+ echo "This script only works with ubuntu oneiric and natty" |
|
6 |
+ exit 1 |
|
10 | 7 |
fi |
11 | 8 |
|
12 | 9 |
# Keep track of the current directory |
... | ... |
@@ -21,6 +18,9 @@ source ./stackrc |
21 | 21 |
# Ubuntu distro to install |
22 | 22 |
DIST_NAME=${DIST_NAME:-oneiric} |
23 | 23 |
|
24 |
+# Configure how large the VM should be |
|
25 |
+GUEST_SIZE=${GUEST_SIZE:-10G} |
|
26 |
+ |
|
24 | 27 |
# exit on error to stop unexpected errors |
25 | 28 |
set -o errexit |
26 | 29 |
set -o xtrace |
... | ... |
@@ -33,7 +33,8 @@ if [ ! -e $TOP_DIR/localrc ]; then |
33 | 33 |
fi |
34 | 34 |
|
35 | 35 |
# Install deps if needed |
36 |
-dpkg -l kvm libvirt-bin kpartx || apt-get install -y --force-yes kvm libvirt-bin kpartx |
|
36 |
+DEPS="kvm libvirt-bin kpartx" |
|
37 |
+dpkg -l $DEPS || apt-get install -y --force-yes $DEPS |
|
37 | 38 |
|
38 | 39 |
# Where to store files and instances |
39 | 40 |
WORK_DIR=${WORK_DIR:-/opt/kvmstack} |
... | ... |
@@ -50,7 +51,7 @@ tarball=$image_dir/$(basename $uec_url) |
50 | 50 |
if [ ! -f $tarball ]; then |
51 | 51 |
curl $uec_url -o $tarball |
52 | 52 |
(cd $image_dir && tar -Sxvzf $tarball) |
53 |
- resize-part-image $image_dir/*.img 10G $image_dir/disk |
|
53 |
+ resize-part-image $image_dir/*.img $GUEST_SIZE $image_dir/disk |
|
54 | 54 |
cp $image_dir/*-vmlinuz-virtual $image_dir/kernel |
55 | 55 |
fi |
56 | 56 |
|
... | ... |
@@ -164,8 +165,8 @@ cp -r $TOOLS_DIR/uec $vm_dir/uec |
164 | 164 |
# set metadata |
165 | 165 |
cat > $vm_dir/uec/meta-data<<EOF |
166 | 166 |
hostname: $GUEST_NAME |
167 |
-instance-id: i-87018aed |
|
168 |
-instance-type: m1.large |
|
167 |
+instance-id: i-hop |
|
168 |
+instance-type: m1.ignore |
|
169 | 169 |
local-hostname: $GUEST_NAME.local |
170 | 170 |
EOF |
171 | 171 |
|