Description: remove autostart symlinks when deleting a container
 Note autostart symlinks are not upstream.
Author: Serge Hallyn <serge.hallyn@ubuntu.com>
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/930525
Forwarded: no

Index: lxc/src/lxc/lxc-destroy.in
===================================================================
--- lxc.orig/src/lxc/lxc-destroy.in	2012-02-15 23:25:06.014478000 -0600
+++ lxc/src/lxc/lxc-destroy.in	2012-02-15 23:51:54.637231790 -0600
@@ -111,3 +111,14 @@
 fi
 # recursively remove the container to remove old container configuration
 rm -rf --preserve-root $lxc_path/$lxc_name
+
+# remove any autostart symlinks pointing to this container.
+ls /etc/lxc/auto/* > /dev/null 2>&1 || exit 0;
+for f in /etc/lxc/auto/*; do
+	if [ -h "$f" ]; then
+		l=`readlink $f`
+		if [ $l = $lxc_path/$lxc_name/config ]; then
+			rm -f $f
+		fi
+	fi
+done
