| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 1 | #!/bin/bash | 
|  | 2 |  | 
| Dean Troyer | cc80654 | 2011-10-03 09:30:57 -0500 | [diff] [blame] | 3 | PROGDIR=`dirname $0` | 
| Dean Troyer | d4a3bac | 2011-10-03 21:16:27 -0500 | [diff] [blame] | 4 | CHROOTCACHE=${CHROOTCACHE:-/var/cache/devstack} | 
| Dean Troyer | 4cbb267 | 2011-10-03 09:14:36 -0500 | [diff] [blame] | 5 |  | 
| Anthony Young | 2f14020 | 2011-09-26 13:02:40 -0700 | [diff] [blame] | 6 | # Source params | 
|  | 7 | source ./stackrc | 
|  | 8 |  | 
| Dean Troyer | 03412c8 | 2011-10-03 09:56:41 -0500 | [diff] [blame] | 9 | # Store cwd | 
|  | 10 | CWD=`pwd` | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 11 |  | 
|  | 12 | NAME=$1 | 
| Dean Troyer | 03412c8 | 2011-10-03 09:56:41 -0500 | [diff] [blame] | 13 | NFSDIR="/nfs/$NAME" | 
|  | 14 | DEST=${DEST:-/opt/stack} | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 15 |  | 
| Dean Troyer | a3379e0 | 2011-10-03 11:14:13 -0500 | [diff] [blame] | 16 | # Option to use the version of devstack on which we are currently working | 
|  | 17 | USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1} | 
|  | 18 |  | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 19 | # remove old nfs filesystem if one exists | 
|  | 20 | rm -rf $DEST | 
|  | 21 |  | 
| Dean Troyer | cc80654 | 2011-10-03 09:30:57 -0500 | [diff] [blame] | 22 | # clean install of natty | 
|  | 23 | if [ ! -d $CHROOTCACHE/natty-base ]; then | 
|  | 24 | $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base | 
| Vishvananda Ishaya | 9b35367 | 2011-10-20 10:07:10 -0700 | [diff] [blame] | 25 | # copy kernel modules... | 
| Dean Troyer | cc80654 | 2011-10-03 09:30:57 -0500 | [diff] [blame] | 26 | # NOTE(ja): is there a better way to do this? | 
|  | 27 | cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules | 
|  | 28 | # a simple password - pass | 
|  | 29 | echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 30 | fi | 
|  | 31 |  | 
| Dean Troyer | cc80654 | 2011-10-03 09:30:57 -0500 | [diff] [blame] | 32 | # prime natty with as many apt/pips as we can | 
|  | 33 | if [ ! -d $CHROOTCACHE/natty-dev ]; then | 
|  | 34 | rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/ | 
|  | 35 | chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` | 
|  | 36 | chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*` | 
|  | 37 |  | 
| Vishvananda Ishaya | 9b35367 | 2011-10-20 10:07:10 -0700 | [diff] [blame] | 38 | # Create a stack user that is a member of the libvirtd group so that stack | 
| Dean Troyer | cc80654 | 2011-10-03 09:30:57 -0500 | [diff] [blame] | 39 | # is able to interact with libvirt. | 
|  | 40 | chroot $CHROOTCACHE/natty-dev groupadd libvirtd | 
| Dean Troyer | 11e5e6f | 2011-10-03 09:40:32 -0500 | [diff] [blame] | 41 | chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd | 
|  | 42 | mkdir -p $CHROOTCACHE/natty-dev/$DEST | 
|  | 43 | chown stack $CHROOTCACHE/natty-dev/$DEST | 
| Dean Troyer | cc80654 | 2011-10-03 09:30:57 -0500 | [diff] [blame] | 44 |  | 
|  | 45 | # a simple password - pass | 
|  | 46 | echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd | 
|  | 47 |  | 
| Vishvananda Ishaya | 9b35367 | 2011-10-20 10:07:10 -0700 | [diff] [blame] | 48 | # and has sudo ability (in the future this should be limited to only what | 
| Dean Troyer | cc80654 | 2011-10-03 09:30:57 -0500 | [diff] [blame] | 49 | # stack requires) | 
|  | 50 | echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers | 
|  | 51 | fi | 
|  | 52 |  | 
|  | 53 | # clone git repositories onto the system | 
|  | 54 | # ====================================== | 
|  | 55 |  | 
|  | 56 | if [ ! -d $CHROOTCACHE/natty-stack ]; then | 
|  | 57 | rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/ | 
|  | 58 | fi | 
|  | 59 |  | 
|  | 60 | # git clone only if directory doesn't exist already.  Since ``DEST`` might not | 
|  | 61 | # be owned by the installation user, we create the directory and change the | 
|  | 62 | # ownership to the proper user. | 
|  | 63 | function git_clone { | 
|  | 64 |  | 
|  | 65 | # clone new copy or fetch latest changes | 
|  | 66 | CHECKOUT=$CHROOTCACHE/natty-stack$2 | 
|  | 67 | if [ ! -d $CHECKOUT ]; then | 
|  | 68 | mkdir -p $CHECKOUT | 
|  | 69 | git clone $1 $CHECKOUT | 
|  | 70 | else | 
|  | 71 | pushd $CHECKOUT | 
|  | 72 | git fetch | 
|  | 73 | popd | 
|  | 74 | fi | 
|  | 75 |  | 
|  | 76 | # FIXME(ja): checkout specified version (should works for branches and tags) | 
|  | 77 |  | 
|  | 78 | pushd $CHECKOUT | 
|  | 79 | # checkout the proper branch/tag | 
|  | 80 | git checkout $3 | 
|  | 81 | # force our local version to be the same as the remote version | 
|  | 82 | git reset --hard origin/$3 | 
|  | 83 | popd | 
|  | 84 |  | 
|  | 85 | # give ownership to the stack user | 
|  | 86 | chroot $CHROOTCACHE/natty-stack/ chown -R stack $2 | 
|  | 87 | } | 
|  | 88 |  | 
| Dean Troyer | 11e5e6f | 2011-10-03 09:40:32 -0500 | [diff] [blame] | 89 | git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH | 
|  | 90 | git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH | 
|  | 91 | git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH | 
|  | 92 | git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH | 
| Tres Henry | ca85b79 | 2011-10-28 14:00:21 -0700 | [diff] [blame] | 93 | git_clone $HORIZON_REPO $DEST/horizon $HORIZON_BRANCH $HORIZON_TAG | 
| Dean Troyer | 11e5e6f | 2011-10-03 09:40:32 -0500 | [diff] [blame] | 94 | git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH | 
|  | 95 | git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH | 
| Dean Troyer | cc80654 | 2011-10-03 09:30:57 -0500 | [diff] [blame] | 96 |  | 
| Dean Troyer | 11e5e6f | 2011-10-03 09:40:32 -0500 | [diff] [blame] | 97 | chroot $CHROOTCACHE/natty-stack mkdir -p $DEST/files | 
|  | 98 | wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack$DEST/files/tty.tgz | 
| Dean Troyer | cc80654 | 2011-10-03 09:30:57 -0500 | [diff] [blame] | 99 |  | 
| Dean Troyer | 03412c8 | 2011-10-03 09:56:41 -0500 | [diff] [blame] | 100 | # Use this version of devstack? | 
|  | 101 | if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then | 
| Dean Troyer | 10db445 | 2011-10-03 11:16:32 -0500 | [diff] [blame] | 102 | rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack | 
| Dean Troyer | 03412c8 | 2011-10-03 09:56:41 -0500 | [diff] [blame] | 103 | cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack | 
|  | 104 | fi | 
|  | 105 |  | 
|  | 106 | cp -pr $CHROOTCACHE/natty-stack $NFSDIR | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 107 |  | 
|  | 108 | # set hostname | 
| Dean Troyer | 03412c8 | 2011-10-03 09:56:41 -0500 | [diff] [blame] | 109 | echo $NAME > $NFSDIR/etc/hostname | 
|  | 110 | echo "127.0.0.1 localhost $NAME" > $NFSDIR/etc/hosts | 
| Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 111 |  | 
| Jesse Andrews | 5f09820 | 2011-09-11 16:34:34 -0700 | [diff] [blame] | 112 | # injecting root's public ssh key if it exists | 
|  | 113 | if [ -f /root/.ssh/id_rsa.pub ]; then | 
| Dean Troyer | 03412c8 | 2011-10-03 09:56:41 -0500 | [diff] [blame] | 114 | mkdir $NFSDIR/root/.ssh | 
|  | 115 | chmod 700 $NFSDIR/root/.ssh | 
|  | 116 | cp /root/.ssh/id_rsa.pub $NFSDIR/root/.ssh/authorized_keys | 
| Jesse Andrews | 5f09820 | 2011-09-11 16:34:34 -0700 | [diff] [blame] | 117 | fi |