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 | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 16 | chroot proto apt-get install -y `cat apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` |
Jesse Andrews | f2ef760 | 2011-09-11 16:23:21 -0700 | [diff] [blame] | 17 | chroot proto pip install `cat 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 | 3107deb | 2011-09-11 16:46:44 -0700 | [diff] [blame] | 25 | wget -c http://images.ansolabs.com/tty.tgz -O proto/opt/tty.tgz |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 26 | fi |
| 27 | |
Jesse Andrews | 1639ed6 | 2011-09-11 15:42:17 -0700 | [diff] [blame] | 28 | cp -pr proto $DEST |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 29 | |
| 30 | # set hostname |
| 31 | echo $NAME > $DEST/etc/hostname |
| 32 | echo "127.0.0.1 localhost $NAME" > $DEST/etc/hosts |
| 33 | |
| 34 | # copy kernel modules |
| 35 | cp -pr /lib/modules/`uname -r` $DEST/lib/modules |
| 36 | |
Jesse Andrews | 8b564a8 | 2011-09-11 17:53:34 -0700 | [diff] [blame] | 37 | # inject stack.sh files |
| 38 | cp -r files $DEST/opt/files |
Jesse Andrews | 5f09820 | 2011-09-11 16:34:34 -0700 | [diff] [blame] | 39 | |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 40 | # copy openstack installer and requirement lists to a new directory. |
| 41 | mkdir -p $DEST/opt |
| 42 | cp stack.sh $DEST/opt/stack.sh |
| 43 | cp -r pips $DEST/opt |
| 44 | cp -r apts $DEST/opt |
| 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 |