slightly improved error handling for wwclient

This commit is contained in:
Christian Goll
2021-11-12 11:54:50 +01:00
parent 93c337a469
commit 6a5809e7c4

View File

@@ -47,6 +47,11 @@ func GetRootCommand() *cobra.Command {
}
func CobraRunE(cmd *cobra.Command, args []string) error {
conf, err := warewulfconf.New()
if err != nil {
return err
}
if util.IsFile(PIDFile) {
return errors.New("wwclient is already running")
}
@@ -72,22 +77,18 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
err := os.MkdirAll("/warewulf/wwclient-test", 0755)
if err != nil {
wwlog.Printf(wwlog.ERROR, "failed to create dir: %s", err)
_ = os.Remove(PIDFile)
os.Exit(1)
}
err = os.Chdir("/warewulf/wwclient-test")
if err != nil {
wwlog.Printf(wwlog.ERROR, "failed to change dir: %s", err)
_ = os.Remove(PIDFile)
os.Exit(1)
}
}
conf, err := warewulfconf.New()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not get Warewulf configuration: %s\n", err)
os.Exit(1)
}
localTCPAddr := net.TCPAddr{}
if conf.Warewulf.Secure {
// Setup local port to something privileged (<1024)