blob: 36126fa83deb786968d3a0f77b042749bfacfa61 [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 Troyerd4a3bac2011-10-03 21:16:27 -05004CHROOTCACHE=${CHROOTCACHE:-/var/cache/devstack}
Dean Troyer4cbb2672011-10-03 09:14:36 -05005
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
Dean Troyera3379e02011-10-03 11:14:13 -050016# Option to use the version of devstack on which we are currently working
17USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
18
Jesse Andrewsba23cc72011-09-11 03:22:13 -070019# remove old nfs filesystem if one exists
20rm -rf $DEST
21
Dean Troyercc806542011-10-03 09:30:57 -050022# clean install of natty
23if [ ! -d $CHROOTCACHE/natty-base ]; then
24 $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base
Vishvananda Ishaya9b353672011-10-20 10:07:10 -070025 # copy kernel modules...
Dean Troyercc806542011-10-03 09:30:57 -050026 # 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 Andrewsba23cc72011-09-11 03:22:13 -070030fi
31
Dean Troyercc806542011-10-03 09:30:57 -050032# prime natty with as many apt/pips as we can
33if [ ! -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 Ishaya9b353672011-10-20 10:07:10 -070038 # Create a stack user that is a member of the libvirtd group so that stack
Dean Troyercc806542011-10-03 09:30:57 -050039 # is able to interact with libvirt.
40 chroot $CHROOTCACHE/natty-dev groupadd libvirtd
Dean Troyer11e5e6f2011-10-03 09:40:32 -050041 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 Troyercc806542011-10-03 09:30:57 -050044
45 # a simple password - pass
46 echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd
47
Vishvananda Ishaya9b353672011-10-20 10:07:10 -070048 # and has sudo ability (in the future this should be limited to only what
Dean Troyercc806542011-10-03 09:30:57 -050049 # stack requires)
50 echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers
51fi
52
53# clone git repositories onto the system
54# ======================================
55
56if [ ! -d $CHROOTCACHE/natty-stack ]; then
57 rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/
58fi
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.
63function 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 Troyer11e5e6f2011-10-03 09:40:32 -050089git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
90git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
91git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
92git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH
93git_clone $DASH_REPO $DEST/dash $DASH_BRANCH $DASH_TAG
94git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH
95git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH
Dean Troyercc806542011-10-03 09:30:57 -050096
Dean Troyer11e5e6f2011-10-03 09:40:32 -050097chroot $CHROOTCACHE/natty-stack mkdir -p $DEST/files
98wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack$DEST/files/tty.tgz
Dean Troyercc806542011-10-03 09:30:57 -050099
Dean Troyer03412c82011-10-03 09:56:41 -0500100# Use this version of devstack?
101if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then
Dean Troyer10db4452011-10-03 11:16:32 -0500102 rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack
Dean Troyer03412c82011-10-03 09:56:41 -0500103 cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack
104fi
105
106cp -pr $CHROOTCACHE/natty-stack $NFSDIR
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700107
108# set hostname
Dean Troyer03412c82011-10-03 09:56:41 -0500109echo $NAME > $NFSDIR/etc/hostname
110echo "127.0.0.1 localhost $NAME" > $NFSDIR/etc/hosts
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
Dean Troyer03412c82011-10-03 09:56:41 -0500114 mkdir $NFSDIR/root/.ssh
115 chmod 700 $NFSDIR/root/.ssh
116 cp /root/.ssh/id_rsa.pub $NFSDIR/root/.ssh/authorized_keys
Jesse Andrews5f098202011-09-11 16:34:34 -0700117fi