* Use Conflicts instead of Breaks against sysvinit-core. This avoids
/sbin/init going missing when switching from systemd-sysv to sysvinit.
While at it, add a Replaces: upstart. (Closes: #751589)
+ * Make the SysV compat tools try both /run/initctl and /dev/initctl. This
+ makes them usable under sysvinit as PID 1 without requiring any symlinks.
[ Michael Stapelberg ]
* Clarify that “systemd” does not influence init whereas “systemd-sysv” does
--- /dev/null
+From: Michael Biebl <biebl@debian.org>
+Date: Tue, 24 Jun 2014 12:35:25 +0200
+Subject: Add /run/initctl support to SysV compat tools
+
+sysvinit in Debian uses /run/initctl as FIFO to communicate with PID 1.
+Make the SysV compat tools in systemd-sysv try both /run/initctl and the
+traditional /dev/initctl. This makes them usable when running sysvinit
+as PID 1.
+---
+ src/systemctl/systemctl.c | 17 +++++++++++------
+ 1 file changed, 11 insertions(+), 6 deletions(-)
+
+diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
+index 3147c4a..61d181b 100644
+--- a/src/systemctl/systemctl.c
++++ b/src/systemctl/systemctl.c
+@@ -5589,19 +5589,24 @@ static int talk_initctl(void) {
+ request.cmd = INIT_CMD_RUNLVL;
+ request.runlevel = rl;
+
+- fd = open(INIT_FIFO, O_WRONLY|O_NDELAY|O_CLOEXEC|O_NOCTTY);
++ /* Try /run/initctl first since that is what sysvinit in Debian uses */
++ fd = open("/run/initctl", O_WRONLY|O_NDELAY|O_CLOEXEC|O_NOCTTY);
+ if (fd < 0) {
+- if (errno == ENOENT)
+- return 0;
++ /* Fall back to /dev/initctl */
++ fd = open(INIT_FIFO, O_WRONLY|O_NDELAY|O_CLOEXEC|O_NOCTTY);
++ if (fd < 0) {
++ if (errno == ENOENT)
++ return 0;
+
+- log_error("Failed to open "INIT_FIFO": %m");
+- return -errno;
++ log_error("Failed to open initctl FIFO: %m");
++ return -errno;
++ }
+ }
+
+ errno = 0;
+ r = loop_write(fd, &request, sizeof(request), false) != sizeof(request);
+ if (r) {
+- log_error("Failed to write to "INIT_FIFO": %m");
++ log_error("Failed to write to initctl FIFO: %m");
+ return errno > 0 ? -errno : -EIO;
+ }
+
+++ /dev/null
-#!/bin/sh
-
-set -e
-
-# We are installing systemd-sysv but systemd is not running.
-# This most likely means we are upgrading from another init, possibly a newer
-# sysvinit version which created the initctl socket at /run/initctl.
-# systemd's sysv tools expect the socket at /dev/initctl, so create the compat
-# symlink ourselves.
-if [ ! -d /run/systemd/system ] ; then
- if [ ! -p /dev/initctl ] && [ -p /run/initctl ] ; then
- ln -sf /run/initctl /dev/initctl
- fi
-fi
-
-#DEBHELPER#
fi
fi
-# Create /run/initctl → /dev/initctl compat symlink on upgrades
-if [ -d /run/systemd/system ]; then
- _systemctl restart systemd-initctl.socket || true
-fi
-
if dpkg --compare-versions "$2" lt "40-1"; then
# /lib/init/rw has been replaced by /run, so try to remove it on upgrades
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=643699
if [ -d /lib/init/rw ]; then
rmdir --ignore-fail-on-non-empty /lib/init/rw || true
fi
-
- # Create /run/initctl → /dev/initctl compat symlink on upgrades
- if [ -d /run/systemd/system ]; then
- ln -sf /dev/initctl /run/initctl
- fi
fi
systemd-machine-id-setup