]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-debian: adjust init system configurations
authorCameron Norman <camerontnorman@gmail.com>
Mon, 1 Dec 2014 21:29:26 +0000 (13:29 -0800)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 2 Dec 2014 15:59:16 +0000 (10:59 -0500)
Do as much as possible to allow containers switching from non-systemd to
systemd to work as intended (but nothing that will cause side effects).
Use update-rc.d disable instead of remove so the init scripts are not
re-enabled when the package is updated

Signed-off-by: Cameron Norman <camerontnorman@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
templates/lxc-debian.in

index 7e2f8f57dc2aea50a9cba2bcf2c56e7053668833..ba225f9052562ce923e5734199f72bfcc5188830 100644 (file)
@@ -108,10 +108,10 @@ EOF
     fi
 
     # remove pointless services in a container
-    chroot $rootfs /usr/sbin/update-rc.d -f checkroot.sh remove
-    chroot $rootfs /usr/sbin/update-rc.d -f umountfs remove
-    chroot $rootfs /usr/sbin/update-rc.d -f hwclock.sh remove
-    chroot $rootfs /usr/sbin/update-rc.d -f hwclockfirst.sh remove
+    chroot $rootfs /usr/sbin/update-rc.d -f checkroot.sh disable
+    chroot $rootfs /usr/sbin/update-rc.d -f umountfs disable
+    chroot $rootfs /usr/sbin/update-rc.d -f hwclock.sh disable
+    chroot $rootfs /usr/sbin/update-rc.d -f hwclockfirst.sh disable
 
     # generate new SSH keys
     if [ -x $rootfs/var/lib/dpkg/info/openssh-server.postinst ]; then
@@ -187,26 +187,33 @@ configure_debian_systemd()
 {
     path=$1
     rootfs=$2
+
     init="$(chroot ${rootfs} dpkg-query --search /sbin/init | cut -d : -f 1)"
-    if [ "$init" != "systemd-sysv" ]; then
-       # systemd is not PID 1
-       return
+    if [ "$init" = "systemd-sysv" ]; then
+       # only appropiate when systemd is PID 1
+       echo 'lxc.autodev = 1' >> "$path/config"
+       echo 'lxc.kmsg = 0' >> "$path/config"
+    fi
+
+    # this only works if we have getty@.service to manipulate
+    if [ -f ${rootfs}/lib/systemd/system/getty\@.service ]; then
+       sed -e 's/^ConditionPathExists=/# ConditionPathExists=/' \
+           -e 's/After=dev-%i.device/After=/' \
+           < ${rootfs}/lib/systemd/system/getty\@.service \
+           > ${rootfs}/etc/systemd/system/getty\@.service
     fi
 
-    echo 'lxc.autodev = 1' >> "$path/config"
-    echo 'lxc.kmsg = 0' >> "$path/config"
+    # just in case systemd is not installed
+    mkdir -p ${rootfs}/{lib,etc}/systemd/system
+    mkdir -p ${rootfs}/etc/systemd/system/getty.target.wants
 
     # This function has been copied and adapted from lxc-fedora
     rm -f ${rootfs}/etc/systemd/system/default.target
     touch ${rootfs}/etc/fstab
-    chroot ${rootfs} ln -s /dev/null /etc/systemd/system/udev.service
+    chroot ${rootfs} ln -s /dev/null /etc/systemd/system/systemd-udevd.service
     chroot ${rootfs} ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
     # Make systemd honor SIGPWR
     chroot ${rootfs} ln -s /lib/systemd/system/halt.target /etc/systemd/system/sigpwr.target
-    sed -e 's/^ConditionPathExists=/# ConditionPathExists=/' \
-        -e 's/After=dev-%i.device/After=/' \
-        < ${rootfs}/lib/systemd/system/getty\@.service \
-        > ${rootfs}/etc/systemd/system/getty\@.service
     # Setup getty service on the 4 ttys we are going to allow in the
     # default config.  Number should match lxc.tty
     ( cd ${rootfs}/etc/systemd/system/getty.target.wants