Merge pull request #16 from cloudbuilders/opt_stack

install into /opt/stack instead of /opt by default
This commit is contained in:
sleepsonthefloor 2011-09-26 23:39:09 -07:00
commit f446f5154f
4 changed files with 42 additions and 31 deletions

View file

@ -22,6 +22,7 @@ CONTAINER_NETMASK=${CONTAINER_NETMASK:-255.255.255.0}
CONTAINER_GATEWAY=${CONTAINER_GATEWAY:-192.168.1.1} CONTAINER_GATEWAY=${CONTAINER_GATEWAY:-192.168.1.1}
NAMESERVER=${NAMESERVER:-$CONTAINER_GATEWAY} NAMESERVER=${NAMESERVER:-$CONTAINER_GATEWAY}
COPYENV=${COPYENV:-1} COPYENV=${COPYENV:-1}
DEST=${DEST:-/opt/stack}
# Param string to pass to stack.sh. Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova" # Param string to pass to stack.sh. Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova"
STACKSH_PARAMS=${STACKSH_PARAMS:-} STACKSH_PARAMS=${STACKSH_PARAMS:-}
@ -94,21 +95,27 @@ if [ ! -d $CACHEDIR ]; then
chroot $CACHEDIR pip install `cat files/pips/*` chroot $CACHEDIR pip install `cat files/pips/*`
fi fi
# Clean out code repos if directed to do so
if [ "$CLEAN" = "1" ]; then
rm -rf $CACHEDIR/$DEST
fi
# Cache openstack code # Cache openstack code
git_clone $NOVA_REPO $CACHEDIR/opt/nova $NOVA_BRANCH mkdir -p $CACHEDIR/$DEST
git_clone $GLANCE_REPO $CACHEDIR/opt/glance $GLANCE_BRANCH git_clone $NOVA_REPO $CACHEDIR/$DEST/nova $NOVA_BRANCH
git_clone $KEYSTONE_REPO $CACHEDIR/opt/keystone $KEYSTONE_BRANCH git_clone $GLANCE_REPO $CACHEDIR/$DEST/glance $GLANCE_BRANCH
git_clone $NOVNC_REPO $CACHEDIR/opt/novnc $NOVNC_BRANCH git_clone $KEYSTONE_REPO $CACHEDIR/$DESTkeystone $KEYSTONE_BRANCH
git_clone $DASH_REPO $CACHEDIR/opt/dash $DASH_BRANCH $DASH_TAG git_clone $NOVNC_REPO $CACHEDIR/$DEST/novnc $NOVNC_BRANCH
git_clone $NIXON_REPO $CACHEDIR/opt/nixon $NIXON_BRANCH git_clone $DASH_REPO $CACHEDIR/$DEST/dash $DASH_BRANCH $DASH_TAG
git_clone $NOVACLIENT_REPO $CACHEDIR/opt/python-novaclient $NOVACLIENT_BRANCH git_clone $NIXON_REPO $CACHEDIR/$DEST/nixon $NIXON_BRANCH
git_clone $OPENSTACKX_REPO $CACHEDIR/opt/openstackx $OPENSTACKX_BRANCH git_clone $NOVACLIENT_REPO $CACHEDIR/$DEST/python-novaclient $NOVACLIENT_BRANCH
git_clone $MUNIN_REPO $CACHEDIR/opt/openstack-munin $MUNIN_BRANCH git_clone $OPENSTACKX_REPO $CACHEDIR/$DEST/openstackx $OPENSTACKX_BRANCH
git_clone $MUNIN_REPO $CACHEDIR/$DEST/openstack-munin $MUNIN_BRANCH
# Use this version of devstack? # Use this version of devstack?
if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then
rm -rf $CACHEDIR/opt/devstack rm -rf $CACHEDIR/$DEST/devstack
cp -pr $CWD $CACHEDIR/opt/devstack cp -pr $CWD $CACHEDIR/$DEST/devstack
fi fi
# Destroy the old container # Destroy the old container
@ -128,7 +135,7 @@ ROOTFS=/var/lib/lxc/$CONTAINER/rootfs/
# Create a stack user that is a member of the libvirtd group so that stack # Create a stack user that is a member of the libvirtd group so that stack
# is able to interact with libvirt. # is able to interact with libvirt.
chroot $ROOTFS groupadd libvirtd chroot $ROOTFS groupadd libvirtd
chroot $ROOTFS useradd stack -s /bin/bash -d /opt -G libvirtd chroot $ROOTFS useradd stack -s /bin/bash -d $DEST -G libvirtd
# a simple password - pass # a simple password - pass
echo stack:pass | chroot $ROOTFS chpasswd echo stack:pass | chroot $ROOTFS chpasswd
@ -151,19 +158,19 @@ function cp_it {
# Copy over your ssh keys and env if desired # Copy over your ssh keys and env if desired
if [ "$COPYENV" = "1" ]; then if [ "$COPYENV" = "1" ]; then
cp_it ~/.ssh $ROOTFS/opt/.ssh cp_it ~/.ssh $ROOTFS/$DEST/.ssh
cp_it ~/.ssh/id_rsa.pub $ROOTFS/opt/.ssh/authorized_keys cp_it ~/.ssh/id_rsa.pub $ROOTFS/$DEST/.ssh/authorized_keys
cp_it ~/.gitconfig $ROOTFS/opt/.gitconfig cp_it ~/.gitconfig $ROOTFS/$DEST/.gitconfig
cp_it ~/.vimrc $ROOTFS/opt/.vimrc cp_it ~/.vimrc $ROOTFS/$DEST/.vimrc
cp_it ~/.bashrc $ROOTFS/opt/.bashrc cp_it ~/.bashrc $ROOTFS/$DEST/.bashrc
fi fi
# Make our ip address hostnames look nice at the command prompt # Make our ip address hostnames look nice at the command prompt
echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $ROOTFS/opt/.bashrc echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $ROOTFS/$DEST/.bashrc
echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $ROOTFS/etc/profile echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $ROOTFS/etc/profile
# Give stack ownership over /opt so it may do the work needed # Give stack ownership over $DEST so it may do the work needed
chroot $ROOTFS chown -R stack /opt chroot $ROOTFS chown -R stack $DEST
# Configure instance network # Configure instance network
INTERFACES=$ROOTFS/etc/network/interfaces INTERFACES=$ROOTFS/etc/network/interfaces
@ -179,7 +186,7 @@ iface eth0 inet static
EOF EOF
# Configure the runner # Configure the runner
RUN_SH=$ROOTFS/opt/run.sh RUN_SH=$ROOTFS/$DEST/run.sh
cat > $RUN_SH <<EOF cat > $RUN_SH <<EOF
#!/usr/bin/env bash #!/usr/bin/env bash
# Make sure dns is set up # Make sure dns is set up
@ -192,10 +199,10 @@ killall screen
# Install and run stack.sh # Install and run stack.sh
sudo apt-get update sudo apt-get update
sudo apt-get -y --force-yes install git-core vim-nox sudo sudo apt-get -y --force-yes install git-core vim-nox sudo
if [ ! -d "/opt/devstack" ]; then if [ ! -d "$DEST/devstack" ]; then
git clone git://github.com/cloudbuilders/devstack.git /opt/devstack git clone git://github.com/cloudbuilders/devstack.git $DEST/devstack
fi fi
cd /opt/devstack && $STACKSH_PARAMS ./stack.sh > /opt/run.sh.log cd $DEST/devstack && $STACKSH_PARAMS ./stack.sh > /$DEST/run.sh.log
EOF EOF
# Make the run.sh executable # Make the run.sh executable
@ -205,7 +212,7 @@ chmod 755 $RUN_SH
RC_LOCAL=$ROOTFS/etc/rc.local RC_LOCAL=$ROOTFS/etc/rc.local
cat > $RC_LOCAL <<EOF cat > $RC_LOCAL <<EOF
#!/bin/sh -e #!/bin/sh -e
su -c "/opt/run.sh" stack su -c "$DEST/run.sh" stack
EOF EOF
# Configure cgroup directory # Configure cgroup directory

View file

@ -12,7 +12,7 @@ default_store = sqlite
# Log to this file. Make sure you do not set the same log # Log to this file. Make sure you do not set the same log
# file for both the API and registry servers! # file for both the API and registry servers!
log_file = /opt/keystone/keystone.log log_file = %DEST%/keystone/keystone.log
# List of backends to be configured # List of backends to be configured
backends = keystone.backends.sqlalchemy backends = keystone.backends.sqlalchemy

View file

@ -70,7 +70,9 @@ fi
source ./stackrc source ./stackrc
# Destination path for installation ``DEST`` # Destination path for installation ``DEST``
DEST=${DEST:-/opt} 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
@ -405,6 +407,7 @@ if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
KEYSTONE_CONF=$KEYSTONE_DIR/etc/keystone.conf KEYSTONE_CONF=$KEYSTONE_DIR/etc/keystone.conf
cp $FILES/keystone.conf $KEYSTONE_CONF cp $FILES/keystone.conf $KEYSTONE_CONF
sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/keystone,g" -i $KEYSTONE_CONF sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/keystone,g" -i $KEYSTONE_CONF
sudo sed -e "s,%DEST%,$DEST,g" -i $KEYSTONE_CONF
KEYSTONE_DATA=$KEYSTONE_DIR/bin/keystone_data.sh KEYSTONE_DATA=$KEYSTONE_DIR/bin/keystone_data.sh
cp $FILES/keystone_data.sh $KEYSTONE_DATA cp $FILES/keystone_data.sh $KEYSTONE_DATA

View file

@ -12,6 +12,7 @@ usage() {
HOST=${HOST:-localhost} HOST=${HOST:-localhost}
PORT=${PORT:-9292} PORT=${PORT:-9292}
DEST=${DEST:-/opt/stack}
while getopts h:p: c; do while getopts h:p: c; do
case $c in case $c in
@ -59,14 +60,14 @@ esac
GLANCE=`which glance` GLANCE=`which glance`
if [ -z "$GLANCE" ]; then if [ -z "$GLANCE" ]; then
if [ -x "/opt/glance/bin/glance" ]; then if [ -x "$DEST/glance/bin/glance" ]; then
# Look for stack.sh's install # Look for stack.sh's install
GLANCE="/opt/glance/bin/glance" GLANCE="$DEST/glance/bin/glance"
else else
# Install Glance client in /opt # Install Glance client in $DEST
echo "Glance not found, must install client" echo "Glance not found, must install client"
OWD=`pwd` OWD=`pwd`
cd /opt cd $DEST
sudo apt-get install python-pip python-eventlet python-routes python-greenlet python-argparse python-sqlalchemy python-wsgiref python-pastedeploy python-xattr sudo apt-get install python-pip python-eventlet python-routes python-greenlet python-argparse python-sqlalchemy python-wsgiref python-pastedeploy python-xattr
sudo pip install kombu sudo pip install kombu
sudo git clone https://github.com/cloudbuilders/glance.git sudo git clone https://github.com/cloudbuilders/glance.git