| ... | ... |
@@ -1,5 +1,16 @@ |
| 1 | 1 |
#!/usr/bin/env bash |
| 2 | 2 |
|
| 3 |
+# Sanity check |
|
| 4 |
+if [ "$EUID" -ne "0" ]; then |
|
| 5 |
+ echo "This script must be run with root privileges." |
|
| 6 |
+ exit 1 |
|
| 7 |
+fi |
|
| 8 |
+ |
|
| 9 |
+# Warn users who aren't on natty |
|
| 10 |
+if ! grep -q natty /etc/lsb-release; then |
|
| 11 |
+ echo "WARNING: this script has only been tested on natty" |
|
| 12 |
+fi |
|
| 13 |
+ |
|
| 3 | 14 |
# Source params |
| 4 | 15 |
source ./stackrc |
| 5 | 16 |
|
| ... | ... |
@@ -23,18 +34,14 @@ STACKSH_PARAMS=${STACKSH_PARAMS:-}
|
| 23 | 23 |
# Option to use the version of devstack on which we are currently working |
| 24 | 24 |
USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
|
| 25 | 25 |
|
| 26 |
-# Warn users who aren't on natty |
|
| 27 |
-if ! grep -q natty /etc/lsb-release; then |
|
| 28 |
- echo "WARNING: this script has only been tested on natty" |
|
| 29 |
-fi |
|
| 30 | 26 |
|
| 31 | 27 |
# Install deps |
| 32 | 28 |
apt-get install -y lxc debootstrap |
| 33 | 29 |
|
| 34 | 30 |
# Install cgroup-bin from source, since the packaging is buggy and possibly incompatible with our setup |
| 35 | 31 |
if ! which cgdelete | grep -q cgdelete; then |
| 36 |
- apt-get install -y g++ bison flex libpam0g-dev |
|
| 37 |
- wget http://sourceforge.net/projects/libcg/files/libcgroup/v0.37.1/libcgroup-0.37.1.tar.bz2/download -O /tmp/libcgroup-0.37.1.tar.bz2 |
|
| 32 |
+ apt-get install -y g++ bison flex libpam0g-dev make |
|
| 33 |
+ wget http://sourceforge.net/projects/libcg/files/libcgroup/v0.37.1/libcgroup-0.37.1.tar.bz2/download -O /tmp/libcgroup-0.37.1.tar.bz2 |
|
| 38 | 34 |
cd /tmp && bunzip2 libcgroup-0.37.1.tar.bz2 && tar xfv libcgroup-0.37.1.tar |
| 39 | 35 |
cd libcgroup-0.37.1 |
| 40 | 36 |
./configure |
| ... | ... |
@@ -75,17 +82,25 @@ function git_clone {
|
| 75 | 75 |
fi |
| 76 | 76 |
} |
| 77 | 77 |
|
| 78 |
-# Warm the base image on first install |
|
| 78 |
+# Location of the base image directory |
|
| 79 | 79 |
CACHEDIR=/var/cache/lxc/natty/rootfs-amd64 |
| 80 |
-if [ ! -d $CACHEDIR ]; then |
|
| 80 |
+ |
|
| 81 |
+# Provide option to do totally clean install |
|
| 82 |
+if [ "$CLEAR_LXC_CACHE" = "1" ]; then |
|
| 83 |
+ rm -rf $CACHEDIR |
|
| 84 |
+fi |
|
| 85 |
+ |
|
| 86 |
+# Warm the base image on first install |
|
| 87 |
+if [ ! -f $CACHEDIR/bootstrapped ]; then |
|
| 81 | 88 |
# by deleting the container, we force lxc-create to re-bootstrap (lxc is |
| 82 | 89 |
# lazy and doesn't do anything if a container already exists) |
| 83 | 90 |
lxc-destroy -n $CONTAINER |
| 84 | 91 |
# trigger the initial debootstrap |
| 85 | 92 |
lxc-create -n $CONTAINER -t natty -f $LXC_CONF |
| 86 | 93 |
chroot $CACHEDIR apt-get update |
| 87 |
- chroot $CACHEDIR apt-get install -y --force-yes `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` |
|
| 94 |
+ chroot $CACHEDIR apt-get install -y --force-yes `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server|munin-node)"` |
|
| 88 | 95 |
chroot $CACHEDIR pip install `cat files/pips/*` |
| 96 |
+ touch $CACHEDIR/bootstrapped |
|
| 89 | 97 |
fi |
| 90 | 98 |
|
| 91 | 99 |
# Clean out code repos if directed to do so |
| ... | ... |
@@ -125,7 +140,7 @@ lxc-create -n $CONTAINER -t natty -f $LXC_CONF |
| 125 | 125 |
# Specify where our container rootfs lives |
| 126 | 126 |
ROOTFS=/var/lib/lxc/$CONTAINER/rootfs/ |
| 127 | 127 |
|
| 128 |
-# Create a stack user that is a member of the libvirtd group so that stack |
|
| 128 |
+# Create a stack user that is a member of the libvirtd group so that stack |
|
| 129 | 129 |
# is able to interact with libvirt. |
| 130 | 130 |
chroot $ROOTFS groupadd libvirtd |
| 131 | 131 |
chroot $ROOTFS useradd stack -s /bin/bash -d $DEST -G libvirtd |
| ... | ... |
@@ -133,7 +148,7 @@ chroot $ROOTFS useradd stack -s /bin/bash -d $DEST -G libvirtd |
| 133 | 133 |
# a simple password - pass |
| 134 | 134 |
echo stack:pass | chroot $ROOTFS chpasswd |
| 135 | 135 |
|
| 136 |
-# and has sudo ability (in the future this should be limited to only what |
|
| 136 |
+# and has sudo ability (in the future this should be limited to only what |
|
| 137 | 137 |
# stack requires) |
| 138 | 138 |
echo "stack ALL=(ALL) NOPASSWD: ALL" >> $ROOTFS/etc/sudoers |
| 139 | 139 |
|
| ... | ... |
@@ -145,7 +160,7 @@ cp -pR /lib/modules/`uname -r`/kernel/net $ROOTFS/lib/modules/`uname -r`/kernel/ |
| 145 | 145 |
# Gracefully cp only if source file/dir exists |
| 146 | 146 |
function cp_it {
|
| 147 | 147 |
if [ -e $1 ] || [ -d $1 ]; then |
| 148 |
- cp -pr $1 $2 |
|
| 148 |
+ cp -pRL $1 $2 |
|
| 149 | 149 |
fi |
| 150 | 150 |
} |
| 151 | 151 |
|
| ... | ... |
@@ -196,6 +211,9 @@ if [ ! -d "$DEST/devstack" ]; then |
| 196 | 196 |
git clone git://github.com/cloudbuilders/devstack.git $DEST/devstack |
| 197 | 197 |
fi |
| 198 | 198 |
cd $DEST/devstack && $STACKSH_PARAMS ./stack.sh > /$DEST/run.sh.log |
| 199 |
+echo >> /$DEST/run.sh.log |
|
| 200 |
+echo >> /$DEST/run.sh.log |
|
| 201 |
+echo "All done! Time to start clicking." >> /$DEST/run.sh.log |
|
| 199 | 202 |
EOF |
| 200 | 203 |
|
| 201 | 204 |
# Make the run.sh executable |
| ... | ... |
@@ -216,3 +234,20 @@ fi |
| 216 | 216 |
|
| 217 | 217 |
# Start our container |
| 218 | 218 |
lxc-start -d -n $CONTAINER |
| 219 |
+ |
|
| 220 |
+# Done creating the container, let's tail the log |
|
| 221 |
+echo |
|
| 222 |
+echo "=============================================================" |
|
| 223 |
+echo " -- YAY! --" |
|
| 224 |
+echo "=============================================================" |
|
| 225 |
+echo |
|
| 226 |
+echo "We're done creating the container, about to start tailing the" |
|
| 227 |
+echo "stack.sh log. It will take a second or two to start." |
|
| 228 |
+echo |
|
| 229 |
+echo "Just CTRL-C at any time to stop tailing." |
|
| 230 |
+ |
|
| 231 |
+while [ ! -e "$ROOTFS/$DEST/run.sh.log" ]; do |
|
| 232 |
+ sleep 1 |
|
| 233 |
+done |
|
| 234 |
+ |
|
| 235 |
+tail -F $ROOTFS/$DEST/run.sh.log |
| ... | ... |
@@ -14,7 +14,7 @@ if [ ! -d natty-base ]; then |
| 14 | 14 |
debootstrap natty natty-base |
| 15 | 15 |
# copy kernel modules... |
| 16 | 16 |
# NOTE(ja): is there a better way to do this? |
| 17 |
- cp -pr /lib/modules/`uname -r` proto/lib/modules |
|
| 17 |
+ cp -pr /lib/modules/`uname -r` natty-base/lib/modules |
|
| 18 | 18 |
cp files/sources.list natty-base/etc/apt/sources.list |
| 19 | 19 |
chroot natty-base apt-get update |
| 20 | 20 |
fi |
| ... | ... |
@@ -89,8 +89,8 @@ BASE=build.$$ |
| 89 | 89 |
IMG=$BASE.img |
| 90 | 90 |
MNT=$BASE/ |
| 91 | 91 |
|
| 92 |
-# create a 2GB blank filesystem |
|
| 93 |
-dd if=/dev/zero of=$IMG bs=1024k count=2048 |
|
| 92 |
+# (quickly) create a 2GB blank filesystem |
|
| 93 |
+dd bs=1 count=1 seek=$((2*1024*1024*1024)) if=/dev/zero of=$IMG |
|
| 94 | 94 |
# force it to be initialized as ext2 |
| 95 | 95 |
mkfs.ext2 -F $IMG |
| 96 | 96 |
|
| 97 | 97 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,93 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+# Print some usage info |
|
| 3 |
+function usage {
|
|
| 4 |
+ echo "Usage: $0 [OPTION] [host_ip]" |
|
| 5 |
+ echo "Set up temporary networking for LXC" |
|
| 6 |
+ echo "" |
|
| 7 |
+ echo " -n, --dry-run Just print the commands that would execute." |
|
| 8 |
+ echo " -h, --help Print this usage message." |
|
| 9 |
+ echo "" |
|
| 10 |
+ exit |
|
| 11 |
+} |
|
| 12 |
+ |
|
| 13 |
+# Allow passing the ip address on the command line. |
|
| 14 |
+function process_option {
|
|
| 15 |
+ case "$1" in |
|
| 16 |
+ -h|--help) usage;; |
|
| 17 |
+ -n|--dry-run) dry_run=1;; |
|
| 18 |
+ *) host_ip="$1" |
|
| 19 |
+ esac |
|
| 20 |
+} |
|
| 21 |
+ |
|
| 22 |
+# Set up some defaults |
|
| 23 |
+host_ip= |
|
| 24 |
+dry_run=0 |
|
| 25 |
+bridge=br0 |
|
| 26 |
+DRIER= |
|
| 27 |
+ |
|
| 28 |
+# Process the args |
|
| 29 |
+for arg in "$@"; do |
|
| 30 |
+ process_option $arg |
|
| 31 |
+done |
|
| 32 |
+ |
|
| 33 |
+if [ $dry_run ]; then |
|
| 34 |
+ DRIER=echo |
|
| 35 |
+fi |
|
| 36 |
+ |
|
| 37 |
+if [ "$UID" -ne "0" ]; then |
|
| 38 |
+ echo "This script must be run with root privileges." |
|
| 39 |
+ exit 1 |
|
| 40 |
+fi |
|
| 41 |
+ |
|
| 42 |
+# Check for bridge-utils. |
|
| 43 |
+BRCTL=`which brctl` |
|
| 44 |
+if [ ! -x "$BRCTL" ]; then |
|
| 45 |
+ echo "This script requires you to install bridge-utils." |
|
| 46 |
+ echo "Try: sudo apt-get install bridge-utils." |
|
| 47 |
+ exit 1 |
|
| 48 |
+fi |
|
| 49 |
+ |
|
| 50 |
+# Scare off the nubs. |
|
| 51 |
+echo "=====================================================" |
|
| 52 |
+echo |
|
| 53 |
+echo "WARNING" |
|
| 54 |
+echo |
|
| 55 |
+echo "This script will modify your current network setup," |
|
| 56 |
+echo "this can be a scary thing and it is recommended that" |
|
| 57 |
+echo "you have something equivalent to physical access to" |
|
| 58 |
+echo "this machine before continuing in case your network" |
|
| 59 |
+echo "gets all funky." |
|
| 60 |
+echo |
|
| 61 |
+echo "If you don't want to continue, hit CTRL-C now." |
|
| 62 |
+ |
|
| 63 |
+if [ -z "$host_ip" ]; |
|
| 64 |
+then |
|
| 65 |
+ echo "Otherwise, please type in your host's ip address and" |
|
| 66 |
+ echo "hit enter." |
|
| 67 |
+ echo |
|
| 68 |
+ echo "=====================================================" |
|
| 69 |
+ read host_ip |
|
| 70 |
+else |
|
| 71 |
+ echo "Otherwise hit enter." |
|
| 72 |
+ echo |
|
| 73 |
+ echo "=====================================================" |
|
| 74 |
+ read accept |
|
| 75 |
+fi |
|
| 76 |
+ |
|
| 77 |
+ |
|
| 78 |
+# Add a bridge interface, this will choke if there is already |
|
| 79 |
+# a bridge named $bridge |
|
| 80 |
+$DRIER $BRCTL addbr $bridge |
|
| 81 |
+$DRIER ip addr add 192.168.1.1/24 dev $bridge |
|
| 82 |
+if [ $dry_run ]; then |
|
| 83 |
+ echo "echo 1 > /proc/sys/net/ipv4/ip_forward" |
|
| 84 |
+else |
|
| 85 |
+ echo 1 > /proc/sys/net/ipv4/ip_forward |
|
| 86 |
+fi |
|
| 87 |
+$DRIER ifconfig $bridge up |
|
| 88 |
+ |
|
| 89 |
+# Set up the NAT for the instances |
|
| 90 |
+$DRIER iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j SNAT --to-source $host_ip |
|
| 91 |
+$DRIER iptables -I FORWARD -s 192.168.1.0/24 -j ACCEPT |
|
| 92 |
+ |
| ... | ... |
@@ -13,6 +13,9 @@ |
| 13 | 13 |
# Sanity Check |
| 14 | 14 |
# ============ |
| 15 | 15 |
|
| 16 |
+# Start our timer |
|
| 17 |
+START_TIME=`python -c "import time; print time.time()"` |
|
| 18 |
+ |
|
| 16 | 19 |
# Warn users who aren't on natty, but allow them to override check and attempt |
| 17 | 20 |
# installation with ``FORCE=yes ./stack`` |
| 18 | 21 |
if ! grep -q natty /etc/lsb-release; then |
| ... | ... |
@@ -37,6 +40,15 @@ if [ ! -d $FILES ]; then |
| 37 | 37 |
exit 1 |
| 38 | 38 |
fi |
| 39 | 39 |
|
| 40 |
+# you need to run this as a regular user with sudo priviledges |
|
| 41 |
+if [[ $EUID -eq 0 ]]; then |
|
| 42 |
+ echo "This script cannot be run as root." 1>&2 |
|
| 43 |
+ echo "You should run this script as the user you wish openstack to run as" 1>&2 |
|
| 44 |
+ echo "The user will need to be a sudoer (without password)" 1>&2 |
|
| 45 |
+ exit 1 |
|
| 46 |
+fi |
|
| 47 |
+ |
|
| 48 |
+ |
|
| 40 | 49 |
# Settings |
| 41 | 50 |
# ======== |
| 42 | 51 |
|
| ... | ... |
@@ -48,6 +60,11 @@ fi |
| 48 | 48 |
# |
| 49 | 49 |
# You can also pass options on a single line ``MYSQL_PASS=simple ./stack.sh`` |
| 50 | 50 |
# |
| 51 |
+# Additionally, you can put any local variables into a ``localrc`` file, like:: |
|
| 52 |
+# |
|
| 53 |
+# MYSQL_PASS=anothersecret |
|
| 54 |
+# MYSQL_USER=hellaroot |
|
| 55 |
+# |
|
| 51 | 56 |
# We try to have sensible defaults, so you should be able to run ``./stack.sh`` |
| 52 | 57 |
# in most cases. |
| 53 | 58 |
|
| ... | ... |
@@ -377,7 +394,7 @@ if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then |
| 377 | 377 |
$NOVA_DIR/bin/nova-manage db sync |
| 378 | 378 |
|
| 379 | 379 |
# create a small network |
| 380 |
- $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 $FIXED_NETWORK_SIZE |
|
| 380 |
+ $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 $FIXED_NETWORK_SIZE |
|
| 381 | 381 |
|
| 382 | 382 |
# create some floating ips |
| 383 | 383 |
$NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE |
| ... | ... |
@@ -500,3 +517,11 @@ if [[ "$ENABLED_SERVICES" =~ "key" ]]; then |
| 500 | 500 |
echo "keystone is serving at http://$HOST_IP:5000/v2.0/" |
| 501 | 501 |
echo "examples on using novaclient command line is in exercise.sh" |
| 502 | 502 |
fi |
| 503 |
+ |
|
| 504 |
+# Summary |
|
| 505 |
+# ======= |
|
| 506 |
+ |
|
| 507 |
+# End our timer and give a timing summary |
|
| 508 |
+END_TIME=`python -c "import time; print time.time()"` |
|
| 509 |
+ELAPSED=`python -c "print $END_TIME - $START_TIME"` |
|
| 510 |
+echo "stack.sh completed in $ELAPSED seconds." |
| ... | ... |
@@ -1,6 +1,6 @@ |
| 1 | 1 |
# compute service |
| 2 |
-NOVA_REPO=https://github.com/openstack/nova.git |
|
| 3 |
-NOVA_BRANCH=2011.3 |
|
| 2 |
+NOVA_REPO=https://github.com/cloudbuilders/nova.git |
|
| 3 |
+NOVA_BRANCH=diablo |
|
| 4 | 4 |
|
| 5 | 5 |
# image catalog service |
| 6 | 6 |
GLANCE_REPO=https://github.com/cloudbuilders/glance.git |
| ... | ... |
@@ -34,3 +34,8 @@ OPENSTACKX_BRANCH=diablo |
| 34 | 34 |
# openstack-munin is a collection of munin plugins for monitoring the stack |
| 35 | 35 |
MUNIN_REPO=https://github.com/cloudbuilders/openstack-munin.git |
| 36 | 36 |
MUNIN_BRANCH=master |
| 37 |
+ |
|
| 38 |
+# allow local overrides of env variables |
|
| 39 |
+if [ -f ./localrc ]; then |
|
| 40 |
+ source ./localrc |
|
| 41 |
+fi |