Properly support relative paths to the SYSCONFDIR

This commit is contained in:
Gregory Kurtzer
2022-01-26 03:46:39 +00:00
parent af32998c2b
commit 2d880aae76
10 changed files with 16 additions and 12 deletions

View File

@@ -5,14 +5,18 @@ import (
"path"
"strings"
"github.com/hpcng/warewulf/internal/pkg/buildconfig"
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
)
func templateFileInclude(path string) string {
wwlog.Printf(wwlog.DEBUG, "Including file into template: %s\n", path)
content, err := ioutil.ReadFile(path)
func templateFileInclude(inc string) string {
if !strings.HasPrefix(inc, "/") {
inc = path.Join(buildconfig.SYSCONFDIR(), "warewulf", inc)
}
wwlog.Printf(wwlog.DEBUG, "Including file into template: %s\n", inc)
content, err := ioutil.ReadFile(inc)
if err != nil {
wwlog.Printf(wwlog.VERBOSE, "Could not include file into template: %s\n", err)
}

View File

@@ -1 +1 @@
{{Include "/etc/warewulf/keys/ssh_host_dsa_key.pub"}}
{{Include "keys/ssh_host_dsa_key.pub"}}

View File

@@ -1 +1 @@
{{Include "/etc/warewulf/keys/ssh_host_dsa_key"}}
{{Include "keys/ssh_host_dsa_key"}}

View File

@@ -1 +1 @@
{{Include "/etc/warewulf/keys/ssh_host_ecdsa_key.pub"}}
{{Include "keys/ssh_host_ecdsa_key.pub"}}

View File

@@ -1 +1 @@
{{Include "/etc/warewulf/keys/ssh_host_ecdsa_key"}}
{{Include "keys/ssh_host_ecdsa_key"}}

View File

@@ -1 +1 @@
{{Include "/etc/warewulf/keys/ssh_host_ed25519_key.pub"}}
{{Include "keys/ssh_host_ed25519_key.pub"}}

View File

@@ -1 +1 @@
{{Include "/etc/warewulf/keys/ssh_host_ed25519_key"}}
{{Include "keys/ssh_host_ed25519_key"}}

View File

@@ -1 +1 @@
{{Include "/etc/warewulf/keys/ssh_host_rsa_key.pub"}}
{{Include "keys/ssh_host_rsa_key.pub"}}

View File

@@ -1 +1 @@
{{Include "/etc/warewulf/keys/ssh_host_rsa_key"}}
{{Include "keys/ssh_host_rsa_key"}}

View File

@@ -1 +1 @@
{{Include "/etc/warewulf/warewulf.conf"}}
{{Include "warewulf.conf"}}