| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 1 | #!/bin/bash | 
|  | 2 |  | 
| Anthony Young | d8c259a | 2011-09-26 14:04:13 -0700 | [diff] [blame] | 3 | # Use stackrc.example if stackrc is missing | 
|  | 4 | if [ ! -e ./stackrc ]; then | 
|  | 5 | read -n1 -p "No stackrc present.  Copy stackrc.example to stackrc? (y/n) " | 
|  | 6 | echo | 
|  | 7 | [[ $REPLY = [yY] ]] && cp stackrc.example stackrc|| { echo "Aborting:  Missing stackrc"; exit 1; } | 
|  | 8 | fi | 
|  | 9 |  | 
| Anthony Young | 2f14020 | 2011-09-26 13:02:40 -0700 | [diff] [blame] | 10 | # Source params | 
|  | 11 | source ./stackrc | 
|  | 12 |  | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 13 | # TODO: make dest not hardcoded | 
|  | 14 |  | 
|  | 15 | NAME=$1 | 
| Jesse Andrews | 1639ed6 | 2011-09-11 15:42:17 -0700 | [diff] [blame] | 16 | DEST="/nfs/$NAME" | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 17 |  | 
|  | 18 | # remove old nfs filesystem if one exists | 
|  | 19 | rm -rf $DEST | 
|  | 20 |  | 
|  | 21 | # build a proto image - natty + packages that will install (optimization) | 
| Jesse Andrews | f2ef760 | 2011-09-11 16:23:21 -0700 | [diff] [blame] | 22 | if [ ! -d proto ]; then | 
| Jesse Andrews | 1639ed6 | 2011-09-11 15:42:17 -0700 | [diff] [blame] | 23 | debootstrap natty proto | 
| Jesse Andrews | 5f09820 | 2011-09-11 16:34:34 -0700 | [diff] [blame] | 24 | cp files/sources.list proto/etc/apt/sources.list | 
| Jesse Andrews | 1639ed6 | 2011-09-11 15:42:17 -0700 | [diff] [blame] | 25 | chroot proto apt-get update | 
| Jesse Andrews | 4d28218 | 2011-09-16 11:27:43 -0700 | [diff] [blame] | 26 | chroot proto apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` | 
|  | 27 | chroot proto pip install `cat files/pips/*` | 
| Anthony Young | 2f14020 | 2011-09-26 13:02:40 -0700 | [diff] [blame] | 28 | git_clone $NOVA_REPO proto/opt/nova $NOVA_BRANCH | 
|  | 29 | git_clone $GLANCE_REPO proto/opt/glance $GLANCE_BRANCH | 
|  | 30 | git_clone $KEYSTONE_REPO proto/opt/keystone $KEYSTONE_BRANCH | 
|  | 31 | git_clone $NOVNC_REPO proto/opt/novnc $NOVNC_BRANCH | 
|  | 32 | git_clone $DASH_REPO proto/opt/dash $DASH_BRANCH $DASH_TAG | 
|  | 33 | git_clone $NIXON_REPO proto/opt/nixon $NIXON_BRANCH | 
|  | 34 | git_clone $NOVACLIENT_REPO proto/opt/python-novaclient $NOVACLIENT_BRANCH | 
|  | 35 | git_clone $OPENSTACKX_REPO proto/opt/openstackx $OPENSTACKX_BRANCH | 
|  | 36 | git_clone $MUNIN_REPO proto/opt/openstack-munin $MUNIN_BRANCH | 
| Jesse Andrews | 543d7d4 | 2011-09-16 14:16:36 -0700 | [diff] [blame] | 37 | chroot proto mkdir -p /opt/files | 
|  | 38 | wget -c http://images.ansolabs.com/tty.tgz -O proto/opt/files/tty.tgz | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 39 | fi | 
|  | 40 |  | 
| Jesse Andrews | 1639ed6 | 2011-09-11 15:42:17 -0700 | [diff] [blame] | 41 | cp -pr proto $DEST | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 42 |  | 
|  | 43 | # set hostname | 
|  | 44 | echo $NAME > $DEST/etc/hostname | 
|  | 45 | echo "127.0.0.1 localhost $NAME" > $DEST/etc/hosts | 
|  | 46 |  | 
|  | 47 | # copy kernel modules | 
|  | 48 | cp -pr /lib/modules/`uname -r` $DEST/lib/modules | 
|  | 49 |  | 
| Jesse Andrews | 5f09820 | 2011-09-11 16:34:34 -0700 | [diff] [blame] | 50 |  | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 51 | # copy openstack installer and requirement lists to a new directory. | 
|  | 52 | mkdir -p $DEST/opt | 
| Jesse Andrews | 4d28218 | 2011-09-16 11:27:43 -0700 | [diff] [blame] | 53 |  | 
|  | 54 | # inject stack.sh and dependant files | 
|  | 55 | cp -r files $DEST/opt/files | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 56 | cp stack.sh $DEST/opt/stack.sh | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 57 |  | 
| Jesse Andrews | 5f09820 | 2011-09-11 16:34:34 -0700 | [diff] [blame] | 58 | # injecting root's public ssh key if it exists | 
|  | 59 | if [ -f /root/.ssh/id_rsa.pub ]; then | 
|  | 60 | mkdir $DEST/root/.ssh | 
|  | 61 | chmod 700 $DEST/root/.ssh | 
|  | 62 | cp /root/.ssh/id_rsa.pub $DEST/root/.ssh/authorized_keys | 
|  | 63 | fi | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 64 |  | 
|  | 65 | # set root password to password | 
| Jesse Andrews | 18d350d | 2011-09-12 21:46:12 -0700 | [diff] [blame] | 66 | echo root:pass | chroot $DEST chpasswd | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 67 |  | 
| Jesse Andrews | 4d6cb14 | 2011-09-12 23:48:30 -0700 | [diff] [blame] | 68 | # Create a stack user that is a member of the libvirtd group so that stack | 
|  | 69 | # is able to interact with libvirt. | 
|  | 70 | chroot $DEST groupadd libvirtd | 
|  | 71 | chroot $DEST useradd stack -s /bin/bash -d /opt -G libvirtd | 
|  | 72 | # a simple password - pass | 
| Jesse Andrews | 18d350d | 2011-09-12 21:46:12 -0700 | [diff] [blame] | 73 | echo stack:pass | chroot $DEST chpasswd | 
| Jesse Andrews | 4d6cb14 | 2011-09-12 23:48:30 -0700 | [diff] [blame] | 74 | # give stack ownership over /opt so it may do the work needed | 
| Jesse Andrews | 18d350d | 2011-09-12 21:46:12 -0700 | [diff] [blame] | 75 | chroot $DEST chown -R stack /opt | 
|  | 76 |  | 
| Jesse Andrews | 4d6cb14 | 2011-09-12 23:48:30 -0700 | [diff] [blame] | 77 | # and has sudo ability (in the future this should be limited to only what | 
|  | 78 | # stack requires) | 
| Jesse Andrews | 18d350d | 2011-09-12 21:46:12 -0700 | [diff] [blame] | 79 | echo "stack ALL=(ALL) NOPASSWD: ALL" >> $DEST/etc/sudoers |