|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -set -e |
4 | | - |
5 | | -declare -a on_exit_hooks |
6 | | - |
7 | | -on_exit() |
8 | | -{ |
9 | | - for i in $(seq $((${#on_exit_hooks[*]} - 1)) -1 0) |
10 | | - do |
11 | | - eval "${on_exit_hooks[$i]}" |
12 | | - done |
13 | | -} |
14 | | - |
15 | | -add_on_exit() |
16 | | -{ |
17 | | - local n=${#on_exit_hooks[*]} |
18 | | - on_exit_hooks[$n]="$*" |
19 | | - if [[ $n -eq 0 ]] |
20 | | - then |
21 | | - trap on_exit EXIT |
22 | | - fi |
23 | | -} |
24 | | - |
25 | | -# Abort if localrc is not set |
26 | | -if [ ! -e ../../localrc ]; then |
27 | | - echo "You must have a localrc with ALL necessary passwords defined before proceeding." |
28 | | - echo "See the xen README for required passwords." |
29 | | - exit 1 |
30 | | -fi |
| 3 | +# This script is run by install_os_domU.sh |
| 4 | +# |
| 5 | +# It modifies the ubuntu image created by install_os_domU.sh |
| 6 | +# and previously moodified by prepare_guest_template.sh |
| 7 | +# |
| 8 | +# This script is responsible for: |
| 9 | +# - pushing in the DevStack code |
| 10 | +# - creating run.sh, to run the code on boot |
| 11 | +# It does this by mounting the disk image of the VM. |
| 12 | +# |
| 13 | +# The resultant image is then templated and started |
| 14 | +# by install_os_domU.sh |
| 15 | + |
| 16 | +# Exit on errors |
| 17 | +set -o errexit |
| 18 | +# Echo commands |
| 19 | +set -o xtrace |
31 | 20 |
|
32 | 21 | # This directory |
33 | 22 | TOP_DIR=$(cd $(dirname "$0") && pwd) |
34 | 23 |
|
| 24 | +# Include onexit commands |
| 25 | +. $TOP_DIR/scripts/on_exit.sh |
| 26 | + |
35 | 27 | # Source params - override xenrc params in your localrc to suite your taste |
36 | 28 | source xenrc |
37 | 29 |
|
38 | | -# Echo commands |
39 | | -set -o xtrace |
40 | | - |
| 30 | +# |
| 31 | +# Parameters |
| 32 | +# |
41 | 33 | GUEST_NAME="$1" |
42 | 34 |
|
43 | | -# Directory where we stage the build |
| 35 | +# |
| 36 | +# Mount the VDI |
| 37 | +# |
44 | 38 | STAGING_DIR=$($TOP_DIR/scripts/manage-vdi open $GUEST_NAME 0 1 | grep -o "/tmp/tmp.[[:alnum:]]*") |
45 | 39 | add_on_exit "$TOP_DIR/scripts/manage-vdi close $GUEST_NAME 0 1" |
46 | 40 |
|
@@ -76,7 +70,7 @@ cd $TOP_DIR |
76 | 70 | cat <<EOF >$STAGING_DIR/etc/rc.local |
77 | 71 | # network restart required for getting the right gateway |
78 | 72 | /etc/init.d/networking restart |
79 | | -GUEST_PASSWORD=$GUEST_PASSWORD STAGING_DIR=/ DO_TGZ=0 bash /opt/stack/devstack/tools/xen/prepare_guest.sh > /opt/stack/prepare_guest.log 2>&1 |
| 73 | +chown -R stack /opt/stack |
80 | 74 | su -c "/opt/stack/run.sh > /opt/stack/run.sh.log 2>&1" stack |
81 | 75 | exit 0 |
82 | 76 | EOF |
|
85 | 79 | echo $GUEST_NAME > $STAGING_DIR/etc/hostname |
86 | 80 |
|
87 | 81 | # Hostname must resolve for rabbit |
| 82 | +HOSTS_FILE_IP=$PUB_IP |
| 83 | +if [ $MGT_IP != "dhcp" ]; then |
| 84 | + HOSTS_FILE_IP=$MGT_IP |
| 85 | +fi |
88 | 86 | cat <<EOF >$STAGING_DIR/etc/hosts |
89 | | -$MGT_IP $GUEST_NAME |
| 87 | +$HOSTS_FILE_IP $GUEST_NAME |
90 | 88 | 127.0.0.1 localhost localhost.localdomain |
91 | 89 | EOF |
92 | 90 |
|
@@ -142,8 +140,6 @@ cat <<EOF >$STAGING_DIR/opt/stack/run.sh |
142 | 140 | #!/bin/bash |
143 | 141 | cd /opt/stack/devstack |
144 | 142 | killall screen |
145 | | -UPLOAD_LEGACY_TTY=yes HOST_IP=$PUB_IP VIRT_DRIVER=xenserver FORCE=yes MULTI_HOST=$MULTI_HOST HOST_IP_IFACE=$HOST_IP_IFACE $STACKSH_PARAMS ./stack.sh |
| 143 | +VIRT_DRIVER=xenserver FORCE=yes MULTI_HOST=$MULTI_HOST HOST_IP_IFACE=$HOST_IP_IFACE $STACKSH_PARAMS ./stack.sh |
146 | 144 | EOF |
147 | 145 | chmod 755 $STAGING_DIR/opt/stack/run.sh |
148 | | - |
149 | | -echo "Done" |
0 commit comments