|
...
|
...
|
@@ -1,5 +1,6 @@
|
|
1
|
1
|
#!/bin/bash
|
|
2
|
2
|
|
|
|
3
|
+PROGDIR=`dirname $0`
|
|
3
|
4
|
CHROOTCACHE=${CHROOTCACHE:-/root/cache}
|
|
4
|
5
|
|
|
5
|
6
|
# Source params
|
|
...
|
...
|
@@ -13,25 +14,83 @@ DEST="/nfs/$NAME"
|
|
13
|
13
|
# remove old nfs filesystem if one exists
|
|
14
|
14
|
rm -rf $DEST
|
|
15
|
15
|
|
|
16
|
|
-# build a proto image - natty + packages that will install (optimization)
|
|
17
|
|
-if [ ! -d $CHROOTCACHE/proto ]; then
|
|
18
|
|
- debootstrap natty $CHROOTCACHE/proto
|
|
19
|
|
- cp files/sources.list $CHROOTCACHE/proto/etc/apt/sources.list
|
|
20
|
|
- chroot $CHROOTCACHE/proto apt-get update
|
|
21
|
|
- chroot $CHROOTCACHE/proto apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
|
|
22
|
|
- chroot $CHROOTCACHE/proto pip install `cat files/pips/*`
|
|
23
|
|
- git_clone $NOVA_REPO $CHROOTCACHE/proto/opt/nova $NOVA_BRANCH
|
|
24
|
|
- git_clone $GLANCE_REPO $CHROOTCACHE/proto/opt/glance $GLANCE_BRANCH
|
|
25
|
|
- git_clone $KEYSTONE_REPO $CHROOTCACHE/proto/opt/keystone $KEYSTONE_BRANCH
|
|
26
|
|
- git_clone $NOVNC_REPO $CHROOTCACHE/proto/opt/novnc $NOVNC_BRANCH
|
|
27
|
|
- git_clone $DASH_REPO $CHROOTCACHE/proto/opt/dash $DASH_BRANCH $DASH_TAG
|
|
28
|
|
- git_clone $NOVACLIENT_REPO $CHROOTCACHE/proto/opt/python-novaclient $NOVACLIENT_BRANCH
|
|
29
|
|
- git_clone $OPENSTACKX_REPO $CHROOTCACHE/proto/opt/openstackx $OPENSTACKX_BRANCH
|
|
30
|
|
- chroot $CHROOTCACHE/proto mkdir -p /opt/files
|
|
31
|
|
- wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/proto/opt/files/tty.tgz
|
|
|
16
|
+# clean install of natty
|
|
|
17
|
+if [ ! -d $CHROOTCACHE/natty-base ]; then
|
|
|
18
|
+ $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base
|
|
|
19
|
+ # copy kernel modules...
|
|
|
20
|
+ # NOTE(ja): is there a better way to do this?
|
|
|
21
|
+ cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules
|
|
|
22
|
+ # a simple password - pass
|
|
|
23
|
+ echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd
|
|
32
|
24
|
fi
|
|
33
|
25
|
|
|
34
|
|
-cp -pr $CHROOTCACHE/proto $DEST
|
|
|
26
|
+# prime natty with as many apt/pips as we can
|
|
|
27
|
+if [ ! -d $CHROOTCACHE/natty-dev ]; then
|
|
|
28
|
+ rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/
|
|
|
29
|
+ chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
|
|
|
30
|
+ chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*`
|
|
|
31
|
+
|
|
|
32
|
+ # Create a stack user that is a member of the libvirtd group so that stack
|
|
|
33
|
+ # is able to interact with libvirt.
|
|
|
34
|
+ chroot $CHROOTCACHE/natty-dev groupadd libvirtd
|
|
|
35
|
+ chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d /opt -G libvirtd
|
|
|
36
|
+
|
|
|
37
|
+ # a simple password - pass
|
|
|
38
|
+ echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd
|
|
|
39
|
+
|
|
|
40
|
+ # and has sudo ability (in the future this should be limited to only what
|
|
|
41
|
+ # stack requires)
|
|
|
42
|
+ echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers
|
|
|
43
|
+fi
|
|
|
44
|
+
|
|
|
45
|
+# clone git repositories onto the system
|
|
|
46
|
+# ======================================
|
|
|
47
|
+
|
|
|
48
|
+if [ ! -d $CHROOTCACHE/natty-stack ]; then
|
|
|
49
|
+ rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/
|
|
|
50
|
+fi
|
|
|
51
|
+
|
|
|
52
|
+# git clone only if directory doesn't exist already. Since ``DEST`` might not
|
|
|
53
|
+# be owned by the installation user, we create the directory and change the
|
|
|
54
|
+# ownership to the proper user.
|
|
|
55
|
+function git_clone {
|
|
|
56
|
+
|
|
|
57
|
+ # clone new copy or fetch latest changes
|
|
|
58
|
+ CHECKOUT=$CHROOTCACHE/natty-stack$2
|
|
|
59
|
+ if [ ! -d $CHECKOUT ]; then
|
|
|
60
|
+ mkdir -p $CHECKOUT
|
|
|
61
|
+ git clone $1 $CHECKOUT
|
|
|
62
|
+ else
|
|
|
63
|
+ pushd $CHECKOUT
|
|
|
64
|
+ git fetch
|
|
|
65
|
+ popd
|
|
|
66
|
+ fi
|
|
|
67
|
+
|
|
|
68
|
+ # FIXME(ja): checkout specified version (should works for branches and tags)
|
|
|
69
|
+
|
|
|
70
|
+ pushd $CHECKOUT
|
|
|
71
|
+ # checkout the proper branch/tag
|
|
|
72
|
+ git checkout $3
|
|
|
73
|
+ # force our local version to be the same as the remote version
|
|
|
74
|
+ git reset --hard origin/$3
|
|
|
75
|
+ popd
|
|
|
76
|
+
|
|
|
77
|
+ # give ownership to the stack user
|
|
|
78
|
+ chroot $CHROOTCACHE/natty-stack/ chown -R stack $2
|
|
|
79
|
+}
|
|
|
80
|
+
|
|
|
81
|
+git_clone $NOVA_REPO /opt/stack/nova $NOVA_BRANCH
|
|
|
82
|
+git_clone $GLANCE_REPO /opt/stack/glance $GLANCE_BRANCH
|
|
|
83
|
+git_clone $KEYSTONE_REPO /opt/stack/keystone $KEYSTONE_BRANCH
|
|
|
84
|
+git_clone $NOVNC_REPO /opt/stack/novnc $NOVNC_BRANCH
|
|
|
85
|
+git_clone $DASH_REPO /opt/stack/dash $DASH_BRANCH $DASH_TAG
|
|
|
86
|
+git_clone $NOVACLIENT_REPO /opt/stack/python-novaclient $NOVACLIENT_BRANCH
|
|
|
87
|
+git_clone $OPENSTACKX_REPO /opt/stack/openstackx $OPENSTACKX_BRANCH
|
|
|
88
|
+
|
|
|
89
|
+chroot $CHROOTCACHE/natty-stack mkdir -p /opt/stack/files
|
|
|
90
|
+wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack/opt/stack/files/tty.tgz
|
|
|
91
|
+
|
|
|
92
|
+cp -pr $CHROOTCACHE/natty-stack $DEST
|
|
35
|
93
|
|
|
36
|
94
|
# set hostname
|
|
37
|
95
|
echo $NAME > $DEST/etc/hostname
|
|
...
|
...
|
@@ -54,19 +113,3 @@ if [ -f /root/.ssh/id_rsa.pub ]; then
|
|
54
|
54
|
chmod 700 $DEST/root/.ssh
|
|
55
|
55
|
cp /root/.ssh/id_rsa.pub $DEST/root/.ssh/authorized_keys
|
|
56
|
56
|
fi
|
|
57
|
|
-
|
|
58
|
|
-# set root password to password
|
|
59
|
|
-echo root:pass | chroot $DEST chpasswd
|
|
60
|
|
-
|
|
61
|
|
-# Create a stack user that is a member of the libvirtd group so that stack
|
|
62
|
|
-# is able to interact with libvirt.
|
|
63
|
|
-chroot $DEST groupadd libvirtd
|
|
64
|
|
-chroot $DEST useradd stack -s /bin/bash -d /opt -G libvirtd
|
|
65
|
|
-# a simple password - pass
|
|
66
|
|
-echo stack:pass | chroot $DEST chpasswd
|
|
67
|
|
-# give stack ownership over /opt so it may do the work needed
|
|
68
|
|
-chroot $DEST chown -R stack /opt
|
|
69
|
|
-
|
|
70
|
|
-# and has sudo ability (in the future this should be limited to only what
|
|
71
|
|
-# stack requires)
|
|
72
|
|
-echo "stack ALL=(ALL) NOPASSWD: ALL" >> $DEST/etc/sudoers
|