blob: 39a2cf0889743a8f8358ed47451c24acfefedf0f [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/
Anthony Youngca2c0472011-11-03 16:29:32 -070035 chroot $CHROOTCACHE apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1`
36 chroot $CHROOTCACHE apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1`
37 chroot $CHROOTCACHE pip install `cat files/pips/*`
Dean Troyercc806542011-10-03 09:30:57 -050038
Vishvananda Ishaya9b353672011-10-20 10:07:10 -070039 # Create a stack user that is a member of the libvirtd group so that stack
Dean Troyercc806542011-10-03 09:30:57 -050040 # is able to interact with libvirt.
41 chroot $CHROOTCACHE/natty-dev groupadd libvirtd
Dean Troyer11e5e6f2011-10-03 09:40:32 -050042 chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd
43 mkdir -p $CHROOTCACHE/natty-dev/$DEST
44 chown stack $CHROOTCACHE/natty-dev/$DEST
Dean Troyercc806542011-10-03 09:30:57 -050045
46 # a simple password - pass
47 echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd
48
Vishvananda Ishaya9b353672011-10-20 10:07:10 -070049 # and has sudo ability (in the future this should be limited to only what
Dean Troyercc806542011-10-03 09:30:57 -050050 # stack requires)
51 echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers
52fi
53
54# clone git repositories onto the system
55# ======================================
56
57if [ ! -d $CHROOTCACHE/natty-stack ]; then
58 rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/
59fi
60
61# git clone only if directory doesn't exist already. Since ``DEST`` might not
62# be owned by the installation user, we create the directory and change the
63# ownership to the proper user.
64function git_clone {
65
66 # clone new copy or fetch latest changes
67 CHECKOUT=$CHROOTCACHE/natty-stack$2
68 if [ ! -d $CHECKOUT ]; then
69 mkdir -p $CHECKOUT
70 git clone $1 $CHECKOUT
71 else
72 pushd $CHECKOUT
73 git fetch
74 popd
75 fi
76
77 # FIXME(ja): checkout specified version (should works for branches and tags)
78
79 pushd $CHECKOUT
80 # checkout the proper branch/tag
81 git checkout $3
82 # force our local version to be the same as the remote version
83 git reset --hard origin/$3
84 popd
85
86 # give ownership to the stack user
87 chroot $CHROOTCACHE/natty-stack/ chown -R stack $2
88}
89
Dean Troyer11e5e6f2011-10-03 09:40:32 -050090git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
91git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
92git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
93git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH
Tres Henryca85b792011-10-28 14:00:21 -070094git_clone $HORIZON_REPO $DEST/horizon $HORIZON_BRANCH $HORIZON_TAG
Dean Troyer11e5e6f2011-10-03 09:40:32 -050095git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH
96git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH
Dean Troyercc806542011-10-03 09:30:57 -050097
Dean Troyer11e5e6f2011-10-03 09:40:32 -050098chroot $CHROOTCACHE/natty-stack mkdir -p $DEST/files
99wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack$DEST/files/tty.tgz
Dean Troyercc806542011-10-03 09:30:57 -0500100
Dean Troyer03412c82011-10-03 09:56:41 -0500101# Use this version of devstack?
102if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then
Dean Troyer10db4452011-10-03 11:16:32 -0500103 rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack
Dean Troyer03412c82011-10-03 09:56:41 -0500104 cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack
105fi
106
107cp -pr $CHROOTCACHE/natty-stack $NFSDIR
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700108
109# set hostname
Dean Troyer03412c82011-10-03 09:56:41 -0500110echo $NAME > $NFSDIR/etc/hostname
111echo "127.0.0.1 localhost $NAME" > $NFSDIR/etc/hosts
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700112
Jesse Andrews5f098202011-09-11 16:34:34 -0700113# injecting root's public ssh key if it exists
114if [ -f /root/.ssh/id_rsa.pub ]; then
Dean Troyer03412c82011-10-03 09:56:41 -0500115 mkdir $NFSDIR/root/.ssh
116 chmod 700 $NFSDIR/root/.ssh
117 cp /root/.ssh/id_rsa.pub $NFSDIR/root/.ssh/authorized_keys
Jesse Andrews5f098202011-09-11 16:34:34 -0700118fi