From c7af020c3d90d95b1ae3fb0af40bda7587fed38a Mon Sep 17 00:00:00 2001 From: Ryan Harper Date: Tue, 27 Jun 2023 15:38:48 -0500 Subject: [PATCH] machined install should create systemd user unit directory On server installs (Ubuntu Server at least) the user's .config path to systemd user units may not be present. Ensure this path exists for attempting to render the unit template file. Signed-off-by: Ryan Harper --- cmd/machined/cmd/install.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/machined/cmd/install.go b/cmd/machined/cmd/install.go index 63779fa..22443d3 100644 --- a/cmd/machined/cmd/install.go +++ b/cmd/machined/cmd/install.go @@ -25,6 +25,11 @@ func doInstall(cmd *cobra.Command, args []string) error { if err != nil { return fmt.Errorf("Failed to get Systemd Unit Path: %s", err) } + if !api.PathExists(unitPath) { + if err := api.EnsureDir(unitPath); err != nil { + return fmt.Errorf("Failed to create Systemd Unit path %q: %s", unitPath, err) + } + } serviceUnit := filepath.Join(unitPath, MachinedServiceUnit) socketUnit := filepath.Join(unitPath, MachinedSocketUnit) customService := cmd.Flag("service-template").Value.String()