Browse code

a variety of tweaks for lxc stackiness

Anthony Young authored on 2011/09/13 18:05:12
Showing 1 changed files
... ...
@@ -12,9 +12,19 @@ WARMCACHE=${WARMCACHE:-0}
12 12
 
13 13
 # Destroy any existing container
14 14
 lxc-stop -n $CONTAINER
15
-sleep 1
15
+sleep 2
16 16
 lxc-destroy -n $CONTAINER
17
-sleep 1
17
+sleep 2
18
+
19
+CACHEDIR=/var/cache/lxc/natty/rootfs-amd64
20
+if [ "$WARMCACHE" = "1" ]; then
21
+    if [ -d $CACHEDIR ]; then
22
+        # Pre-cache files
23
+        chroot $CACHEDIR apt-get update
24
+        chroot $CACHEDIR apt-get install -y `cat apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
25
+        chroot $CACHEDIR pip install `cat pips/*`
26
+    fi
27
+fi
18 28
 
19 29
 # Create network configuration
20 30
 NET_CONF=/tmp/net.conf
... ...
@@ -27,14 +37,7 @@ EOF
27 27
 
28 28
 # Configure the network
29 29
 lxc-create -n $CONTAINER -t natty -f $NET_CONF
30
-
31
-if [ "$WARMCACHE" = "1" ]; then
32
-    # Pre-cache files
33
-    BASECACHE=/var/cache/lxc/natty/rootfs-amd64
34
-    chroot $BASECACHE apt-get update
35
-    chroot $BASECACHE apt-get install -y `cat apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
36
-    chroot $BASECACHE pip install `cat pips/*`
37
-fi
30
+sleep 2
38 31
 
39 32
 # Where our container lives
40 33
 ROOTFS=/var/lib/lxc/$CONTAINER/rootfs/
... ...
@@ -67,9 +70,27 @@ cat > $INSTALL_SH <<EOF
67 67
 #!/bin/bash
68 68
 echo "nameserver $NAMESERVER" | resolvconf -a eth0
69 69
 sleep 1
70
+# Create a stack user that is a member of the libvirtd group so that stack 
71
+# is able to interact with libvirt.
72
+groupadd libvirtd
73
+useradd stack -s /bin/bash -d /opt -G libvirtd
74
+
75
+# a simple password - pass
76
+echo stack:pass | chpasswd
77
+
78
+# give stack ownership over /opt so it may do the work needed
79
+chown -R stack /opt
80
+
81
+# and has sudo ability (in the future this should be limited to only what 
82
+# stack requires)
83
+
84
+echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
85
+
86
+# Install and run stack.sh
70 87
 apt-get update
71 88
 apt-get -y --force-yes install git-core vim-nox sudo
72
-git clone git://github.com/cloudbuilders/nfs-stack.git /root/nfs-stack
89
+su -c "git clone git://github.com/cloudbuilders/nfs-stack.git /opt/nfs-stack" stack
90
+su -c "cd /opt/nfs-stack && ./stack.sh" stack
73 91
 EOF
74 92
 
75 93
 chmod 700 $INSTALL_SH
... ...
@@ -81,20 +102,9 @@ cat > $RC_LOCAL <<EOF
81 81
 /root/install.sh
82 82
 EOF
83 83
 
84
-# Setup cache
85
-# FIXME - use proper fstab mount
86
-CWD=`pwd`
87
-CACHEDIR=$CWD/cache/
88
-mkdir -p $CACHEDIR/apt
89
-mkdir -p $CACHEDIR/pip
90
-cp -pr $CACHEDIR/apt/* $ROOTFS/var/cache/apt/
91
-cp -pr $CACHEDIR/pip/* $ROOTFS/var/cache/pip/
92
-
93 84
 # Configure cgroup directory
94
-if [ ! -d /cgroup ] ; then
95
-    mkdir -p /cgroup
96
-    mount none -t cgroup /cgroup
97
-fi
85
+mkdir -p /cgroup
86
+mount none -t cgroup /cgroup
98 87
 
99 88
 # Start our container
100 89
 lxc-start -d -n $CONTAINER