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