[lxc-devel] [PATCH] Improve check for systemd in the template for Fedora

Satoshi Matsumoto kaorimatz at gmail.com
Tue Aug 13 07:36:42 UTC 2013


Configure the guest init based on whether the PID 1 process is systemd
or not.

In the template for Fedora, currently the guest is configured based on
whether the /bin/systemd exists in the host or not. This doesn't work
correctly because the /usr/bin/systemd symlink has been removed from the
systemd package in Fedora 20 (Rawhide) and Arch Linux.

Signed-off-by: Satoshi Matsumoto <kaorimatz at gmail.com>
---
I've proposed this patch as a pull request on the github [1], and got a
comment that the original code may not make sense. In
configure_fedora_systemd() and configure_fedora_init(), we are
configuring the guest init not the host init, so it seems to be correct
to configure the guest init based on whether the guest is based on
systemd or not. In that case, I think the code should look like this:

if [ $release -gt 14 ]; then
  configure_fedora_systemd
else
  configure_fedora_init
fi

[1] https://github.com/lxc/lxc/pull/29

 templates/lxc-fedora.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in
index 23728c6..36c3d21 100644
--- a/templates/lxc-fedora.in
+++ b/templates/lxc-fedora.in
@@ -567,7 +567,7 @@ if [ $? -ne 0 ]; then
     exit 1
 fi
 
-type /bin/systemd >/dev/null 2>&1
+test $(ps --no-headers -o comm 1) = 'systemd'
 if [ $? -ne 0 ]; then
     configure_fedora_init
 else
-- 
1.8.3.1





More information about the lxc-devel mailing list