Try 07
This commit is contained in:
parent
790015d412
commit
7b31b7291c
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue