Skip to content

Commit

Permalink
Delay .net 4.0 install to the end and run it stand alone
Browse files Browse the repository at this point in the history
- Use sc to install openvpnserv2 if .NET 4.0 not found
- Download of net installer happens withing the installer, but .NET
  installation is left to run standalone.
- Only .NET 4.0 client profile installed which should be enough to run the
  service (?) Download slightly smaller and installs a bit faster (?)

Signed-off-by: Selva Nair <[email protected]>
  • Loading branch information
selvanair committed Dec 5, 2016
1 parent ae8ebec commit 61c16da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
7 changes: 2 additions & 5 deletions windows-nsis/DotNetChecker.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,9 @@ DownloadDotNET${FrameworkVersion}:
IDYES NewDotNET${FrameworkVersion} IDNO GiveUpDotNET${FrameworkVersion}
${EndIf}

DetailPrint "Pausing installation while downloaded .NET Framework installer runs."
ExecWait '$TEMP\dotnetfx.exe /q /c:"install /q"'
DetailPrint "Starting downloaded .NET Framework installer as stand alone."
Exec '$TEMP\dotnetfx.exe'

DetailPrint "Completed .NET Framework install/update. Removing .NET Framework installer."
Delete "$TEMP\dotnetfx.exe"
DetailPrint ".NET Framework installer removed."
goto NewDotNet${FrameworkVersion}

GiveUpDotNET${FrameworkVersion}:
Expand Down
18 changes: 15 additions & 3 deletions windows-nsis/openvpn.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,23 @@ SectionEnd

Section /o "${PACKAGE_NAME} Service" SecService

!insertmacro CheckNetFramework 40Full

SetOverwrite on

SetOutPath "$INSTDIR\bin"
; Copy openvpnserv2.exe for automatic service
File /oname=openvpnserv2.exe "${OPENVPNSERV2_EXECUTABLE}"
DetailPrint "Installing OpenVPN Service..."
nsExec::ExecToLog '"$INSTDIR\bin\openvpnserv2.exe" -install'

DotNetChecker::IsDotNet40ClientInstalled
Pop $0
${If} $0 == "false"
${OrIf} $0 == "f" ; could be either false or f as per dotnetchecker.nsh
DetailPrint "NET 4.0 not found. Using sc.exe to install openvpnservice"
nsExec::ExecToLog '$SYSDIR\sc.exe create OpenVPNService binPath= "$INSTDIR\bin\openvpnserv2.exe" depend= tap0901/dhcp'
${Else}
DetailPrint "Running openvpnserv2.exe -install"
nsExec::ExecToLog '"$INSTDIR\bin\openvpnserv2.exe" -install'
${EndIf}

Pop $R0 # return value/error/timeout

Expand Down Expand Up @@ -593,6 +601,10 @@ Section -post
${Else}
DetailPrint "WARNING: $\"sc.exe start OpenVPNServiceInteractive$\" failed with return value of $R1"
${EndIf}
${If} ${SectionIsSelected} ${SecService}
; if no .NET 4, offer to install it
!insertmacro CheckNetFramework 40Client
${Endif}

SectionEnd

Expand Down

0 comments on commit 61c16da

Please sign in to comment.