blob: a6c8b4c9c03dd1ea9d784b431ac9aff0d4d3cac5 [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
Dean Troyer03412c82011-10-03 09:56:41 -05009# Store cwd
10CWD=`pwd`
Jesse Andrewsba23cc72011-09-11 03:22:13 -070011
12NAME=$1
Dean Troyer03412c82011-10-03 09:56:41 -050013NFSDIR="/nfs/$NAME"
14DEST=${DEST:-/opt/stack}
Jesse Andrewsba23cc72011-09-11 03:22:13 -070015
16# remove old nfs filesystem if one exists
17rm -rf $DEST
18
Dean Troyercc806542011-10-03 09:30:57 -050019# clean install of natty
20if [ ! -d $CHROOTCACHE/natty-base ]; then
21 $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base
22 # copy kernel modules...
23 # NOTE(ja): is there a better way to do this?
24 cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules
25 # a simple password - pass
26 echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd
Jesse Andrewsba23cc72011-09-11 03:22:13 -070027fi
28
Dean Troyercc806542011-10-03 09:30:57 -050029# prime natty with as many apt/pips as we can
30if [ ! -d $CHROOTCACHE/natty-dev ]; then
31 rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/
32 chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
33 chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*`
34
35 # Create a stack user that is a member of the libvirtd group so that stack
36 # is able to interact with libvirt.
37 chroot $CHROOTCACHE/natty-dev groupadd libvirtd
Dean Troyer11e5e6f2011-10-03 09:40:32 -050038 chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd
39 mkdir -p $CHROOTCACHE/natty-dev/$DEST
40 chown stack $CHROOTCACHE/natty-dev/$DEST
Dean Troyercc806542011-10-03 09:30:57 -050041
42 # a simple password - pass
43 echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd
44
45 # and has sudo ability (in the future this should be limited to only what
46 # stack requires)
47 echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers
48fi
49
50# clone git repositories onto the system
51# ======================================
52
53if [ ! -d $CHROOTCACHE/natty-stack ]; then
54 rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/
55fi
56
57# git clone only if directory doesn't exist already. Since ``DEST`` might not
58# be owned by the installation user, we create the directory and change the
59# ownership to the proper user.
60function git_clone {
61
62 # clone new copy or fetch latest changes
63 CHECKOUT=$CHROOTCACHE/natty-stack$2
64 if [ ! -d $CHECKOUT ]; then
65 mkdir -p $CHECKOUT
66 git clone $1 $CHECKOUT
67 else
68 pushd $CHECKOUT
69 git fetch
70 popd
71 fi
72
73 # FIXME(ja): checkout specified version (should works for branches and tags)
74
75 pushd $CHECKOUT
76 # checkout the proper branch/tag
77 git checkout $3
78 # force our local version to be the same as the remote version
79 git reset --hard origin/$3
80 popd
81
82 # give ownership to the stack user
83 chroot $CHROOTCACHE/natty-stack/ chown -R stack $2
84}
85
Dean Troyer11e5e6f2011-10-03 09:40:32 -050086git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
87git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
88git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
89git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH
90git_clone $DASH_REPO $DEST/dash $DASH_BRANCH $DASH_TAG
91git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH
92git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH
Dean Troyercc806542011-10-03 09:30:57 -050093
Dean Troyer11e5e6f2011-10-03 09:40:32 -050094chroot $CHROOTCACHE/natty-stack mkdir -p $DEST/files
95wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack$DEST/files/tty.tgz
Dean Troyercc806542011-10-03 09:30:57 -050096
Dean Troyer03412c82011-10-03 09:56:41 -050097# Use this version of devstack?
98if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then
99 rm -rf $$CHROOTCACHE/natty-stack/$DEST/devstack
100 cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack
101fi
102
103cp -pr $CHROOTCACHE/natty-stack $NFSDIR
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700104
105# set hostname
Dean Troyer03412c82011-10-03 09:56:41 -0500106echo $NAME > $NFSDIR/etc/hostname
107echo "127.0.0.1 localhost $NAME" > $NFSDIR/etc/hosts
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700108
Jesse Andrews5f098202011-09-11 16:34:34 -0700109# injecting root's public ssh key if it exists
110if [ -f /root/.ssh/id_rsa.pub ]; then
Dean Troyer03412c82011-10-03 09:56:41 -0500111 mkdir $NFSDIR/root/.ssh
112 chmod 700 $NFSDIR/root/.ssh
113 cp /root/.ssh/id_rsa.pub $NFSDIR/root/.ssh/authorized_keys
Jesse Andrews5f098202011-09-11 16:34:34 -0700114fi