Browse code

cleanup output

Anthony Young authored on 2011/09/14 13:51:28
Showing 1 changed files
... ...
@@ -1,4 +1,4 @@
1
-#!/bin/bash
1
+#!/usr/bin/env bash
2 2
 # Configurable params
3 3
 BRIDGE=${BRIDGE:-br0}
4 4
 CONTAINER=${CONTAINER:-STACK}
... ...
@@ -12,6 +12,11 @@ COPYENV=${COPYENV:-1}
12 12
 # Param string to pass to stack.sh.  Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova"
13 13
 STACKSH_PARAMS=${STACKSH_PARAMS:-}
14 14
 
15
+# Install cgroup-bin if we don't have it yet
16
+if ! which cgdelete | grep -q cgdelete; then
17
+    apt-get install cgroup-bin
18
+fi
19
+
15 20
 # Create lxc configuration
16 21
 LXC_CONF=/tmp/$CONTAINER.conf
17 22
 cat > $LXC_CONF <<EOF
... ...
@@ -26,8 +31,10 @@ EOF
26 26
 # Shutdown any existing container
27 27
 lxc-stop -n $CONTAINER
28 28
 
29
-# This prevents zombie containers
30
-cgdelete -r cpu,net_cls:$CONTAINER
29
+# This kills zombie containers
30
+if [ -d /cgroup/$CONTAINER ]; then
31
+    cgdelete -r cpu,net_cls:$CONTAINER
32
+fi
31 33
 
32 34
 # Warm the base image on first install
33 35
 CACHEDIR=/var/cache/lxc/natty/rootfs-amd64
... ...
@@ -113,8 +120,10 @@ cat > $RC_LOCAL <<EOF
113 113
 EOF
114 114
 
115 115
 # Configure cgroup directory
116
-mkdir -p /cgroup
117
-mount none -t cgroup /cgroup
116
+if ! mount | grep -q cgroup; then
117
+    mkdir -p /cgroup
118
+    mount none -t cgroup /cgroup
119
+fi
118 120
 
119 121
 # Start our container
120 122
 lxc-start -d -n $CONTAINER