[Libguestfs] [PATCH 1/2] customize: firstboot: Factor out the name of the systemd target.

Richard W.M. Jones rjones at redhat.com
Sun Jul 16 21:02:23 UTC 2017


Currently we install the firstboot service under systemd target
‘default.target’.  This change simply factors out this name.

Note that the name is not factored out in the code which deletes the
old ‘/etc/systemd/system/default.target.wants/firstboot.service’ file,
since that would have always been installed in the same location.
---
 customize/firstboot.ml | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/customize/firstboot.ml b/customize/firstboot.ml
index 41aa52dac..35cb87c2b 100644
--- a/customize/firstboot.ml
+++ b/customize/firstboot.ml
@@ -80,6 +80,8 @@ then
 fi
 " firstboot_dir firstboot_dir
 
+  let systemd_target = "default.target"
+
   let firstboot_service = sprintf "\
 [Unit]
 Description=libguestfs firstboot service
@@ -94,8 +96,8 @@ StandardOutput=journal+console
 StandardError=inherit
 
 [Install]
-WantedBy=default.target
-" firstboot_dir
+WantedBy=%s
+" firstboot_dir systemd_target
 
   let rec install_service (g : Guestfs.guestfs) root distro major =
     g#mkdir_p firstboot_dir;
@@ -124,8 +126,10 @@ WantedBy=default.target
     g#mkdir_p unitdir;
     let unitfile = sprintf "%s/guestfs-firstboot.service" unitdir in
     g#write unitfile firstboot_service;
-    g#mkdir_p "/etc/systemd/system/default.target.wants";
-    g#ln_sf unitfile "/etc/systemd/system/default.target.wants";
+    g#mkdir_p (sprintf "/etc/systemd/system/%s.wants"
+                       systemd_target);
+    g#ln_sf unitfile (sprintf "/etc/systemd/system/%s.wants"
+                              systemd_target);
 
     (* Try to remove the old firstboot.service files. *)
     let oldunitfile = sprintf "%s/firstboot.service" unitdir in
-- 
2.13.2




More information about the Libguestfs mailing list