[lxc-devel] [lxc/master] Execute script lxc-devsetup also with sysvinit and upstart.

clopez on Github lxc-bot at linuxcontainers.org
Fri Mar 4 16:13:01 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 490 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160304/934e5e16/attachment.bin>
-------------- next part --------------
From 3c16ff809a7b89e9b2219add0730730cc5a6721b Mon Sep 17 00:00:00 2001
From: Carlos Alberto Lopez Perez <clopez at igalia.com>
Date: Fri, 4 Mar 2016 16:40:21 +0100
Subject: [PATCH] Execute script lxc-devsetup also with sysvinit and upstart.

  * This script sets /dev/.lxc which is needed for autodev containers.
  * Previously was only executed with systemd. Execute it also with
    the other init systems (sysvinit and upstart)
---
 config/init/common/Makefile.am         |  2 +-
 config/init/common/lxc-devsetup        | 25 +++++++++++
 config/init/systemd/Makefile.am        |  5 +--
 config/init/systemd/lxc-devsetup       | 25 -----------
 config/init/sysvinit/lxc-containers.in |  2 +
 config/init/upstart/Makefile.am        |  2 +-
 config/init/upstart/lxc.conf           | 74 --------------------------------
 config/init/upstart/lxc.conf.in        | 77 ++++++++++++++++++++++++++++++++++
 configure.ac                           |  1 +
 9 files changed, 109 insertions(+), 104 deletions(-)
 create mode 100755 config/init/common/lxc-devsetup
 delete mode 100755 config/init/systemd/lxc-devsetup
 delete mode 100644 config/init/upstart/lxc.conf
 create mode 100644 config/init/upstart/lxc.conf.in

diff --git a/config/init/common/Makefile.am b/config/init/common/Makefile.am
index 8c0134c..6d1a077 100644
--- a/config/init/common/Makefile.am
+++ b/config/init/common/Makefile.am
@@ -1,2 +1,2 @@
 EXTRA_DIST = lxc-containers.in lxc-net.in
-pkglibexec_SCRIPTS = lxc-containers lxc-net
+pkglibexec_SCRIPTS = lxc-containers lxc-net lxc-devsetup
diff --git a/config/init/common/lxc-devsetup b/config/init/common/lxc-devsetup
new file mode 100755
index 0000000..e765daf
--- /dev/null
+++ b/config/init/common/lxc-devsetup
@@ -0,0 +1,25 @@
+#!/bin/sh -
+
+# lxc.devsetup - Setup host /dev for container /dev subdirectories.
+
+if [ ! -d /dev/.lxc ]
+then
+    echo "Creating /dev/.lxc"
+    mkdir /dev/.lxc
+    chmod 755 /dev/.lxc
+fi
+
+if grep -q "/dev devtmpfs " /proc/self/mounts
+then
+    echo "/dev is devtmpfs"
+else
+    echo "/dev is not devtmpfs - mounting tmpfs on .lxc"
+    mount -t tmpfs tmpfs /dev/.lxc
+fi
+
+if [ ! -d /dev/.lxc/user ]
+then
+    echo "Creating /dev/.lxc/user"
+    mkdir /dev/.lxc/user
+    chmod 1777 /dev/.lxc/user
+fi
diff --git a/config/init/systemd/Makefile.am b/config/init/systemd/Makefile.am
index d0f8205..c448850 100644
--- a/config/init/systemd/Makefile.am
+++ b/config/init/systemd/Makefile.am
@@ -1,5 +1,4 @@
 EXTRA_DIST = \
-	lxc-devsetup \
 	lxc-apparmor-load \
 	lxc.service.in \
 	lxc at .service.in \
@@ -8,7 +7,7 @@ EXTRA_DIST = \
 if INIT_SCRIPT_SYSTEMD
 BUILT_SOURCES = lxc.service lxc at .service lxc-net.service
 
-install-systemd: lxc.service lxc at .service lxc-net.service lxc-devsetup lxc-apparmor-load
+install-systemd: lxc.service lxc at .service lxc-net.service lxc-apparmor-load
 	$(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
 	$(INSTALL_DATA) lxc.service lxc at .service lxc-net.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
 
@@ -18,7 +17,7 @@ uninstall-systemd:
 	rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc-net.service
 	rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) || :
 
-pkglibexec_SCRIPTS = lxc-devsetup lxc-apparmor-load
+pkglibexec_SCRIPTS = lxc-apparmor-load
 
 install-data-local: install-systemd
 uninstall-local: uninstall-systemd
diff --git a/config/init/systemd/lxc-devsetup b/config/init/systemd/lxc-devsetup
deleted file mode 100755
index e765daf..0000000
--- a/config/init/systemd/lxc-devsetup
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh -
-
-# lxc.devsetup - Setup host /dev for container /dev subdirectories.
-
-if [ ! -d /dev/.lxc ]
-then
-    echo "Creating /dev/.lxc"
-    mkdir /dev/.lxc
-    chmod 755 /dev/.lxc
-fi
-
-if grep -q "/dev devtmpfs " /proc/self/mounts
-then
-    echo "/dev is devtmpfs"
-else
-    echo "/dev is not devtmpfs - mounting tmpfs on .lxc"
-    mount -t tmpfs tmpfs /dev/.lxc
-fi
-
-if [ ! -d /dev/.lxc/user ]
-then
-    echo "Creating /dev/.lxc/user"
-    mkdir /dev/.lxc/user
-    chmod 1777 /dev/.lxc/user
-fi
diff --git a/config/init/sysvinit/lxc-containers.in b/config/init/sysvinit/lxc-containers.in
index bc93322..7a55c3b 100644
--- a/config/init/sysvinit/lxc-containers.in
+++ b/config/init/sysvinit/lxc-containers.in
@@ -30,6 +30,8 @@ if ! type action >/dev/null 2>&1; then
 fi
 
 start() {
+    # Setup host /dev for autodev containers.
+    @LIBEXECDIR@/lxc/lxc-devsetup
     action $"Starting LXC autoboot containers: " @LIBEXECDIR@/lxc/lxc-containers start
 }
 
diff --git a/config/init/upstart/Makefile.am b/config/init/upstart/Makefile.am
index 916b850..3702633 100644
--- a/config/init/upstart/Makefile.am
+++ b/config/init/upstart/Makefile.am
@@ -1,4 +1,4 @@
-EXTRA_DIST = lxc.conf lxc-instance.conf lxc-net.conf.in
+EXTRA_DIST = lxc.conf.in lxc-instance.conf lxc-net.conf.in
 
 if INIT_SCRIPT_UPSTART
 install-upstart: lxc.conf lxc-instance.conf lxc-net.conf
diff --git a/config/init/upstart/lxc.conf b/config/init/upstart/lxc.conf
deleted file mode 100644
index 437db3c..0000000
--- a/config/init/upstart/lxc.conf
+++ /dev/null
@@ -1,74 +0,0 @@
-description "lxc"
-author "Serge Hallyn <serge.hallyn at canonical.com>"
-
-start on runlevel [2345]
-stop on starting rc RUNLEVEL=[016]
-
-env LXC_AUTO="false"
-
-# These can be overridden in /etc/default/lxc
-
-# BOOTGROUPS - What groups should start on bootup?
-#	Comma separated list of groups.
-#	Leading comma, trailing comma or embedded double
-#	comma indicates when the NULL group should be run.
-# Example (default): boot the onboot group first then the NULL group
-env BOOTGROUPS="onboot,"
-
-# SHUTDOWNDELAY - Wait time for a container to shut down.
-#	Container shutdown can result in lengthy system
-#	shutdown times.  Even 5 seconds per container can be
-#	too long.
-env SHUTDOWNDELAY=5
-
-# OPTIONS can be used for anything else.
-#	If you want to boot everything then
-#	options can be "-a" or "-a -A".
-env OPTIONS=
-
-# STOPOPTS are stop options.  The can be used for anything else to stop.
-#	If you want to kill containers fast, use -k
-env STOPOPTS="-a -A -s"
-
-pre-start script
-	[ -f /etc/default/lxc ] && . /etc/default/lxc
-
-	# don't load profiles if mount mediation is not supported
-	SYSF=/sys/kernel/security/apparmor/features/mount/mask
-	if [ -f $SYSF ]; then
-		if [ -x /lib/apparmor/profile-load ]; then
-			/lib/apparmor/profile-load usr.bin.lxc-start
-			/lib/apparmor/profile-load lxc-containers
-		elif [ -x /lib/init/apparmor-profile-load ]; then
-			/lib/init/apparmor-profile-load usr.bin.lxc-start
-			/lib/init/apparmor-profile-load lxc-containers
-		fi
-	fi
-
-	[ "x$LXC_AUTO" = "xtrue" ] || exit 0
-
-	if [ -n "$BOOTGROUPS" ]
-	then
-		BOOTGROUPS="-g $BOOTGROUPS"
-	fi
-
-	# Process the "onboot" group first then the NULL group.
-	lxc-autostart -L $OPTIONS $BOOTGROUPS | while read line; do
-		set -- $line
-		(start lxc-instance NAME=$1 && sleep $2) || true
-	done
-end script
-
-# The stop is serialized and can take excessive time.  We need to avoid
-# delaying the system shutdown / reboot as much as we can since it's not
-# parallelized...  Even 5 second timout may be too long.
-post-stop script
-	[ -f /etc/default/lxc ] && . /etc/default/lxc
-
-	if [ -n "$SHUTDOWNDELAY" ]
-	then
-		SHUTDOWNDELAY="-t $SHUTDOWNDELAY"
-	fi
-
-	lxc-autostart $STOPOPTS $SHUTDOWNDELAY || true
-end script
diff --git a/config/init/upstart/lxc.conf.in b/config/init/upstart/lxc.conf.in
new file mode 100644
index 0000000..899fe11
--- /dev/null
+++ b/config/init/upstart/lxc.conf.in
@@ -0,0 +1,77 @@
+description "lxc"
+author "Serge Hallyn <serge.hallyn at canonical.com>"
+
+start on runlevel [2345]
+stop on starting rc RUNLEVEL=[016]
+
+env LXC_AUTO="false"
+
+# These can be overridden in /etc/default/lxc
+
+# BOOTGROUPS - What groups should start on bootup?
+#	Comma separated list of groups.
+#	Leading comma, trailing comma or embedded double
+#	comma indicates when the NULL group should be run.
+# Example (default): boot the onboot group first then the NULL group
+env BOOTGROUPS="onboot,"
+
+# SHUTDOWNDELAY - Wait time for a container to shut down.
+#	Container shutdown can result in lengthy system
+#	shutdown times.  Even 5 seconds per container can be
+#	too long.
+env SHUTDOWNDELAY=5
+
+# OPTIONS can be used for anything else.
+#	If you want to boot everything then
+#	options can be "-a" or "-a -A".
+env OPTIONS=
+
+# STOPOPTS are stop options.  The can be used for anything else to stop.
+#	If you want to kill containers fast, use -k
+env STOPOPTS="-a -A -s"
+
+pre-start script
+	[ -f /etc/default/lxc ] && . /etc/default/lxc
+
+	# don't load profiles if mount mediation is not supported
+	SYSF=/sys/kernel/security/apparmor/features/mount/mask
+	if [ -f $SYSF ]; then
+		if [ -x /lib/apparmor/profile-load ]; then
+			/lib/apparmor/profile-load usr.bin.lxc-start
+			/lib/apparmor/profile-load lxc-containers
+		elif [ -x /lib/init/apparmor-profile-load ]; then
+			/lib/init/apparmor-profile-load usr.bin.lxc-start
+			/lib/init/apparmor-profile-load lxc-containers
+		fi
+	fi
+
+	# Setup host /dev for autodev containers.
+	@LIBEXECDIR@/lxc/lxc-devsetup
+
+	[ "x$LXC_AUTO" = "xtrue" ] || exit 0
+
+	if [ -n "$BOOTGROUPS" ]
+	then
+		BOOTGROUPS="-g $BOOTGROUPS"
+	fi
+
+	# Process the "onboot" group first then the NULL group.
+	lxc-autostart -L $OPTIONS $BOOTGROUPS | while read line; do
+		set -- $line
+		(start lxc-instance NAME=$1 && sleep $2) || true
+	done
+end script
+
+# The stop is serialized and can take excessive time.  We need to avoid
+# delaying the system shutdown / reboot as much as we can since it's not
+# parallelized...  Even 5 second timout may be too long.
+post-stop script
+	[ -f /etc/default/lxc ] && . /etc/default/lxc
+
+	if [ -n "$SHUTDOWNDELAY" ]
+	then
+		SHUTDOWNDELAY="-t $SHUTDOWNDELAY"
+	fi
+
+	lxc-autostart $STOPOPTS $SHUTDOWNDELAY || true
+end script
diff --git a/configure.ac b/configure.ac
index 4756493..84e24eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -650,6 +650,7 @@ AC_CONFIG_FILES([
 	config/init/sysvinit/Makefile
 	config/init/sysvinit/lxc-containers
 	config/init/sysvinit/lxc-net
+	config/init/upstart/lxc.conf
 	config/init/upstart/lxc-net.conf
 	config/init/upstart/Makefile
 	config/etc/Makefile


More information about the lxc-devel mailing list