Merge remote-tracking branch 'upstream/master' into rcb-master
diff --git a/stack.sh b/stack.sh
index 38560e6..0b34790 100755
--- a/stack.sh
+++ b/stack.sh
@@ -318,6 +318,19 @@
 mysql-server-5.1 mysql-server/start_on_boot boolean true
 MYSQL_PRESEED
 
+    # while ``.my.cnf`` is not needed for openstack to function, it is useful
+    # as it allows you to access the mysql databases via ``mysql nova`` instead
+    # of having to specify the username/password each time.
+    if [[ ! -e $HOME/.my.cnf ]]; then
+        cat <<EOF >$HOME/.my.cnf
+[client]
+user=$MYSQL_USER
+password=$MYSQL_PASS    
+host=$MYSQL_HOST
+EOF
+        chmod 0600 $HOME/.my.cnf
+    fi
+
     # Install and start mysql-server
     sudo apt-get -y -q install mysql-server
     # Update the DB to give user ‘$MYSQL_USER’@’%’ full control of the all databases:
diff --git a/build_nfs.sh b/tools/build_nfs.sh
similarity index 100%
rename from build_nfs.sh
rename to tools/build_nfs.sh
diff --git a/build_pxe_boot.sh b/tools/build_pxe_boot.sh
similarity index 60%
rename from build_pxe_boot.sh
rename to tools/build_pxe_boot.sh
index 4feb14d..0653664 100755
--- a/build_pxe_boot.sh
+++ b/tools/build_pxe_boot.sh
@@ -4,15 +4,8 @@
 # build_pxe_boot.sh [-k kernel-version] destdir
 #
 # Assumes syslinux is installed
-# Assumes devstack files are in `pwd`/pxe
 # Only needs to run as root if the destdir permissions require it
 
-UBUNTU_MIRROR=http://archive.ubuntu.com/ubuntu/dists/natty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64
-
-MEMTEST_VER=4.10
-MEMTEST_BIN=memtest86+-${MEMTEST_VER}.bin
-MEMTEST_URL=http://www.memtest.org/download/${MEMTEST_VER}/
-
 KVER=`uname -r`
 if [ "$1" = "-k" ]; then
     KVER=$2
@@ -30,8 +23,8 @@
 	cp -p /usr/lib/syslinux/$i $DEST_DIR
 done
 
-DEFAULT=$DEST_DIR/pxelinux.cfg/default
-cat >$DEFAULT <<EOF
+CFG=$DEST_DIR/pxelinux.cfg/default
+cat >$CFG <<EOF
 default menu.c32
 prompt 0
 timeout 0
@@ -56,10 +49,10 @@
 cp -p $PXEDIR/vmlinuz-${KVER} $DEST_DIR/ubuntu
 if [ ! -r $PXEDIR/stack-initrd.gz ]; then
     cd $OPWD
-    sudo $PROGDIR/build_pxe_ramdisk.sh $PXEDIR/stack-initrd.gz
+    sudo $PROGDIR/build_ramdisk.sh $PXEDIR/stack-initrd.gz
 fi
 cp -p $PXEDIR/stack-initrd.gz $DEST_DIR/ubuntu
-cat >>$DEFAULT <<EOF
+cat >>$CFG <<EOF
 
 LABEL devstack
     MENU LABEL ^devstack
@@ -69,48 +62,21 @@
 EOF
 
 # Get Ubuntu
-if [ -d $PXEDIR ]; then
+if [ -d $PXEDIR -a -r $PXEDIR/natty-base-initrd.gz ]; then
     cp -p $PXEDIR/natty-base-initrd.gz $DEST_DIR/ubuntu
-fi
-cat >>$DEFAULT <<EOF
+    cat >>$CFG <<EOF
 
 LABEL ubuntu
     MENU LABEL ^Ubuntu Natty
     KERNEL ubuntu/vmlinuz-$KVER
     APPEND initrd=ubuntu/natty-base-initrd.gz ramdisk_size=419600 root=/dev/ram0
 EOF
-
-# Get Memtest
-cd $DEST_DIR
-if [ ! -r $MEMTEST_BIN ]; then
-    wget -N --quiet ${MEMTEST_URL}/${MEMTEST_BIN}.gz
-    gunzip $MEMTEST_BIN
 fi
-cat >>$DEFAULT <<EOF
-
-LABEL memtest
-    MENU LABEL ^Memtest86+
-    KERNEL $MEMTEST_BIN
-EOF
-
-# Get FreeDOS
-mkdir -p $DEST_DIR/freedos
-cd $DEST_DIR/freedos
-wget -N --quiet http://www.fdos.org/bootdisks/autogen/FDSTD.288.gz
-gunzip -f FDSTD.288.gz
-cat >>$DEFAULT <<EOF
-
-LABEL freedos
-	MENU LABEL ^FreeDOS bootdisk
-	KERNEL memdisk
-	APPEND initrd=freedos/FDSTD.288
-EOF
 
 # Local disk boot
-cat >>$DEFAULT <<EOF
+cat >>$CFG <<EOF
 
 LABEL local
     MENU LABEL ^Local disk
-    MENU DEFAULT
     LOCALBOOT 0
 EOF
diff --git a/build_pxe_ramdisk.sh b/tools/build_ramdisk.sh
similarity index 98%
rename from build_pxe_ramdisk.sh
rename to tools/build_ramdisk.sh
index a01656b..63d37a9 100755
--- a/build_pxe_ramdisk.sh
+++ b/tools/build_ramdisk.sh
@@ -1,4 +1,5 @@
 #!/bin/bash
+# build_ramdisk.sh - Build RAM disk images
 
 if [ ! "$#" -eq "1" ]; then
     echo "$0 builds a gziped natty openstack install"
diff --git a/tools/build_usb_boot.sh b/tools/build_usb_boot.sh
new file mode 100755
index 0000000..ac49848
--- /dev/null
+++ b/tools/build_usb_boot.sh
@@ -0,0 +1,103 @@
+#!/bin/bash -e
+# build_usb_boot.sh - Create a syslinux boot environment
+#
+# build_usb_boot.sh [-k kernel-version] destdev
+#
+# Assumes syslinux is installed
+# Needs to run as root
+
+KVER=`uname -r`
+if [ "$1" = "-k" ]; then
+    KVER=$2
+    shift;shift
+fi
+
+DEST_DIR=${1:-/tmp/syslinux-boot}
+PXEDIR=${PXEDIR:-/var/cache/devstack/pxe}
+OPWD=`pwd`
+PROGDIR=`dirname $0`
+
+if [ -b $DEST_DIR ]; then
+    # We have a block device, install syslinux and mount it
+    DEST_DEV=$DEST_DIR
+    DEST_DIR=`mktemp -d mntXXXXXX`
+
+    # Install syslinux on the device
+    syslinux --install --directory syslinux $DEST_DEV
+
+    mount $DEST_DEV $DEST_DIR
+else
+    # We have a directory (for sanity checking output)
+	DEST_DEV=""
+	if [ ! -d $DEST_DIR/syslinux ]; then
+	    mkdir -p $DEST_DIR/syslinux
+	fi
+fi
+
+# Get some more stuff from syslinux
+for i in memdisk menu.c32; do
+	cp -p /usr/lib/syslinux/$i $DEST_DIR/syslinux
+done
+
+CFG=$DEST_DIR/syslinux/syslinux.cfg
+cat >$CFG <<EOF
+default /syslinux/menu.c32
+prompt 0
+timeout 0
+
+MENU TITLE Boot Menu
+
+EOF
+
+# Setup devstack boot
+mkdir -p $DEST_DIR/ubuntu
+if [ ! -d $PXEDIR ]; then
+    mkdir -p $PXEDIR
+fi
+if [ ! -r $PXEDIR/vmlinuz-${KVER} ]; then
+    sudo chmod 644 /boot/vmlinuz-${KVER}
+    if [ ! -r /boot/vmlinuz-${KVER} ]; then
+        echo "No kernel found"
+    else
+        cp -p /boot/vmlinuz-${KVER} $PXEDIR
+    fi
+fi
+cp -p $PXEDIR/vmlinuz-${KVER} $DEST_DIR/ubuntu
+if [ ! -r $PXEDIR/stack-initrd.gz ]; then
+    cd $OPWD
+    sudo $PROGDIR/build_ramdisk.sh $PXEDIR/stack-initrd.gz
+fi
+cp -p $PXEDIR/stack-initrd.gz $DEST_DIR/ubuntu
+cat >>$CFG <<EOF
+
+LABEL devstack
+    MENU LABEL ^devstack
+    MENU DEFAULT
+    KERNEL /ubuntu/vmlinuz-$KVER
+    APPEND initrd=/ubuntu/stack-initrd.gz ramdisk_size=2109600 root=/dev/ram0
+EOF
+
+# Get Ubuntu
+if [ -d $PXEDIR -a -r $PXEDIR/natty-base-initrd.gz ]; then
+    cp -p $PXEDIR/natty-base-initrd.gz $DEST_DIR/ubuntu
+    cat >>$CFG <<EOF
+
+LABEL ubuntu
+    MENU LABEL ^Ubuntu Natty
+    KERNEL /ubuntu/vmlinuz-$KVER
+    APPEND initrd=/ubuntu/natty-base-initrd.gz ramdisk_size=419600 root=/dev/ram0
+EOF
+fi
+
+# Local disk boot
+cat >>$CFG <<EOF
+
+LABEL local
+    MENU LABEL ^Local disk
+    LOCALBOOT 0
+EOF
+
+if [ -n "$DEST_DEV" ]; then
+    umount $DEST_DIR
+    rmdir $DEST_DIR
+fi
diff --git a/make_image.sh b/tools/make_image.sh
similarity index 100%
rename from make_image.sh
rename to tools/make_image.sh
diff --git a/upload_image.sh b/tools/upload_image.sh
similarity index 100%
rename from upload_image.sh
rename to tools/upload_image.sh