Merge remote-tracking branch 'origin/master' into password_prompt

This commit is contained in:
Anthony Young 2011-10-13 11:45:07 -07:00
commit f8dfba1c73
8 changed files with 176 additions and 74 deletions

View file

@ -7,6 +7,8 @@ Tool to quickly deploy openstack dev environments.
* To make it easier for developers to dive into openstack so that they can productively contribute without having to understand every part of the system at once * To make it easier for developers to dive into openstack so that they can productively contribute without having to understand every part of the system at once
* To make it easy to prototype cross-project features * To make it easy to prototype cross-project features
Read more at http://devstack.org (built from the gh-pages branch)
Be sure to carefully read these scripts before you run them as they install software and may alter your networking configuration. Be sure to carefully read these scripts before you run them as they install software and may alter your networking configuration.
# To start a dev cloud on your local machine (installing on a dedicated vm is safer!): # To start a dev cloud on your local machine (installing on a dedicated vm is safer!):
@ -32,7 +34,6 @@ You can tweak environment variables by creating file name 'localrc' should you n
* Add python-novaclient cli support * Add python-novaclient cli support
* syslog * syslog
* allow rabbit connection to be specified via environment variables with sensible defaults
* Add volume support * Add volume support
* Add quantum support * Add quantum support

View file

@ -20,9 +20,6 @@
# Sanity Check # Sanity Check
# ============ # ============
# Record the start time. This allows us to print how long this script takes to run.
START_TIME=`python -c "import time; print time.time()"`
# Warn users who aren't on natty, but allow them to override check and attempt # Warn users who aren't on natty, but allow them to override check and attempt
# installation with ``FORCE=yes ./stack`` # installation with ``FORCE=yes ./stack``
if ! grep -q natty /etc/lsb-release; then if ! grep -q natty /etc/lsb-release; then
@ -53,40 +50,38 @@ TOP_DIR=$(cd $(dirname "$0") && pwd)
if [[ $EUID -eq 0 ]]; then if [[ $EUID -eq 0 ]]; then
echo "You are running this script as root." echo "You are running this script as root."
echo "In 10 seconds, we will create a user 'stack' and run as that user"
sleep 10
# since this script runs as a normal user, we need to give that user # since this script runs as a normal user, we need to give that user
# ability to run sudo # ability to run sudo
apt-get update apt-get update
apt-get install -qqy sudo apt-get install -y sudo
if ! getent passwd | grep -q stack; then if ! getent passwd stack >/dev/null; then
echo "Creating a user called stack" echo "Creating a user called stack"
useradd -U -G sudo -s /bin/bash -m stack useradd -U -G sudo -s /bin/bash -m stack
fi fi
echo "Giving stack user passwordless sudo priviledges" echo "Giving stack user passwordless sudo priviledges"
echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers # natty uec images sudoers does not have a '#includedir'. add one.
grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers ||
echo "#includedir /etc/sudoers.d" >> /etc/sudoers
( umask 226 && echo "stack ALL=(ALL) NOPASSWD:ALL" \
> /etc/sudoers.d/50_stack_sh )
echo "Copying files to stack user" echo "Copying files to stack user"
cp -r -f `pwd` /home/stack/ STACK_DIR="/home/stack/${PWD##*/}"
THIS_DIR=$(basename $(dirname $(readlink -f $0))) cp -r -f "$PWD" "$STACK_DIR"
chown -R stack /home/stack/$THIS_DIR chown -R stack "$STACK_DIR"
echo "Running the script as stack in 3 seconds..."
sleep 3
if [[ "$SHELL_AFTER_RUN" != "no" ]]; then if [[ "$SHELL_AFTER_RUN" != "no" ]]; then
exec su -c "cd /home/stack/$THIS_DIR/; bash stack.sh; bash" stack exec su -c "set -e; cd $STACK_DIR; bash stack.sh; bash" stack
else else
exec su -c "cd /home/stack/$THIS_DIR/; bash stack.sh" stack exec su -c "set -e; cd $STACK_DIR; bash stack.sh" stack
fi fi
exit 0 exit 1
fi fi
# So that errors don't compound we exit on any errors so you see only the
# first error that occured.
set -o errexit
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following allowing as the install occurs.
set -o xtrace
# Settings # Settings
# ======== # ========
@ -120,8 +115,6 @@ source ./stackrc
# Destination path for installation ``DEST`` # Destination path for installation ``DEST``
DEST=${DEST:-/opt/stack} DEST=${DEST:-/opt/stack}
sudo mkdir -p $DEST
sudo chown `whoami` $DEST
# Set the destination directories for openstack projects # Set the destination directories for openstack projects
NOVA_DIR=$DEST/nova NOVA_DIR=$DEST/nova
@ -261,6 +254,24 @@ read_password SERVICE_TOKEN "ENTER A SERVICE_TOKEN TO USE FOR THE SERVICE ADMIN
# Dash currently truncates usernames and passwords at 20 characters # Dash currently truncates usernames and passwords at 20 characters
read_password ADMIN_PASSWORD "ENTER A PASSWORD TO USE FOR DASH AND KEYSTONE (20 CHARS OR LESS)." read_password ADMIN_PASSWORD "ENTER A PASSWORD TO USE FOR DASH AND KEYSTONE (20 CHARS OR LESS)."
LOGFILE=${LOGFILE:-"$PWD/stack.sh.$$.log"}
(
# So that errors don't compound we exit on any errors so you see only the
# first error that occured.
trap failed ERR
failed() {
local r=$?
set +o xtrace
[ -n "$LOGFILE" ] && echo "${0##*/} failed: full log in $LOGFILE"
exit $r
}
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following along as the install occurs.
set -o xtrace
sudo mkdir -p $DEST
sudo chown `whoami` $DEST
# Install Packages # Install Packages
# ================ # ================
@ -269,6 +280,7 @@ read_password ADMIN_PASSWORD "ENTER A PASSWORD TO USE FOR DASH AND KEYSTONE (20
# install apt requirements # install apt requirements
sudo apt-get update
sudo apt-get install -qqy `cat $FILES/apts/* | cut -d\# -f1 | grep -Ev "mysql-server|rabbitmq-server"` sudo apt-get install -qqy `cat $FILES/apts/* | cut -d\# -f1 | grep -Ev "mysql-server|rabbitmq-server"`
# install python requirements # install python requirements
@ -347,6 +359,19 @@ mysql-server-5.1 mysql-server/root_password_again password $MYSQL_PASSWORD
mysql-server-5.1 mysql-server/start_on_boot boolean true mysql-server-5.1 mysql-server/start_on_boot boolean true
MYSQL_PRESEED 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 # Install and start mysql-server
sudo apt-get -y -q install mysql-server sudo apt-get -y -q install mysql-server
# Update the DB to give user $MYSQL_USER@% full control of the all databases: # Update the DB to give user $MYSQL_USER@% full control of the all databases:
@ -625,9 +650,8 @@ fi
# have to do a little more than that in our script. Since we add the group # have to do a little more than that in our script. Since we add the group
# ``libvirtd`` to our user in this script, when nova-compute is run it is # ``libvirtd`` to our user in this script, when nova-compute is run it is
# within the context of our original shell (so our groups won't be updated). # within the context of our original shell (so our groups won't be updated).
# We can send the command nova-compute to the ``newgrp`` command to execute # Use 'sg' to execute nova-compute as a member of the libvirtd group.
# in a specific context. screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_DIR/bin/nova-compute"
screen_it n-cpu "cd $NOVA_DIR && echo $NOVA_DIR/bin/nova-compute | newgrp libvirtd"
screen_it n-net "cd $NOVA_DIR && $NOVA_DIR/bin/nova-network" screen_it n-net "cd $NOVA_DIR && $NOVA_DIR/bin/nova-network"
screen_it n-sch "cd $NOVA_DIR && $NOVA_DIR/bin/nova-scheduler" screen_it n-sch "cd $NOVA_DIR && $NOVA_DIR/bin/nova-scheduler"
screen_it n-vnc "cd $NOVNC_DIR && ./utils/nova-wsproxy.py 6080 --web . --flagfile=../nova/bin/nova.conf" screen_it n-vnc "cd $NOVNC_DIR && ./utils/nova-wsproxy.py 6080 --web . --flagfile=../nova/bin/nova.conf"
@ -687,6 +711,16 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
fi fi
# Fin
# ===
) 2>&1 | tee "${LOGFILE}"
# Check that the left side of the above pipe succeeded
for ret in "${PIPESTATUS[@]}"; do [ $ret -eq 0 ] || exit $ret; done
(
# Using the cloud # Using the cloud
# =============== # ===============
@ -704,10 +738,7 @@ if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
echo "the password: $ADMIN_PASSWORD" echo "the password: $ADMIN_PASSWORD"
fi fi
# Fin # indicate how long this took to run (bash maintained variable 'SECONDS')
# === echo "stack.sh completed in $SECONDS seconds."
# End our timer and give a timing summary ) | tee -a "$LOGFILE"
END_TIME=`python -c "import time; print time.time()"`
ELAPSED=`python -c "print $END_TIME - $START_TIME"`
echo "stack.sh completed in $ELAPSED seconds."

View file

@ -4,15 +4,8 @@
# build_pxe_boot.sh [-k kernel-version] destdir # build_pxe_boot.sh [-k kernel-version] destdir
# #
# Assumes syslinux is installed # Assumes syslinux is installed
# Assumes devstack files are in `pwd`/pxe
# Only needs to run as root if the destdir permissions require it # 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` KVER=`uname -r`
if [ "$1" = "-k" ]; then if [ "$1" = "-k" ]; then
KVER=$2 KVER=$2
@ -30,8 +23,8 @@ for i in memdisk menu.c32 pxelinux.0; do
cp -p /usr/lib/syslinux/$i $DEST_DIR cp -p /usr/lib/syslinux/$i $DEST_DIR
done done
DEFAULT=$DEST_DIR/pxelinux.cfg/default CFG=$DEST_DIR/pxelinux.cfg/default
cat >$DEFAULT <<EOF cat >$CFG <<EOF
default menu.c32 default menu.c32
prompt 0 prompt 0
timeout 0 timeout 0
@ -56,10 +49,10 @@ fi
cp -p $PXEDIR/vmlinuz-${KVER} $DEST_DIR/ubuntu cp -p $PXEDIR/vmlinuz-${KVER} $DEST_DIR/ubuntu
if [ ! -r $PXEDIR/stack-initrd.gz ]; then if [ ! -r $PXEDIR/stack-initrd.gz ]; then
cd $OPWD cd $OPWD
sudo $PROGDIR/build_pxe_ramdisk.sh $PXEDIR/stack-initrd.gz sudo $PROGDIR/build_ramdisk.sh $PXEDIR/stack-initrd.gz
fi fi
cp -p $PXEDIR/stack-initrd.gz $DEST_DIR/ubuntu cp -p $PXEDIR/stack-initrd.gz $DEST_DIR/ubuntu
cat >>$DEFAULT <<EOF cat >>$CFG <<EOF
LABEL devstack LABEL devstack
MENU LABEL ^devstack MENU LABEL ^devstack
@ -69,48 +62,21 @@ LABEL devstack
EOF EOF
# Get Ubuntu # 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 cp -p $PXEDIR/natty-base-initrd.gz $DEST_DIR/ubuntu
fi cat >>$CFG <<EOF
cat >>$DEFAULT <<EOF
LABEL ubuntu LABEL ubuntu
MENU LABEL ^Ubuntu Natty MENU LABEL ^Ubuntu Natty
KERNEL ubuntu/vmlinuz-$KVER KERNEL ubuntu/vmlinuz-$KVER
APPEND initrd=ubuntu/natty-base-initrd.gz ramdisk_size=419600 root=/dev/ram0 APPEND initrd=ubuntu/natty-base-initrd.gz ramdisk_size=419600 root=/dev/ram0
EOF EOF
# Get Memtest
cd $DEST_DIR
if [ ! -r $MEMTEST_BIN ]; then
wget -N --quiet ${MEMTEST_URL}/${MEMTEST_BIN}.gz
gunzip $MEMTEST_BIN
fi 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 # Local disk boot
cat >>$DEFAULT <<EOF cat >>$CFG <<EOF
LABEL local LABEL local
MENU LABEL ^Local disk MENU LABEL ^Local disk
MENU DEFAULT
LOCALBOOT 0 LOCALBOOT 0
EOF EOF

View file

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
# build_ramdisk.sh - Build RAM disk images
if [ ! "$#" -eq "1" ]; then if [ ! "$#" -eq "1" ]; then
echo "$0 builds a gziped natty openstack install" echo "$0 builds a gziped natty openstack install"

103
tools/build_usb_boot.sh Executable file
View file

@ -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