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