Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Dean Troyer | 4cbb267 | 2011-10-03 09:14:36 -0500 | [diff] [blame^] | 3 | CHROOTCACHE=${CHROOTCACHE:-/root/cache} |
| 4 | |
Anthony Young | 2f14020 | 2011-09-26 13:02:40 -0700 | [diff] [blame] | 5 | # Source params |
| 6 | source ./stackrc |
| 7 | |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 8 | # TODO: make dest not hardcoded |
| 9 | |
| 10 | NAME=$1 |
Jesse Andrews | 1639ed6 | 2011-09-11 15:42:17 -0700 | [diff] [blame] | 11 | DEST="/nfs/$NAME" |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 12 | |
| 13 | # remove old nfs filesystem if one exists |
| 14 | rm -rf $DEST |
| 15 | |
| 16 | # build a proto image - natty + packages that will install (optimization) |
Dean Troyer | 4cbb267 | 2011-10-03 09:14:36 -0500 | [diff] [blame^] | 17 | if [ ! -d $CHROOTCACHE/proto ]; then |
| 18 | debootstrap natty $CHROOTCACHE/proto |
| 19 | cp files/sources.list $CHROOTCACHE/proto/etc/apt/sources.list |
| 20 | chroot $CHROOTCACHE/proto apt-get update |
| 21 | chroot $CHROOTCACHE/proto apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` |
| 22 | chroot $CHROOTCACHE/proto pip install `cat files/pips/*` |
| 23 | git_clone $NOVA_REPO $CHROOTCACHE/proto/opt/nova $NOVA_BRANCH |
| 24 | git_clone $GLANCE_REPO $CHROOTCACHE/proto/opt/glance $GLANCE_BRANCH |
| 25 | git_clone $KEYSTONE_REPO $CHROOTCACHE/proto/opt/keystone $KEYSTONE_BRANCH |
| 26 | git_clone $NOVNC_REPO $CHROOTCACHE/proto/opt/novnc $NOVNC_BRANCH |
| 27 | git_clone $DASH_REPO $CHROOTCACHE/proto/opt/dash $DASH_BRANCH $DASH_TAG |
| 28 | git_clone $NOVACLIENT_REPO $CHROOTCACHE/proto/opt/python-novaclient $NOVACLIENT_BRANCH |
| 29 | git_clone $OPENSTACKX_REPO $CHROOTCACHE/proto/opt/openstackx $OPENSTACKX_BRANCH |
| 30 | chroot $CHROOTCACHE/proto mkdir -p /opt/files |
| 31 | wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/proto/opt/files/tty.tgz |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 32 | fi |
| 33 | |
Dean Troyer | 4cbb267 | 2011-10-03 09:14:36 -0500 | [diff] [blame^] | 34 | cp -pr $CHROOTCACHE/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 |