Browse code

Build devstack images

Dean Troyer authored on 2011/09/30 06:15:23
Showing 1 changed files
... ...
@@ -1,9 +1,10 @@
1 1
 #!/bin/bash
2 2
 # build_pxe_boot.sh - Create a PXE boot environment
3 3
 #
4
-# build_pxe_boot.sh destdir
4
+# build_pxe_boot.sh [-k kernel-version] destdir
5 5
 #
6 6
 # Assumes syslinux is installed
7
+# Assumes devstack files are in `pwd`/pxe
7 8
 # Only needs to run as root if the destdir permissions require it
8 9
 
9 10
 UBUNTU_MIRROR=http://archive.ubuntu.com/ubuntu/dists/natty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64
... ...
@@ -12,8 +13,15 @@ MEMTEST_VER=4.10
12 12
 MEMTEST_BIN=memtest86+-${MEMTEST_VER}.bin
13 13
 MEMTEST_URL=http://www.memtest.org/download/${MEMTEST_VER}/
14 14
 
15
+KVER=`uname -r`
16
+if [ "$1" = "-k" ]; then
17
+    KVER=$2
18
+    shift;shift
19
+fi
20
+
15 21
 DEST_DIR=${1:-/tmp}/tftpboot
16 22
 OPWD=`pwd`
23
+PROGDIR=`dirname $0`
17 24
 
18 25
 mkdir -p $DEST_DIR/pxelinux.cfg
19 26
 cd $DEST_DIR
... ...
@@ -31,17 +39,42 @@ MENU TITLE PXE Boot Menu
31 31
 
32 32
 EOF
33 33
 
34
-# Get Ubuntu netboot
34
+# Setup devstack boot
35 35
 mkdir -p $DEST_DIR/ubuntu
36
-cd $DEST_DIR/ubuntu
37
-wget -N --quiet $UBUNTU_MIRROR/linux
38
-wget -N --quiet $UBUNTU_MIRROR/initrd.gz
36
+if [ ! -d $OPWD/pxe ]; then
37
+    mkdir -p $OPWD/pxe
38
+fi
39
+if [ ! -r $OPWD/pxe/vmlinuz-${KVER}-generic ]; then
40
+    if [ ! -r /boot/vmlinuz-${KVER}-generic ]; then
41
+        echo "No kernel found"
42
+    else
43
+        cp -p /boot/vmlinuz-${KVER}-generic $OPWD/pxe
44
+    fi
45
+fi
46
+cp -p $OPWD/pxe/vmlinuz-${KVER}-generic $DEST_DIR/ubuntu
47
+if [ ! -r $OPWD/pxe/stack-initrd.gz ]; then
48
+    $PROGDIR/build_pxe_ramdisk.sh $OPWD/pxe/stack-initrd.gz
49
+fi
50
+cp -p $OPWD/pxe/stack-initrd.gz $DEST_DIR/ubuntu
51
+cat >>$DEFAULT <<EOF
52
+
53
+LABEL devstack
54
+    MENU LABEL ^devstack
55
+    MENU DEFAULT
56
+    KERNEL ubuntu/vmlinuz-$KVER-generic
57
+    APPEND initrd=ubuntu/stack-initrd.gz ramdisk_size=2109600 root=/dev/ram0
58
+EOF
59
+
60
+# Get Ubuntu
61
+if [ -d $OPWD/pxe ]; then
62
+    cp -p $OPWD/pxe/natty-min-initrd.gz $DEST_DIR/ubuntu
63
+fi
39 64
 cat >>$DEFAULT <<EOF
40 65
 
41 66
 LABEL ubuntu
42
-	MENU LABEL Ubuntu Natty
43
-	KERNEL ubuntu/linux
44
-	APPEND initrd=ubuntu/initrd.gz
67
+    MENU LABEL ^Ubuntu Natty
68
+    KERNEL ubuntu/vmlinuz-$KVER-generic
69
+    APPEND initrd=ubuntu/natty-base-initrd.gz ramdisk_size=419600 root=/dev/ram0
45 70
 EOF
46 71
 
47 72
 # Get Memtest
... ...
@@ -53,7 +86,7 @@ fi
53 53
 cat >>$DEFAULT <<EOF
54 54
 
55 55
 LABEL memtest
56
-    MENU LABEL Memtest86+
56
+    MENU LABEL ^Memtest86+
57 57
     KERNEL $MEMTEST_BIN
58 58
 EOF
59 59
 
... ...
@@ -74,7 +107,7 @@ EOF
74 74
 cat >>$DEFAULT <<EOF
75 75
 
76 76
 LABEL local
77
-    MENU LABEL Local disk
77
+    MENU LABEL ^Local disk
78 78
     MENU DEFAULT
79 79
     LOCALBOOT 0
80 80
 EOF