blob: 9ffa3cbe89b42bbf52f524a7d8767dfac6aeb94c [file] [log] [blame]
Jesse Andrewsba23cc72011-09-11 03:22:13 -07001#!/bin/bash
2
Dean Troyercc806542011-10-03 09:30:57 -05003PROGDIR=`dirname $0`
Dean Troyer4cbb2672011-10-03 09:14:36 -05004CHROOTCACHE=${CHROOTCACHE:-/root/cache}
5
Anthony Young2f140202011-09-26 13:02:40 -07006# Source params
7source ./stackrc
8
Jesse Andrewsba23cc72011-09-11 03:22:13 -07009# TODO: make dest not hardcoded
10
11NAME=$1
Jesse Andrews1639ed62011-09-11 15:42:17 -070012DEST="/nfs/$NAME"
Jesse Andrewsba23cc72011-09-11 03:22:13 -070013
14# remove old nfs filesystem if one exists
15rm -rf $DEST
16
Dean Troyercc806542011-10-03 09:30:57 -050017# clean install of natty
18if [ ! -d $CHROOTCACHE/natty-base ]; then
19 $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base
20 # copy kernel modules...
21 # NOTE(ja): is there a better way to do this?
22 cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules
23 # a simple password - pass
24 echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd
Jesse Andrewsba23cc72011-09-11 03:22:13 -070025fi
26
Dean Troyercc806542011-10-03 09:30:57 -050027# prime natty with as many apt/pips as we can
28if [ ! -d $CHROOTCACHE/natty-dev ]; then
29 rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/
30 chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
31 chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*`
32
33 # Create a stack user that is a member of the libvirtd group so that stack
34 # is able to interact with libvirt.
35 chroot $CHROOTCACHE/natty-dev groupadd libvirtd
Dean Troyer11e5e6f2011-10-03 09:40:32 -050036 chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd
37 mkdir -p $CHROOTCACHE/natty-dev/$DEST
38 chown stack $CHROOTCACHE/natty-dev/$DEST
Dean Troyercc806542011-10-03 09:30:57 -050039
40 # a simple password - pass
41 echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd
42
43 # and has sudo ability (in the future this should be limited to only what
44 # stack requires)
45 echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers
46fi
47
48# clone git repositories onto the system
49# ======================================
50
51if [ ! -d $CHROOTCACHE/natty-stack ]; then
52 rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/
53fi
54
55# git clone only if directory doesn't exist already. Since ``DEST`` might not
56# be owned by the installation user, we create the directory and change the
57# ownership to the proper user.
58function git_clone {
59
60 # clone new copy or fetch latest changes
61 CHECKOUT=$CHROOTCACHE/natty-stack$2
62 if [ ! -d $CHECKOUT ]; then
63 mkdir -p $CHECKOUT
64 git clone $1 $CHECKOUT
65 else
66 pushd $CHECKOUT
67 git fetch
68 popd
69 fi
70
71 # FIXME(ja): checkout specified version (should works for branches and tags)
72
73 pushd $CHECKOUT
74 # checkout the proper branch/tag
75 git checkout $3
76 # force our local version to be the same as the remote version
77 git reset --hard origin/$3
78 popd
79
80 # give ownership to the stack user
81 chroot $CHROOTCACHE/natty-stack/ chown -R stack $2
82}
83
Dean Troyer11e5e6f2011-10-03 09:40:32 -050084git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
85git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
86git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
87git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH
88git_clone $DASH_REPO $DEST/dash $DASH_BRANCH $DASH_TAG
89git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH
90git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH
Dean Troyercc806542011-10-03 09:30:57 -050091
Dean Troyer11e5e6f2011-10-03 09:40:32 -050092chroot $CHROOTCACHE/natty-stack mkdir -p $DEST/files
93wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack$DEST/files/tty.tgz
Dean Troyercc806542011-10-03 09:30:57 -050094
95cp -pr $CHROOTCACHE/natty-stack $DEST
Jesse Andrewsba23cc72011-09-11 03:22:13 -070096
97# set hostname
98echo $NAME > $DEST/etc/hostname
99echo "127.0.0.1 localhost $NAME" > $DEST/etc/hosts
100
101# copy kernel modules
102cp -pr /lib/modules/`uname -r` $DEST/lib/modules
103
Jesse Andrews5f098202011-09-11 16:34:34 -0700104
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700105# copy openstack installer and requirement lists to a new directory.
106mkdir -p $DEST/opt
Jesse Andrews4d282182011-09-16 11:27:43 -0700107
108# inject stack.sh and dependant files
109cp -r files $DEST/opt/files
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700110cp stack.sh $DEST/opt/stack.sh
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700111
Jesse Andrews5f098202011-09-11 16:34:34 -0700112# injecting root's public ssh key if it exists
113if [ -f /root/.ssh/id_rsa.pub ]; then
114 mkdir $DEST/root/.ssh
115 chmod 700 $DEST/root/.ssh
116 cp /root/.ssh/id_rsa.pub $DEST/root/.ssh/authorized_keys
117fi