Browse code

Merge "XenAPI: Move some boot-time functions to install-time"

Jenkins authored on 2015/02/17 06:49:17
Showing 5 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,14 @@
0
+#!/bin/bash
1
+set -eux
2
+
3
+# Need to set barrier=0 to avoid a Xen bug
4
+# https://bugs.launchpad.net/ubuntu/+source/linux/+bug/824089
5
+sed -i -e 's/errors=/barrier=0,errors=/' /etc/fstab
6
+
7
+# Allow root to login with a password
8
+sed -i -e 's/.*PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
9
+
10
+# Install the XenServer tools so IP addresses are reported
11
+wget --no-proxy @XS_TOOLS_URL@ -O /root/tools.deb
12
+dpkg -i /root/tools.deb
13
+rm /root/tools.deb
... ...
@@ -331,10 +331,11 @@ d-i apt-setup/backports boolean true
331 331
 tasksel tasksel/first multiselect openssh-server
332 332
 
333 333
 # Individual additional packages to install
334
-#d-i pkgsel/include string openssh-server build-essential
334
+d-i pkgsel/include string cracklib-runtime curl wget ssh openssh-server tcpdump ethtool git sudo python-netaddr coreutils
335
+
335 336
 # Whether to upgrade packages after debootstrap.
336 337
 # Allowed values: none, safe-upgrade, full-upgrade
337
-#d-i pkgsel/upgrade select none
338
+d-i pkgsel/upgrade select safe-upgrade
338 339
 
339 340
 # Language pack selection
340 341
 #d-i pkgsel/language-packs multiselect de, en, zh
... ...
@@ -467,4 +468,4 @@ xserver-xorg xserver-xorg/config/monitor/mode-list \
467 467
 # still a usable /target directory. You can chroot to /target and use it
468 468
 # directly, or use the apt-install and in-target commands to easily install
469 469
 # packages and run commands in the target system.
470
-#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh
470
+d-i preseed/late_command string
... ...
@@ -178,12 +178,32 @@ if [ -z "$templateuuid" ]; then
178 178
     PRESEED_URL=${PRESEED_URL:-""}
179 179
     if [ -z "$PRESEED_URL" ]; then
180 180
         PRESEED_URL="${HOST_IP}/devstackubuntupreseed.cfg"
181
+
181 182
         HTTP_SERVER_LOCATION="/opt/xensource/www"
182 183
         if [ ! -e $HTTP_SERVER_LOCATION ]; then
183 184
             HTTP_SERVER_LOCATION="/var/www/html"
184 185
             mkdir -p $HTTP_SERVER_LOCATION
185 186
         fi
187
+
188
+        # Copy the tools DEB to the XS web server
189
+        XS_TOOLS_URL="https://github.com/downloads/citrix-openstack/warehouse/xe-guest-utilities_5.6.100-651_amd64.deb"
190
+        ISO_DIR="/opt/xensource/packages/iso"
191
+        XS_TOOLS_FILE_NAME="xs-tools.deb"
192
+        XS_TOOLS_PATH="/root/$XS_TOOLS_FILE_NAME"
193
+        if [ -e "$ISO_DIR" ]; then
194
+            TOOLS_ISO=$(ls -1 $ISO_DIR/xs-tools-*.iso | head -1)
195
+            TMP_DIR=/tmp/temp.$RANDOM
196
+            mkdir -p $TMP_DIR
197
+            mount -o loop $TOOLS_ISO $TMP_DIR
198
+            DEB_FILE=$(ls $TMP_DIR/Linux/*amd64.deb)
199
+            cp $DEB_FILE $HTTP_SERVER_LOCATION
200
+            umount $TMP_DIR
201
+            rmdir $TMP_DIR
202
+            XS_TOOLS_URL=${HOST_IP}/$(basename $DEB_FILE)
203
+        fi
204
+
186 205
         cp -f $THIS_DIR/devstackubuntupreseed.cfg $HTTP_SERVER_LOCATION
206
+        cp -f $THIS_DIR/devstackubuntu_latecommand.sh $HTTP_SERVER_LOCATION/latecommand.sh
187 207
 
188 208
         sed \
189 209
             -e "s,\(d-i mirror/http/hostname string\).*,\1 $UBUNTU_INST_HTTP_HOSTNAME,g" \
... ...
@@ -191,7 +211,12 @@ if [ -z "$templateuuid" ]; then
191 191
             -e "s,\(d-i mirror/http/proxy string\).*,\1 $UBUNTU_INST_HTTP_PROXY,g" \
192 192
             -e "s,\(d-i passwd/root-password password\).*,\1 $GUEST_PASSWORD,g" \
193 193
             -e "s,\(d-i passwd/root-password-again password\).*,\1 $GUEST_PASSWORD,g" \
194
+            -e "s,\(d-i preseed/late_command string\).*,\1 in-target mkdir -p /tmp; in-target wget --no-proxy ${HOST_IP}/latecommand.sh -O /root/latecommand.sh; in-target bash /root/latecommand.sh,g" \
194 195
             -i "${HTTP_SERVER_LOCATION}/devstackubuntupreseed.cfg"
196
+
197
+        sed \
198
+            -e "s,@XS_TOOLS_URL@,$XS_TOOLS_URL,g" \
199
+            -i "${HTTP_SERVER_LOCATION}/latecommand.sh"
195 200
     fi
196 201
 
197 202
     # Update the template
... ...
@@ -16,9 +16,8 @@ set -o xtrace
16 16
 
17 17
 # Configurable nuggets
18 18
 GUEST_PASSWORD="$1"
19
-XS_TOOLS_PATH="$2"
20
-STACK_USER="$3"
21
-DOMZERO_USER="$4"
19
+STACK_USER="$2"
20
+DOMZERO_USER="$3"
22 21
 
23 22
 
24 23
 function setup_domzero_user {
... ...
@@ -70,16 +69,6 @@ EOF
70 70
 
71 71
 }
72 72
 
73
-# Install basics
74
-apt-get update
75
-apt-get install -y cracklib-runtime curl wget ssh openssh-server tcpdump ethtool
76
-apt-get install -y git sudo python-netaddr coreutils
77
-
78
-# Install XenServer guest utilities
79
-dpkg -i $XS_TOOLS_PATH
80
-update-rc.d -f xe-linux-distribution remove
81
-update-rc.d xe-linux-distribution defaults
82
-
83 73
 # Make a small cracklib dictionary, so that passwd still works, but we don't
84 74
 # have the big dictionary.
85 75
 mkdir -p /usr/share/cracklib
... ...
@@ -46,28 +46,6 @@ if [ ! -d $STAGING_DIR/etc ]; then
46 46
     exit 1
47 47
 fi
48 48
 
49
-# Copy XenServer tools deb into the VM
50
-ISO_DIR="/opt/xensource/packages/iso"
51
-XS_TOOLS_FILE_NAME="xs-tools.deb"
52
-XS_TOOLS_PATH="/root/$XS_TOOLS_FILE_NAME"
53
-if [ -e "$ISO_DIR" ]; then
54
-    TOOLS_ISO=$(ls -1 $ISO_DIR/xs-tools-*.iso | head -1)
55
-    TMP_DIR=/tmp/temp.$RANDOM
56
-    mkdir -p $TMP_DIR
57
-    mount -o loop $TOOLS_ISO $TMP_DIR
58
-    DEB_FILE=$(ls $TMP_DIR/Linux/*amd64.deb)
59
-    echo "Copying XenServer tools into VM from: $DEB_FILE"
60
-    cp $DEB_FILE "${STAGING_DIR}${XS_TOOLS_PATH}"
61
-    umount $TMP_DIR
62
-    rm -rf $TMP_DIR
63
-else
64
-    echo "WARNING: no XenServer tools found, falling back to 5.6 tools"
65
-    TOOLS_URL="https://github.com/downloads/citrix-openstack/warehouse/xe-guest-utilities_5.6.100-651_amd64.deb"
66
-    curl --no-sessionid -L -o "$XS_TOOLS_FILE_NAME" $TOOLS_URL
67
-    cp $XS_TOOLS_FILE_NAME "${STAGING_DIR}${XS_TOOLS_PATH}"
68
-    rm -rf $XS_TOOLS_FILE_NAME
69
-fi
70
-
71 49
 # Copy prepare_guest.sh to VM
72 50
 mkdir -p $STAGING_DIR/opt/stack/
73 51
 cp $TOP_DIR/prepare_guest.sh $STAGING_DIR/opt/stack/prepare_guest.sh
... ...
@@ -79,14 +57,10 @@ cp $STAGING_DIR/etc/rc.local $STAGING_DIR/etc/rc.local.preparebackup
79 79
 cat <<EOF >$STAGING_DIR/etc/rc.local
80 80
 #!/bin/sh -e
81 81
 bash /opt/stack/prepare_guest.sh \\
82
-    "$GUEST_PASSWORD" "$XS_TOOLS_PATH" "$STACK_USER" "$DOMZERO_USER" \\
82
+    "$GUEST_PASSWORD" "$STACK_USER" "$DOMZERO_USER" \\
83 83
     > /opt/stack/prepare_guest.log 2>&1
84 84
 EOF
85 85
 
86
-# Need to set barrier=0 to avoid a Xen bug
87
-# https://bugs.launchpad.net/ubuntu/+source/linux/+bug/824089
88
-sed -i -e 's/errors=/barrier=0,errors=/' $STAGING_DIR/etc/fstab
89
-
90 86
 # Update ubuntu repositories
91 87
 cat > $STAGING_DIR/etc/apt/sources.list << EOF
92 88
 deb http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE} main restricted