From 7b31b7291c33712ab34d79e0146f52cca17bb1d9 Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Wed, 29 Jun 2022 17:18:06 +0200 Subject: [PATCH] Try 07 --- pkg/templater/files.go | 2 +- pkg/templater/system_services.go | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/templater/files.go b/pkg/templater/files.go index 540997d..511c2d7 100644 --- a/pkg/templater/files.go +++ b/pkg/templater/files.go @@ -51,7 +51,7 @@ func (cf *ConfigFile) Generate(root string, templateDir string, values []byte) e if err != nil { return fmt.Errorf("Process templates failed with error: %v", err) } - log.Printf("\tConfiguration file %s generated\n", dest) + log.Printf("\tFile %s generated\n", dest) return nil } diff --git a/pkg/templater/system_services.go b/pkg/templater/system_services.go index 2e5936c..c344f4b 100644 --- a/pkg/templater/system_services.go +++ b/pkg/templater/system_services.go @@ -2,6 +2,7 @@ package templater import ( "fmt" + "log" "os" "forge.cadoles.com/pcaseiro/templatefile/pkg/utils" @@ -57,13 +58,13 @@ func (sys *SystemService) Manage() error { } } else { - fmt.Printf("Nothing to do for daemon %s\n", sys.Name) + log.Printf("\nNothing to do for daemon %s\n", sys.Name) } return nil } func (sys *SystemService) Start() error { - fmt.Printf("Starting system service : %s\n", sys.Name) + log.Printf("\tStarting system service : %s\n", sys.Name) if sys.Type == "systemd" { _, stdErr, err := utils.RunSystemCommand("systemctl", "start", sys.Name) if err != nil { @@ -81,7 +82,7 @@ func (sys *SystemService) Start() error { } func (sys *SystemService) Stop() error { - fmt.Printf("Stoping system service : %s\n", sys.Name) + log.Printf("\tStopping system service : %s\n", sys.Name) if sys.Type == "systemd" { _, stdErr, err := utils.RunSystemCommand("systemctl", "stop", sys.Name) if err != nil { @@ -104,11 +105,13 @@ func (sys *SystemService) Enable() error { if err != nil { return fmt.Errorf("System service %s \n * Enable error:\n - %s", sys.Name, stdErr) } + log.Printf("\tSystemd service %s enabled", sys.Name) } else if sys.Type == "openrc" { _, stdErr, err := utils.RunSystemCommand("rc-update", "add", sys.Name, "default") if err != nil { return fmt.Errorf("System service %s \n * Enable error:\n - %s", sys.Name, stdErr) } + log.Printf("\tOpenRC service %s enabled", sys.Name) } else { return fmt.Errorf("Unsupported service type %s for service %s", sys.Type, sys.Name) }