Browse Source

windows netclient fix

afeiszli 3 years ago
parent
commit
20a939b188
2 changed files with 5 additions and 4 deletions
  1. 1 2
      netclient/wireguard/common.go
  2. 4 2
      scripts/netclient-install.ps1

+ 1 - 2
netclient/wireguard/common.go

@@ -188,10 +188,9 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
 		}
 		if ncutils.IsWindows() {
 			wgConfPath := ncutils.GetWGPathSpecific() + ifacename + ".conf"
-			ncutils.PrintLog("error writing wg conf file to "+confPath+": "+err.Error(), 1)
 			err = ioutil.WriteFile(wgConfPath, []byte(newConf), 0644)
 			if err != nil {
-				ncutils.PrintLog("error writing wg conf file to "+confPath+": "+err.Error(), 1)
+				ncutils.PrintLog("error writing wg conf file to "+wgConfPath+": "+err.Error(), 1)
 				return err
 			}
 			confPath = wgConfPath

+ 4 - 2
scripts/netclient-install.ps1

@@ -23,7 +23,8 @@ new-module -name netclient-install -scriptblock {
         $outpath = "$env:userprofile\Downloads\wireguard-installer.exe"
         Invoke-WebRequest -Uri $url -OutFile $outpath
         $args = @("Comma","Separated","Arguments")
-        Start-Process -Filepath "$env:userprofile\Downloads\wireguard-installer.exe" -ArgumentList $args
+        $procWG = Start-Process -Filepath "$env:userprofile\Downloads\wireguard-installer.exe" -ArgumentList $args
+        $procWG.WaitForExit()        
         Start-Sleep -Seconds 5
         $software = "WireGuard";
         $installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -eq $software }) -ne $null
@@ -46,7 +47,8 @@ new-module -name netclient-install -scriptblock {
         Invoke-WebRequest -Uri $url -OutFile $outpath
     }
     $NetArgs = @("join","-t",$token)
-    Start-Process -Filepath $outpath -ArgumentList $NetArgs
+    $procNC = Start-Process -Filepath $outpath -ArgumentList $NetArgs
+    $procNC.WaitForExit() 
     Add-MpPreference -ExclusionPath "C:\ProgramData\Netclient"
 
     if ((Get-Command "netclient.exe" -ErrorAction SilentlyContinue) -eq $null) {