The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/distrobuilder/pull/292

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
This checks the existance of /lib/systemd/system, and uses
/usr/lib/systemd/system if the former doesn't exist.

Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
From 608d4db0b8987798742b3b6ec7821ce5081d54e3 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.h...@canonical.com>
Date: Thu, 27 Feb 2020 16:17:01 +0100
Subject: [PATCH] generator/lxd-agent: Fix systemd units path

This checks the existance of /lib/systemd/system, and uses
/usr/lib/systemd/system if the former doesn't exist.

Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
---
 generators/lxd-agent.go | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/generators/lxd-agent.go b/generators/lxd-agent.go
index cd861eb..9f1b684 100644
--- a/generators/lxd-agent.go
+++ b/generators/lxd-agent.go
@@ -79,12 +79,18 @@ ExecStart=/run/lxd_config/9p/lxd-agent
 WantedBy=multi-user.target
 `
 
-       err := ioutil.WriteFile(filepath.Join(sourceDir, 
"/lib/systemd/system/lxd-agent.service"), []byte(lxdAgentServiceUnit), 0644)
+       systemdPath := filepath.Join("/", "lib", "systemd", "system")
+
+       if !lxd.PathExists(filepath.Dir(filepath.Join(sourceDir, systemdPath))) 
{
+               systemdPath = filepath.Join("/", "usr", "lib", "systemd", 
"system")
+       }
+
+       err := ioutil.WriteFile(filepath.Join(sourceDir, systemdPath, 
"lxd-agent.service"), []byte(lxdAgentServiceUnit), 0644)
        if err != nil {
                return err
        }
 
-       err = os.Symlink("/lib/systemd/system/lxd-agent.service", 
filepath.Join(sourceDir, 
"/etc/systemd/system/multi-user.target.wants/lxd-agent.service"))
+       err = os.Symlink(filepath.Join(sourceDir, systemdPath, 
"lxd-agent.service"), filepath.Join(sourceDir, 
"/etc/systemd/system/multi-user.target.wants/lxd-agent.service"))
        if err != nil {
                return err
        }
@@ -106,12 +112,12 @@ ExecStart=/bin/mount -t 9p config /run/lxd_config/9p -o 
access=0
 WantedBy=multi-user.target
 `
 
-       err = ioutil.WriteFile(filepath.Join(sourceDir, 
"/lib/systemd/system/lxd-agent-9p.service"), []byte(lxdConfigShareMountUnit), 
0644)
+       err = ioutil.WriteFile(filepath.Join(sourceDir, systemdPath, 
"lxd-agent-9p.service"), []byte(lxdConfigShareMountUnit), 0644)
        if err != nil {
                return err
        }
 
-       err = os.Symlink("/lib/systemd/system/lxd-agent-9p.service", 
filepath.Join(sourceDir, 
"/etc/systemd/system/multi-user.target.wants/lxd-agent-9p.service"))
+       err = os.Symlink(filepath.Join(sourceDir, systemdPath, 
"lxd-agent-9p.service"), filepath.Join(sourceDir, 
"/etc/systemd/system/multi-user.target.wants/lxd-agent-9p.service"))
        if err != nil {
                return err
        }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to