tag 611920 patch
thanks
Hi,
here is the patch.
Jonas
diff --git a/debian/README.Debian b/debian/README.Debian
index 8e51d82..0c47ba6 100644
--- a/debian/README.Debian
+++ b/debian/README.Debian
@@ -25,4 +25,13 @@ control groups filesystem there:
cgroup /var/local/cgroup cgroup defaults 0 0
+
+Autostart containers on boot
+----------------------------
+
+If you want to start lxc containers on boot you have to create an symlink from
+the /etc/lxc/auto directory to your lxc configuration.
+
+ ln -s /etc/lxc/bar.conf /etc/lxc/auto/bar.conf
+
-- Guido Trotter <ultrot...@debian.org> Fri, 12 Jun 2009 15:13:55 +0100
diff --git a/debian/dirs b/debian/dirs
index 3ccdaf6..5e80db3 100644
--- a/debian/dirs
+++ b/debian/dirs
@@ -4,3 +4,4 @@ usr/share/lintian/overrides
usr/share/doc/lxc/examples
var/lib/lxc
etc/lxc
+etc/lxc/auto
diff --git a/debian/lxc.default b/debian/lxc.default
index d225a04..6cc2798 100644
--- a/debian/lxc.default
+++ b/debian/lxc.default
@@ -4,6 +4,3 @@
# Directory containing the container configurations
CONF_DIR=/etc/lxc
-# Start /etc/lxc/example.conf, /etc/lxc/autostart.conf, etc.
-CONTAINERS="example autostart container"
-
diff --git a/debian/lxc.init b/debian/lxc.init
index 5c63f7b..d6a9b90 100644
--- a/debian/lxc.init
+++ b/debian/lxc.init
@@ -13,6 +13,7 @@
NAME=lxc
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
+LXCDOMAINS_AUTO="/etc/lxc/auto"
DESC="LXC containers"
SCRIPTNAME="/etc/init.d/lxc"
@@ -28,6 +29,20 @@ if [ "x$RUN" != "xyes" ] ; then
exit 0
fi
+if [ ! -d "$LXCDOMAINS_AUTO" ]; then
+ log_success_msg "$NAME missing LXC autostart directory $LXCDOMAINS_AUTO"
+ exit 0
+fi
+
+is_running() {
+ name=$1
+ RC=1
+ if [ $(lxc-info -n $name | grep "RUNNING" -c) -eq 1 ]; then
+ RC=0
+ fi
+ return $RC
+}
+
start_one() {
name=$1
if [ -f "$CONF_DIR/$name.conf" ]; then
@@ -40,9 +55,18 @@ start_one() {
action_all() {
action=$1
nolog=$2
- for i in $CONTAINERS; do
- [ -n "$nolog" ] || log_progress_msg "$i"
- $action $i
+ for i in $LXCDOMAINS_AUTO/*; do
+ NAME=$(basename $i | sed 's@\.conf@@')
+ [ -n "$nolog" ] || log_progress_msg "$NAME"
+ if [ "$action" = "start_one" ]; then
+ if is_running $NAME; then
+ [ -n "$nolog" ] || log_progress_msg "(skip)"
+ else
+ $action $NAME
+ fi
+ else
+ $action $NAME
+ fi
done
[ -n "$nolog" ] || log_end_msg 0
}