blob: 59a3609ad972b874170545d4a266c61bc07eb75e [file] [log] [blame]
Jesse Andrewsba23cc72011-09-11 03:22:13 -07001#!/bin/bash
2
3# TODO: make dest not hardcoded
4
5NAME=$1
Jesse Andrews1639ed62011-09-11 15:42:17 -07006DEST="/nfs/$NAME"
Jesse Andrewsba23cc72011-09-11 03:22:13 -07007
8# remove old nfs filesystem if one exists
9rm -rf $DEST
10
11# build a proto image - natty + packages that will install (optimization)
Jesse Andrewsf2ef7602011-09-11 16:23:21 -070012if [ ! -d proto ]; then
Jesse Andrews1639ed62011-09-11 15:42:17 -070013 debootstrap natty proto
Jesse Andrews5f098202011-09-11 16:34:34 -070014 cp files/sources.list proto/etc/apt/sources.list
Jesse Andrews1639ed62011-09-11 15:42:17 -070015 chroot proto apt-get update
Jesse Andrews4d282182011-09-16 11:27:43 -070016 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 Andrews1639ed62011-09-11 15:42:17 -070018 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 Andrews543d7d42011-09-16 14:16:36 -070025 chroot proto mkdir -p /opt/files
26 wget -c http://images.ansolabs.com/tty.tgz -O proto/opt/files/tty.tgz
Jesse Andrewsba23cc72011-09-11 03:22:13 -070027fi
28
Jesse Andrews1639ed62011-09-11 15:42:17 -070029cp -pr proto $DEST
Jesse Andrewsba23cc72011-09-11 03:22:13 -070030
31# set hostname
32echo $NAME > $DEST/etc/hostname
33echo "127.0.0.1 localhost $NAME" > $DEST/etc/hosts
34
35# copy kernel modules
36cp -pr /lib/modules/`uname -r` $DEST/lib/modules
37
Jesse Andrews5f098202011-09-11 16:34:34 -070038
Jesse Andrewsba23cc72011-09-11 03:22:13 -070039# copy openstack installer and requirement lists to a new directory.
40mkdir -p $DEST/opt
Jesse Andrews4d282182011-09-16 11:27:43 -070041
42# inject stack.sh and dependant files
43cp -r files $DEST/opt/files
Jesse Andrewsba23cc72011-09-11 03:22:13 -070044cp stack.sh $DEST/opt/stack.sh
Jesse Andrewsba23cc72011-09-11 03:22:13 -070045
Jesse Andrews5f098202011-09-11 16:34:34 -070046# injecting root's public ssh key if it exists
47if [ -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
51fi
Jesse Andrewsba23cc72011-09-11 03:22:13 -070052
53# set root password to password
Jesse Andrews18d350d2011-09-12 21:46:12 -070054echo root:pass | chroot $DEST chpasswd
Jesse Andrewsba23cc72011-09-11 03:22:13 -070055
Jesse Andrews4d6cb142011-09-12 23:48:30 -070056# Create a stack user that is a member of the libvirtd group so that stack
57# is able to interact with libvirt.
58chroot $DEST groupadd libvirtd
59chroot $DEST useradd stack -s /bin/bash -d /opt -G libvirtd
60# a simple password - pass
Jesse Andrews18d350d2011-09-12 21:46:12 -070061echo stack:pass | chroot $DEST chpasswd
Jesse Andrews4d6cb142011-09-12 23:48:30 -070062# give stack ownership over /opt so it may do the work needed
Jesse Andrews18d350d2011-09-12 21:46:12 -070063chroot $DEST chown -R stack /opt
64
Jesse Andrews4d6cb142011-09-12 23:48:30 -070065# and has sudo ability (in the future this should be limited to only what
66# stack requires)
Jesse Andrews18d350d2011-09-12 21:46:12 -070067echo "stack ALL=(ALL) NOPASSWD: ALL" >> $DEST/etc/sudoers