parameterize vm size, improve metadata, conditional for ubuntu version
This commit is contained in:
parent
955e5e73f2
commit
e3c47a351e
1 changed files with 11 additions and 10 deletions
|
@ -1,13 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Make sure that we have the proper version of ubuntu (only works on natty/oneiric)
|
# Make sure that we have the proper version of ubuntu (only works on natty/oneiric)
|
||||||
UBUNTU_VERSION=`cat /etc/lsb-release | grep CODENAME | sed 's/.*=//g'`
|
if ! egrep -q "oneiric|natty" /etc/lsb-release; then
|
||||||
if [ ! "oneiric" = "$UBUNTU_VERSION" ]; then
|
echo "This script only works with ubuntu oneiric and natty"
|
||||||
if [ ! "natty" = "$UBUNTU_VERSION" ]; then
|
|
||||||
echo "This script only works with oneiric and natty"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Keep track of the current directory
|
# Keep track of the current directory
|
||||||
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
||||||
|
@ -21,6 +18,9 @@ source ./stackrc
|
||||||
# Ubuntu distro to install
|
# Ubuntu distro to install
|
||||||
DIST_NAME=${DIST_NAME:-oneiric}
|
DIST_NAME=${DIST_NAME:-oneiric}
|
||||||
|
|
||||||
|
# Configure how large the VM should be
|
||||||
|
GUEST_SIZE=${GUEST_SIZE:-10G}
|
||||||
|
|
||||||
# exit on error to stop unexpected errors
|
# exit on error to stop unexpected errors
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o xtrace
|
set -o xtrace
|
||||||
|
@ -33,7 +33,8 @@ if [ ! -e $TOP_DIR/localrc ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install deps if needed
|
# Install deps if needed
|
||||||
dpkg -l kvm libvirt-bin kpartx || apt-get install -y --force-yes kvm libvirt-bin kpartx
|
DEPS="kvm libvirt-bin kpartx"
|
||||||
|
dpkg -l $DEPS || apt-get install -y --force-yes $DEPS
|
||||||
|
|
||||||
# Where to store files and instances
|
# Where to store files and instances
|
||||||
WORK_DIR=${WORK_DIR:-/opt/kvmstack}
|
WORK_DIR=${WORK_DIR:-/opt/kvmstack}
|
||||||
|
@ -50,7 +51,7 @@ tarball=$image_dir/$(basename $uec_url)
|
||||||
if [ ! -f $tarball ]; then
|
if [ ! -f $tarball ]; then
|
||||||
curl $uec_url -o $tarball
|
curl $uec_url -o $tarball
|
||||||
(cd $image_dir && tar -Sxvzf $tarball)
|
(cd $image_dir && tar -Sxvzf $tarball)
|
||||||
resize-part-image $image_dir/*.img 10G $image_dir/disk
|
resize-part-image $image_dir/*.img $GUEST_SIZE $image_dir/disk
|
||||||
cp $image_dir/*-vmlinuz-virtual $image_dir/kernel
|
cp $image_dir/*-vmlinuz-virtual $image_dir/kernel
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -164,8 +165,8 @@ cp -r $TOOLS_DIR/uec $vm_dir/uec
|
||||||
# set metadata
|
# set metadata
|
||||||
cat > $vm_dir/uec/meta-data<<EOF
|
cat > $vm_dir/uec/meta-data<<EOF
|
||||||
hostname: $GUEST_NAME
|
hostname: $GUEST_NAME
|
||||||
instance-id: i-87018aed
|
instance-id: i-hop
|
||||||
instance-type: m1.large
|
instance-type: m1.ignore
|
||||||
local-hostname: $GUEST_NAME.local
|
local-hostname: $GUEST_NAME.local
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue