diff --git a/netclient/daemon/windows.go b/netclient/daemon/windows.go
index 266f520c..1578e9cd 100644
--- a/netclient/daemon/windows.go
+++ b/netclient/daemon/windows.go
@@ -34,6 +34,7 @@ func SetupWindowsDaemon() error {
return nil
}
+// RestartWindowsDaemon - restarts windows service
func RestartWindowsDaemon() {
StopWindowsDaemon()
// start daemon, will not restart or start another
@@ -59,6 +60,7 @@ func writeServiceConfig() error {
Netclient
Connects Windows nodes to one or more Netmaker networks.
%v
+daemon
`, strings.Replace(ncutils.GetNetclientPathSpecific()+"netclient.exe", `\\`, `\`, -1))
diff --git a/netclient/main.go b/netclient/main.go
index 5ef2a95e..c4b45d28 100644
--- a/netclient/main.go
+++ b/netclient/main.go
@@ -8,7 +8,6 @@ import (
"runtime/debug"
"github.com/gravitl/netmaker/netclient/cli_options"
- "github.com/gravitl/netmaker/netclient/command"
"github.com/gravitl/netmaker/netclient/ncutils"
"github.com/gravitl/netmaker/netclient/ncwindows"
"github.com/urfave/cli/v2"
@@ -31,13 +30,10 @@ func main() {
ncutils.CheckUID()
ncutils.CheckWG()
}
- if len(os.Args) == 1 && ncutils.IsWindows() {
- command.RunUserspaceDaemon()
- } else {
- err := app.Run(os.Args)
- if err != nil {
- log.Fatal(err)
- }
+
+ err := app.Run(os.Args)
+ if err != nil {
+ log.Fatal(err)
}
}
diff --git a/netclient/ncwindows/windows.go b/netclient/ncwindows/windows.go
index dffa98b1..ff76a3ea 100644
--- a/netclient/ncwindows/windows.go
+++ b/netclient/ncwindows/windows.go
@@ -18,17 +18,22 @@ func InitWindows() {
if wdErr != nil {
log.Fatal("failed to get current directory..")
}
- _, dataNetclientErr := os.Stat(ncutils.GetNetclientPathSpecific() + "netclient.exe")
- _, currentNetclientErr := os.Stat(wdPath + "\\netclient.exe")
- if os.IsNotExist(dataNetclientErr) { // check and see if netclient.exe is in appdata
+ dataPath := ncutils.GetNetclientPathSpecific() + "netclient.exe"
+ currentPath := wdPath + "\\netclient.exe"
+ _, dataNetclientErr := os.Stat(dataPath)
+ _, currentNetclientErr := os.Stat(currentPath)
+
+ if currentPath == dataPath && currentNetclientErr == nil {
+ ncutils.Log("netclient.exe is in proper location, " + currentPath)
+ } else if os.IsNotExist(dataNetclientErr) { // check and see if netclient.exe is in appdata
if currentNetclientErr == nil { // copy it if it exists locally
- input, err := os.ReadFile(wdPath + "\\netclient.exe")
+ input, err := os.ReadFile(currentPath)
if err != nil {
log.Println("failed to find netclient.exe")
return
}
- if err = os.WriteFile(ncutils.GetNetclientPathSpecific()+"netclient.exe", input, 0600); err != nil {
+ if err = os.WriteFile(dataPath, input, 0700); err != nil {
log.Println("failed to copy netclient.exe to", ncutils.GetNetclientPath())
return
}
diff --git a/netclient/wireguard/unix.go b/netclient/wireguard/unix.go
index 4194abdb..2b2a61a3 100644
--- a/netclient/wireguard/unix.go
+++ b/netclient/wireguard/unix.go
@@ -53,17 +53,20 @@ func SetWGKeyConfig(network string, serveraddr string) error {
// ApplyWGQuickConf - applies wg-quick commands if os supports
func ApplyWGQuickConf(confPath string, ifacename string) error {
- _, err := os.Stat(confPath)
- if err != nil {
- ncutils.Log(confPath + " does not exist " + err.Error())
+ if ncutils.IsWindows() {
+ return ApplyWindowsConf(confPath)
+ } else {
+ _, err := os.Stat(confPath)
+ if err != nil {
+ ncutils.Log(confPath + " does not exist " + err.Error())
+ return err
+ }
+ if ncutils.IfaceExists(ifacename) {
+ ncutils.RunCmd("wg-quick down "+confPath, true)
+ }
+ _, err = ncutils.RunCmd("wg-quick up "+confPath, true)
return err
}
- if ncutils.IfaceExists(ifacename) {
- ncutils.RunCmd("wg-quick down "+confPath, true)
- }
- _, err = ncutils.RunCmd("wg-quick up "+confPath, true)
-
- return err
}
// ApplyMacOSConf - applies system commands similar to wg-quick using golang for MacOS