From e8fed48eadb73152ab4442b166cf9f668d2b11f8 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 26 Sep 2011 19:50:43 -0700 Subject: [PATCH 1/3] use /opt/stack instead of /opt --- build_lxc.sh | 57 +++++++++++++++++++++++++-------------------- files/keystone.conf | 2 +- stack.sh | 5 +++- upload_image.sh | 9 +++---- 4 files changed, 42 insertions(+), 31 deletions(-) diff --git a/build_lxc.sh b/build_lxc.sh index b97f8db..1f85b33 100755 --- a/build_lxc.sh +++ b/build_lxc.sh @@ -22,6 +22,7 @@ CONTAINER_NETMASK=${CONTAINER_NETMASK:-255.255.255.0} CONTAINER_GATEWAY=${CONTAINER_GATEWAY:-192.168.1.1} NAMESERVER=${NAMESERVER:-$CONTAINER_GATEWAY} 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" STACKSH_PARAMS=${STACKSH_PARAMS:-} @@ -94,21 +95,27 @@ if [ ! -d $CACHEDIR ]; then chroot $CACHEDIR pip install `cat files/pips/*` fi +# Clean out code repos if directed to do so +if [ "$CLEAN" = "1" ]; then + rm -rf $NOVA_REPO $CACHEDIR/$DEST +fi + # Cache openstack code -git_clone $NOVA_REPO $CACHEDIR/opt/nova $NOVA_BRANCH -git_clone $GLANCE_REPO $CACHEDIR/opt/glance $GLANCE_BRANCH -git_clone $KEYSTONE_REPO $CACHEDIR/opt/keystone $KEYSTONE_BRANCH -git_clone $NOVNC_REPO $CACHEDIR/opt/novnc $NOVNC_BRANCH -git_clone $DASH_REPO $CACHEDIR/opt/dash $DASH_BRANCH $DASH_TAG -git_clone $NIXON_REPO $CACHEDIR/opt/nixon $NIXON_BRANCH -git_clone $NOVACLIENT_REPO $CACHEDIR/opt/python-novaclient $NOVACLIENT_BRANCH -git_clone $OPENSTACKX_REPO $CACHEDIR/opt/openstackx $OPENSTACKX_BRANCH -git_clone $MUNIN_REPO $CACHEDIR/opt/openstack-munin $MUNIN_BRANCH +mkdir -p $CACHEDIR/$DEST +git_clone $NOVA_REPO $CACHEDIR/$DEST/nova $NOVA_BRANCH +git_clone $GLANCE_REPO $CACHEDIR/$DEST/glance $GLANCE_BRANCH +git_clone $KEYSTONE_REPO $CACHEDIR/$DESTkeystone $KEYSTONE_BRANCH +git_clone $NOVNC_REPO $CACHEDIR/$DEST/novnc $NOVNC_BRANCH +git_clone $DASH_REPO $CACHEDIR/$DEST/dash $DASH_BRANCH $DASH_TAG +git_clone $NIXON_REPO $CACHEDIR/$DEST/nixon $NIXON_BRANCH +git_clone $NOVACLIENT_REPO $CACHEDIR/$DEST/python-novaclient $NOVACLIENT_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? if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then - rm -rf $CACHEDIR/opt/devstack - cp -pr $CWD $CACHEDIR/opt/devstack + rm -rf $CACHEDIR/$DEST/devstack + cp -pr $CWD $CACHEDIR/$DEST/devstack fi # 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 # is able to interact with libvirt. 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 echo stack:pass | chroot $ROOTFS chpasswd @@ -151,19 +158,19 @@ function cp_it { # Copy over your ssh keys and env if desired if [ "$COPYENV" = "1" ]; then - cp_it ~/.ssh $ROOTFS/opt/.ssh - cp_it ~/.ssh/id_rsa.pub $ROOTFS/opt/.ssh/authorized_keys - cp_it ~/.gitconfig $ROOTFS/opt/.gitconfig - cp_it ~/.vimrc $ROOTFS/opt/.vimrc - cp_it ~/.bashrc $ROOTFS/opt/.bashrc + cp_it ~/.ssh $ROOTFS/$DEST/.ssh + cp_it ~/.ssh/id_rsa.pub $ROOTFS/$DEST/.ssh/authorized_keys + cp_it ~/.gitconfig $ROOTFS/$DEST/.gitconfig + cp_it ~/.vimrc $ROOTFS/$DEST/.vimrc + cp_it ~/.bashrc $ROOTFS/$DEST/.bashrc fi # 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 -# Give stack ownership over /opt so it may do the work needed -chroot $ROOTFS chown -R stack /opt +# Give stack ownership over /$DEST so it may do the work needed +chroot $ROOTFS chown -R stack /$DEST # Configure instance network INTERFACES=$ROOTFS/etc/network/interfaces @@ -179,7 +186,7 @@ iface eth0 inet static EOF # Configure the runner -RUN_SH=$ROOTFS/opt/run.sh +RUN_SH=$ROOTFS/$DEST/run.sh cat > $RUN_SH < /opt/run.sh.log +cd /$DEST/devstack && $STACKSH_PARAMS ./stack.sh > /$DEST/run.sh.log EOF # Make the run.sh executable @@ -205,7 +212,7 @@ chmod 755 $RUN_SH RC_LOCAL=$ROOTFS/etc/rc.local cat > $RC_LOCAL < Date: Mon, 26 Sep 2011 19:58:49 -0700 Subject: [PATCH 2/3] fix some paths --- build_lxc.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build_lxc.sh b/build_lxc.sh index 1f85b33..9c9f930 100755 --- a/build_lxc.sh +++ b/build_lxc.sh @@ -169,8 +169,8 @@ fi 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 -# Give stack ownership over /$DEST so it may do the work needed -chroot $ROOTFS chown -R stack /$DEST +# Give stack ownership over $DEST so it may do the work needed +chroot $ROOTFS chown -R stack $DEST # Configure instance network INTERFACES=$ROOTFS/etc/network/interfaces @@ -199,10 +199,10 @@ killall screen # Install and run stack.sh sudo apt-get update sudo apt-get -y --force-yes install git-core vim-nox sudo -if [ ! -d "/$DEST/devstack" ]; then - git clone git://github.com/cloudbuilders/devstack.git /$DEST/devstack +if [ ! -d "$DEST/devstack" ]; then + git clone git://github.com/cloudbuilders/devstack.git $DEST/devstack fi -cd /$DEST/devstack && $STACKSH_PARAMS ./stack.sh > /$DEST/run.sh.log +cd $DEST/devstack && $STACKSH_PARAMS ./stack.sh > /$DEST/run.sh.log EOF # Make the run.sh executable @@ -212,7 +212,7 @@ chmod 755 $RUN_SH RC_LOCAL=$ROOTFS/etc/rc.local cat > $RC_LOCAL < Date: Mon, 26 Sep 2011 20:03:40 -0700 Subject: [PATCH 3/3] fix rm --- build_lxc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_lxc.sh b/build_lxc.sh index 9c9f930..6caffb6 100755 --- a/build_lxc.sh +++ b/build_lxc.sh @@ -97,7 +97,7 @@ fi # Clean out code repos if directed to do so if [ "$CLEAN" = "1" ]; then - rm -rf $NOVA_REPO $CACHEDIR/$DEST + rm -rf $CACHEDIR/$DEST fi # Cache openstack code