This handy NSIS installer script installs both OpenVPN as well as a set of configuration data. It makes it super easy to package and distribute OpenVPN and Configurations to Windows users (like in a corporate environment)
Building OpenVPN Installer
These commands will be executed from the Windows command line, these for example come from our make.bat file.
c:\Program Files\NSIS\makensis.exe \ /Doutput_exe="vpn-output.exe" \ /Dclient_cfg="vpn-config" \ edoceo_openvpn_installer.nsi
Update the comamnd to substitue the desired configuration directory for vpn-config. Also, other files will need to be preset, such as logo icons or images.<
OpenVPN Installer Directory Structure
./edoceo_openvpn_installer.nsi ./images/logo.bmp ./images/logo.ico ./images/logo.png ./make.bat ./source ./source/openvpn-2.2.2-install.exe ./vpn-config ./vpn-config/ca.crt ./vpn-config/client.crt ./vpn-config/client.key ./vpn-config/client.ovpn ./vpn-config/dh.pem ./vpn-config/ta.key
Nullsoft Installer for OpenVPN
# # OpenVPN Application and Configuration Installer # @version $Id$ # # Set Defaults # Allows for /DOUTPUT_EXE=something.exe /DCLIENT_CFG=config\file.cfg !ifndef CONFIG_DIR !define CONFIG_DIR "config" !endif !ifndef OUTPUT_EXE !define OUTPUT_EXE "vpn-install.exe" !endif BrandingText "Edoceo OpenVPN Installer" Caption "Edoceo Automagic OpenVPN Installer" CompletedText "Edoceo Automagic OpenVPN Installation Complete" # ComponentText "OpenVPN" Icon images\logo.ico InstallColors 336699 333333 InstProgressFlags colored smooth Name "OpenVPN Installer" OutFile ${OUTPUT_EXE} RequestExecutionLevel admin ShowInstDetails show XPStyle off # TargetMinimalOS 5.1 Section "" # Var /GLOBAL targetdir # Maybe warn that directory is not here? # @todo check for OpenVPN Dir in Registry DetailPrint "Checking OpenVPN" IfFileExists "$PROGRAMFILES32\OpenVPN\bin\openvpn-gui-1.0.3.exe" goodVPN failVPN failVPN: MessageBox MB_OK "We must install OpenVPN First, please complete the following installer choosing Next or Continue as necessary" SetOutPath $EXEDIR DetailPrint "Extracting OpenVPN $OUTDIR" # Bundle OpenVPN Installer File source\openvpn-2.2.2-install.exe # ExecShell "open" "$EXEDIR\openvpn-2.1.1-install.exe" ExecWait "$EXEDIR\openvpn-2.2.2-install.exe" $0 # Zero == Success, One == Fail, handle IntCmp $0 0 goodInstall DetailPrint "Failed to Install: $0" MessageBox MB_OK|MB_ICONSTOP "Failed to install OpenVPN, this is required to continue. Installation aborted." Quit goodInstall: Goto doneVPN goodVPN: DetailPrint "OpenVPN Already Installed" doneVPN: # @todo read registry for install values? # @todo find the registry entries for the OpenVPN configuration # ReadRegStr $0 HKLM Software\ # SetOutPath $0 SetOutPath "$PROGRAMFILES32\OpenVPN\config" # Full contents of Config File /r /x .svn ${CONFIG_DIR} # un-installer WriteUninstaller "$EXEDIR\remove-edoceo-openvpn.exe" SectionEnd