created exports with template
This commit is contained in:
@@ -4,12 +4,17 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
/*
|
||||
Creates '/etc/exports' from the host template, enables and start the
|
||||
nfs server.
|
||||
*/
|
||||
func configureNFS() error {
|
||||
|
||||
controller, err := warewulfconf.New()
|
||||
@@ -19,19 +24,13 @@ func configureNFS() error {
|
||||
}
|
||||
|
||||
if controller.Nfs.Enabled {
|
||||
exports, err := os.OpenFile("/etc/exports", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
fmt.Println(err)
|
||||
}
|
||||
defer exports.Close()
|
||||
|
||||
fmt.Fprintf(exports, "# This file was written by Warewulf (wwctl configure nfs)\n")
|
||||
|
||||
for _, export := range controller.Nfs.ExportsExtended {
|
||||
fmt.Fprintf(exports, "%s %s/%s(%s)\n", export.Path, controller.Network, controller.Netmask, export.ExportOptions)
|
||||
err = overlay.BuildHostOverlay()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.WARN, "host overlay could not be built: %s\n", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Enabling and restarting the NFS services\n")
|
||||
if controller.Nfs.SystemdName == "" {
|
||||
err := util.SystemdStart("nfs-server")
|
||||
@@ -49,6 +48,10 @@ func configureNFS() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
Prints the configured nfs exports in formated style, needs not to be
|
||||
the content of '/etc/exports'
|
||||
*/
|
||||
func showNFS() {
|
||||
controller, err := warewulfconf.New()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user