forked from pool/warewulf4
Christian Goll
74ff5d3e49
warewulf4 is rewirte of warewulf in go OBS-URL: https://build.opensuse.org/request/show/923039 OBS-URL: https://build.opensuse.org/package/show/network:cluster/warewulf4?expand=0&rev=1
129 lines
5.2 KiB
Diff
129 lines
5.2 KiB
Diff
From b670e183470c97e7fc0a266866ec3e9964084d12 Mon Sep 17 00:00:00 2001
|
|
From: Christian Goll <cgoll@suse.de>
|
|
Date: Wed, 21 Jul 2021 12:45:16 +0200
|
|
Subject: [PATCH] LocalStateDir is configureable to meet FHS
|
|
|
|
---
|
|
Makefile | 27 +++++++++++-----------
|
|
internal/app/wwctl/configure/nfs/main.go | 2 +-
|
|
internal/pkg/config/config.go | 16 ++++++++++---
|
|
internal/pkg/warewulfconf/datastructure.go | 1 +
|
|
4 files changed, 29 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/Makefile b/Makefile
|
|
index 0babd54..7169b6c 100644
|
|
--- a/Makefile
|
|
+++ b/Makefile
|
|
@@ -1,6 +1,7 @@
|
|
.PHONY: all
|
|
|
|
VERSION := 4.2.0
|
|
+LOCALSTATE ?= /var/warewulf/
|
|
|
|
# auto installed tooling
|
|
TOOLS_DIR := .tools
|
|
@@ -52,8 +53,8 @@ debian: all
|
|
|
|
files: all
|
|
install -d -m 0755 $(DESTDIR)/usr/bin/
|
|
- install -d -m 0755 $(DESTDIR)/var/warewulf/
|
|
- install -d -m 0755 $(DESTDIR)/var/warewulf/chroots
|
|
+ install -d -m 0755 $(DESTDIR)$(LOCALSTATE)/
|
|
+ install -d -m 0755 $(DESTDIR)$(LOCALSTATE)/chroots
|
|
install -d -m 0755 $(DESTDIR)/etc/warewulf/
|
|
install -d -m 0755 $(DESTDIR)/etc/warewulf/ipxe
|
|
install -d -m 0755 $(DESTDIR)/var/lib/tftpboot/warewulf/ipxe/
|
|
@@ -63,12 +64,12 @@ files: all
|
|
test -f $(DESTDIR)/etc/warewulf/hosts.tmpl || install -m 644 etc/hosts.tmpl $(DESTDIR)/etc/warewulf/
|
|
cp -r etc/dhcp $(DESTDIR)/etc/warewulf/
|
|
cp -r etc/ipxe $(DESTDIR)/etc/warewulf/
|
|
- cp -r overlays $(DESTDIR)/var/warewulf/
|
|
- chmod +x $(DESTDIR)/var/warewulf/overlays/system/default/init
|
|
- chmod 600 $(DESTDIR)/var/warewulf/overlays/system/default/etc/ssh/ssh*
|
|
- chmod 644 $(DESTDIR)/var/warewulf/overlays/system/default/etc/ssh/ssh*.pub.ww
|
|
- mkdir -p $(DESTDIR)/var/warewulf/overlays/system/default/warewulf/bin/
|
|
- cp wwclient $(DESTDIR)/var/warewulf/overlays/system/default/warewulf/bin/
|
|
+ cp -r overlays $(DESTDIR)$(LOCALSTATE)/
|
|
+ chmod +x $(DESTDIR)$(LOCALSTATE)/overlays/system/default/init
|
|
+ chmod 600 $(DESTDIR)$(LOCALSTATE)/overlays/system/default/etc/ssh/ssh*
|
|
+ chmod 644 $(DESTDIR)$(LOCALSTATE)/overlays/system/default/etc/ssh/ssh*.pub.ww
|
|
+ mkdir -p $(DESTDIR)$(LOCALSTATE)/overlays/system/default/warewulf/bin/
|
|
+ cp wwclient $(DESTDIR)$(LOCALSTATE)/overlays/system/default/warewulf/bin/
|
|
cp wwctl $(DESTDIR)/usr/bin/
|
|
mkdir -p $(DESTDIR)/usr/lib/firewalld/services
|
|
install -c -m 0644 include/firewalld/warewulf.xml $(DESTDIR)/usr/lib/firewalld/services
|
|
@@ -82,11 +83,11 @@ files: all
|
|
# restorecon -r /var/lib/tftpboot/warewulf
|
|
|
|
debfiles: debian
|
|
- chmod +x $(DESTDIR)/var/warewulf/overlays/system/debian/init
|
|
- chmod 600 $(DESTDIR)/var/warewulf/overlays/system/debian/etc/ssh/ssh*
|
|
- chmod 644 $(DESTDIR)/var/warewulf/overlays/system/debian/etc/ssh/ssh*.pub.ww
|
|
- mkdir -p $(DESTDIR)/var/warewulf/overlays/system/debian/warewulf/bin/
|
|
- cp wwclient $(DESTDIR)/var/warewulf/overlays/system/debian/warewulf/bin/
|
|
+ chmod +x $(DESTDIR)$(LOCALSTATE)/overlays/system/debian/init
|
|
+ chmod 600 $(DESTDIR)$(LOCALSTATE)/overlays/system/debian/etc/ssh/ssh*
|
|
+ chmod 644 $(DESTDIR)$(LOCALSTATE)/overlays/system/debian/etc/ssh/ssh*.pub.ww
|
|
+ mkdir -p $(DESTDIR)$(LOCALSTATE)/overlays/system/debian/warewulf/bin/
|
|
+ cp wwclient $(DESTDIR)$(LOCALSTATE)/overlays/system/debian/warewulf/bin/
|
|
|
|
wwctl:
|
|
cd cmd/wwctl; GOOS=linux go build -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../wwctl
|
|
diff --git a/internal/app/wwctl/configure/nfs/main.go b/internal/app/wwctl/configure/nfs/main.go
|
|
index 7827b24..4657f66 100644
|
|
--- a/internal/app/wwctl/configure/nfs/main.go
|
|
+++ b/internal/app/wwctl/configure/nfs/main.go
|
|
@@ -40,7 +40,7 @@ func Configure(show bool) error {
|
|
}
|
|
defer exports.Close()
|
|
|
|
- fstab, err := os.OpenFile("/var/warewulf/overlays/system/default/etc/fstab", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
|
+ fstab, err := os.OpenFile(fmt.Sprintf("%s/overlays/system/default/etc/fstab",controller.LocalStateDir), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
|
if err != nil {
|
|
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
|
os.Exit(1)
|
|
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
|
|
index 34a9f00..c08221d 100644
|
|
--- a/internal/pkg/config/config.go
|
|
+++ b/internal/pkg/config/config.go
|
|
@@ -6,11 +6,21 @@ import (
|
|
|
|
"github.com/hpcng/warewulf/internal/pkg/util"
|
|
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
|
+ "github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
|
)
|
|
|
|
-const (
|
|
- LocalStateDir = "/var/warewulf"
|
|
-)
|
|
+var LocalStateDir = "/var/warewulf"
|
|
+
|
|
+func init() {
|
|
+ conf, err := warewulfconf.New()
|
|
+ if err != nil {
|
|
+ wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
|
+ return
|
|
+ }
|
|
+ if conf.LocalStateDir != "" {
|
|
+ LocalStateDir = conf.LocalStateDir
|
|
+ }
|
|
+}
|
|
|
|
func OverlayDir() string {
|
|
return fmt.Sprintf("%s/overlays/", LocalStateDir)
|
|
diff --git a/internal/pkg/warewulfconf/datastructure.go b/internal/pkg/warewulfconf/datastructure.go
|
|
index 8315ddd..a688617 100644
|
|
--- a/internal/pkg/warewulfconf/datastructure.go
|
|
+++ b/internal/pkg/warewulfconf/datastructure.go
|
|
@@ -13,6 +13,7 @@ type ControllerConf struct {
|
|
Netmask string `yaml:"netmask"`
|
|
Network string `yaml:"network,omitempty"`
|
|
Fqdn string `yaml:"fqdn,omitempty"`
|
|
+ LocalStateDir string `yaml:"localstatedir"`
|
|
Warewulf *WarewulfConf `yaml:"warewulf"`
|
|
Dhcp *DhcpConf `yaml:"dhcp"`
|
|
Tftp *TftpConf `yaml:"tftp"`
|
|
--
|
|
2.33.0
|
|
|