diff --git a/build_pxe_boot.sh b/build_pxe_boot.sh new file mode 100755 index 0000000..2c4cc0e --- /dev/null +++ b/build_pxe_boot.sh @@ -0,0 +1,115 @@ +#!/bin/bash -e +# build_pxe_boot.sh - Create a PXE boot environment +# +# 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 + shift;shift +fi + +DEST_DIR=${1:-/tmp}/tftpboot +OPWD=`pwd` +PROGDIR=`dirname $0` + +mkdir -p $DEST_DIR/pxelinux.cfg +cd $DEST_DIR +for i in memdisk menu.c32 pxelinux.0; do + cp -p /usr/lib/syslinux/$i $DEST_DIR +done + +DEFAULT=$DEST_DIR/pxelinux.cfg/default +cat >$DEFAULT <>$DEFAULT <>$DEFAULT <>$DEFAULT <>$DEFAULT <>$DEFAULT <&2 - echo "You should run this script as the user you wish openstack to run as" 1>&2 - echo "The user will need to be a sudoer (without password)" 1>&2 - exit 1 + echo "You are running this script as root." + apt-get update + apt-get install -y sudo + if ! getent passwd | grep -q stack; then + echo "Creating a user called stack" + useradd -g sudo -s /bin/bash -m stack + fi + echo "Making sure stack has passwordless sudo" + sed -i "/^%sudo/ { / ALL/ { s/ ALL/ NOPASSWD:ALL/ }}" /etc/sudoers + echo "Copying files to stack user" + cp -r -f `pwd` /home/stack/ + THIS_DIR=$(basename $(dirname $(readlink -f $0))) + chown -R stack:sudo /home/stack/$THIS_DIR + echo "Running the script as stack in 3 seconds..." + sleep 3 + exec su -c "cd /home/stack/$THIS_DIR/; bash stack.sh; bash" stack + exit 0 fi