Added some fixes to #184

This commit is contained in:
Gregory Kurtzer
2021-12-28 16:50:07 -08:00
parent ed57dbfe32
commit f745d90c9c
3 changed files with 38 additions and 26 deletions

View File

@@ -18,6 +18,11 @@ tftp:
systemd name: tftp
nfs:
systemd name: nfs-server
exports:
- /home
- /var/warewulf
export paths:
- path: /home
export options: rw,sync
mount options: default
mount: true
- path: /opt
export options: ro,sync,no_root_squash
mount: false

View File

@@ -64,9 +64,15 @@ func Configure(show bool) error {
}
for _, export := range controller.Nfs.ExportsExtended {
fmt.Fprintf(exports, "%s %s/%s(%s)\n", export.Path, controller.Network, controller.Netmask, export.Options)
fmt.Fprintf(exports, "%s %s/%s(%s)\n", export.Path, controller.Network, controller.Netmask, export.ExportOptions)
if export.Mount {
fmt.Fprintf(fstab, "%s:%s %s nfs defaults 0 0\n", controller.Ipaddr, export.Path, export.Path)
var mountOpts string
if export.MountOptions == "" {
mountOpts = "defaults"
} else {
mountOpts = export.MountOptions
}
fmt.Fprintf(fstab, "%s:%s %s nfs %s 0 0\n", controller.Ipaddr, export.Path, export.Path, mountOpts)
}
}

View File

@@ -1,9 +1,9 @@
package warewulfconf
import (
"github.com/creasty/defaults"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/creasty/defaults"
)
var ConfigFile = "/etc/warewulf/warewulf.conf"
@@ -44,29 +44,30 @@ type TftpConf struct {
}
type NfsConf struct {
Enabled bool `default:"true" yaml:"enabled"`
Exports []string `yaml:"exports"`
ExportsExtended []*NfsExportConf `yaml:"exports extended"`
SystemdName string `yaml:"systemd name"`
}
func (s *NfsConf) UnmarshalYAML(unmarshal func(interface{}) error) error {
if err := defaults.Set(s); err != nil {
return err
}
type plain NfsConf
if err := unmarshal((*plain)(s)); err != nil {
return err
}
return nil
Enabled bool `default:"true" yaml:"enabled"`
Exports []string `yaml:"exports"`
ExportsExtended []*NfsExportConf `yaml:"export paths"`
SystemdName string `yaml:"systemd name"`
}
type NfsExportConf struct {
Path string `yaml:"path"`
Options string `yaml:"options"`
Mount bool `yaml:"mount"`
Path string `yaml:"path"`
ExportOptions string `yaml:"export options"`
MountOptions string `yaml:"mount options"`
Mount bool `yaml:"mount"`
}
func (s *NfsConf) UnmarshalYAML(unmarshal func(interface{}) error) error {
if err := defaults.Set(s); err != nil {
return err
}
type plain NfsConf
if err := unmarshal((*plain)(s)); err != nil {
return err
}
return nil
}
func init() {