blob: 7c6dec4f30a24fd01f07140580264cf824474d7d [file] [log] [blame]
John Garbuttdaadf742012-04-27 18:28:28 +01001#!/bin/bash
2
3# This script is run by install_os_domU.sh
4#
5# Parameters:
6# - $GUEST_NAME - hostname for the DomU VM
7#
8# It modifies the ubuntu image created by install_os_domU.sh
9#
10# This script is responsible for cusomtizing the fresh ubuntu
11# image so on boot it runs the prepare_guest.sh script
12# that modifies the VM so it is ready to run stack.sh.
13# It does this by mounting the disk image of the VM.
14#
15# The resultant image is started by install_os_domU.sh,
16# and once the VM has shutdown, build_xva.sh is run
17
18# Exit on errors
19set -o errexit
20# Echo commands
21set -o xtrace
22
23# This directory
24TOP_DIR=$(cd $(dirname "$0") && pwd)
25
26# Include onexit commands
27. $TOP_DIR/scripts/on_exit.sh
28
29# Source params - override xenrc params in your localrc to suite your taste
30source xenrc
31
32#
33# Parameters
34#
35GUEST_NAME="$1"
36
37# Mount the VDI
38STAGING_DIR=$($TOP_DIR/scripts/manage-vdi open $GUEST_NAME 0 1 | grep -o "/tmp/tmp.[[:alnum:]]*")
39add_on_exit "$TOP_DIR/scripts/manage-vdi close $GUEST_NAME 0 1"
40
41# Make sure we have a stage
42if [ ! -d $STAGING_DIR/etc ]; then
43 echo "Stage is not properly set up!"
44 exit 1
45fi
46
47# Copy prepare_guest.sh to VM
48mkdir -p $STAGING_DIR/opt/stack/
49cp $TOP_DIR/prepare_guest.sh $STAGING_DIR/opt/stack/prepare_guest.sh
50
51# backup rc.local
52cp $STAGING_DIR/etc/rc.local $STAGING_DIR/etc/rc.local.preparebackup
53
54# run prepare_guest.sh on boot
55cat <<EOF >$STAGING_DIR/etc/rc.local
56GUEST_PASSWORD=$GUEST_PASSWORD STAGING_DIR=/ DO_TGZ=0 bash /opt/stack/prepare_guest.sh > /opt/stack/prepare_guest.log 2>&1
57EOF