Files
warewulf/internal/app/wwctl/configure/root.go
jcsiadal e7aac8773c Move configuration work to library
Signed-off-by: jcsiadal <jeremy.c.siadal@intel.com>

Update to support show correctly

Signed-off-by: jcsiadal <jeremy.c.siadal@intel.com>
2022-02-26 22:39:50 +00:00

59 lines
1.5 KiB
Go

package configure
import (
"os"
"github.com/hpcng/warewulf/internal/app/wwctl/configure/dhcp"
"github.com/hpcng/warewulf/internal/app/wwctl/configure/hosts"
"github.com/hpcng/warewulf/internal/app/wwctl/configure/nfs"
"github.com/hpcng/warewulf/internal/app/wwctl/configure/ssh"
"github.com/hpcng/warewulf/internal/app/wwctl/configure/tftp"
"github.com/hpcng/warewulf/internal/pkg/configure"
"github.com/spf13/cobra"
)
var (
baseCmd = &cobra.Command{
DisableFlagsInUseLine: true,
Use: "configure [OPTIONS]",
Short: "Manage system services",
Long: "This application allows you to manage and initialize Warewulf dependent system\n" +
"services based on the configuration in the warewulf.conf file.",
RunE: CobraRunE,
}
allFunctions bool
)
func init() {
baseCmd.AddCommand(dhcp.GetCommand())
baseCmd.AddCommand(tftp.GetCommand())
baseCmd.AddCommand(hosts.GetCommand())
baseCmd.AddCommand(ssh.GetCommand())
baseCmd.AddCommand(nfs.GetCommand())
baseCmd.PersistentFlags().BoolVarP(&allFunctions, "all", "a", false, "Configure all services")
}
// GetRootCommand returns the root cobra.Command for the application.
func GetCommand() *cobra.Command {
return baseCmd
}
func CobraRunE(cmd *cobra.Command, args []string) error {
var err error
if allFunctions {
for _, s := range [5]string{"DHPC", "hosts", "NFS", "SSH", "TFTP"} {
err = configure.Configure(s, false)
if err != nil {
os.Exit(1)
}
}
} else {
_ = cmd.Help()
os.Exit(0)
}
return nil
}