Update to OpenVPN 2.1rc17
[tomato.git] / release / src / router / openvpn / install-win32 / openvpn.nsi
blobbd0298b06d64459d176083b2c87f23058c63e52d
1 ; ****************************************************************************
2 ; * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. *
3 ; * This program is free software; you can redistribute it and/or modify *
4 ; * it under the terms of the GNU General Public License version 2 *
5 ; * as published by the Free Software Foundation. *
6 ; ****************************************************************************
8 ; OpenVPN install script for Windows, using NSIS
10 SetCompressor lzma
12 !include "MUI.nsh"
14 !include "defs.nsi"
15 !include "guidefs.nsi"
16 !include "xguidefs.nsi"
17 !include "setpath.nsi"
18 !include "GetWindowsVersion.nsi"
20 !ifdef EXTRACT_FILES
21 !include "MultiFileExtract.nsi"
22 !endif
24 !define GEN ".."
25 !define BIN "${GEN}\bin"
26 !define LIB "${GEN}\lib"
28 ; Which GUI to use (XGUI has priority).
29 ; We will define either USE_XGUI (XML-based version) or
30 ; USE_GUI (Mathias Sundman version) but not both.
31 !ifdef OPENVPN_XGUI_DEFINED
32 !define USE_XGUI
33 !else
34 !ifdef OPENVPN_GUI_DEFINED
35 !define USE_GUI
36 !endif
37 !endif
39 !define PRODUCT_ICON "icon.ico"
41 !ifdef USE_XGUI
42 !define XGUI_POSTFIX "X"
43 !else
44 !define XGUI_POSTFIX ""
45 !endif
47 !ifdef PRODUCT_TAP_DEBUG
48 !define DBG_POSTFIX "-DBG"
49 !else
50 !define DBG_POSTFIX ""
51 !endif
53 !define VERSION "${PRODUCT_VERSION}${XGUI_POSTFIX}${DBG_POSTFIX}"
55 !define TAP "${PRODUCT_TAP_ID}"
56 !define TAPDRV "${TAP}.sys"
58 ; Default service settings
59 !define SERV_CONFIG_DIR "$INSTDIR\config"
60 !define SERV_CONFIG_EXT "${PRODUCT_FILE_EXT}"
61 !define SERV_EXE_PATH "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe"
62 !define SERV_LOG_DIR "$INSTDIR\log"
63 !define SERV_PRIORITY "NORMAL_PRIORITY_CLASS"
64 !define SERV_LOG_APPEND "0"
66 ; XGUI variables
67 !define XGUI_EXE ovpn-xgui-en.exe
68 !define XGUI_TRAY ovpn-tray.exe
69 !define XGUI_XMLSERV ovpn-xmlserv.exe
70 !define XGUI_HTDOCS htdocs
72 !define XGUI_AJAX_GUI_NAME "${PRODUCT_NAME} Ajax GUI"
73 !define XGUI_TRANSITION_GUI_NAME "${PRODUCT_NAME} Transitional GUI"
75 ;--------------------------------
76 ;Configuration
78 ;General
80 OutFile "${GEN}\${PRODUCT_UNIX_NAME}-${VERSION}${OUTFILE_LABEL}-install.exe"
82 ShowInstDetails show
83 ShowUninstDetails show
85 ;Folder selection page
86 InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
88 ;Remember install folder
89 InstallDirRegKey HKCU "Software\${PRODUCT_NAME}" ""
91 ;--------------------------------
92 ;Modern UI Configuration
94 Name "${PRODUCT_NAME} ${VERSION} ${TITLE_LABEL}"
96 !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of ${PRODUCT_NAME}, an Open Source VPN package by James Yonan.\r\n\r\nNote that the Windows version of ${PRODUCT_NAME} will only run on Win 2000, XP, or higher.\r\n\r\n\r\n"
98 !define MUI_COMPONENTSPAGE_TEXT_TOP "Select the components to install/upgrade. Stop any ${PRODUCT_NAME} processes or the ${PRODUCT_NAME} service if it is running. All DLLs are installed locally."
100 !define MUI_COMPONENTSPAGE_SMALLDESC
101 !ifdef USE_XGUI
102 !define MUI_FINISHPAGE_SHOWREADME "http://openvpn.net/"
103 !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
104 !else
105 !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\INSTALL-win32.txt"
106 !endif
107 !define MUI_FINISHPAGE_NOAUTOCLOSE
108 !define MUI_ABORTWARNING
109 !define MUI_ICON "${GEN}\images\${PRODUCT_ICON}"
110 !define MUI_UNICON "${GEN}\images\${PRODUCT_ICON}"
111 !define MUI_HEADERIMAGE
112 !define MUI_HEADERIMAGE_BITMAP "${GEN}\images\install-whirl.bmp"
113 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
115 !insertmacro MUI_PAGE_WELCOME
116 !insertmacro MUI_PAGE_LICENSE "${GEN}\text\license.txt"
117 !insertmacro MUI_PAGE_COMPONENTS
118 !insertmacro MUI_PAGE_DIRECTORY
119 !insertmacro MUI_PAGE_INSTFILES
120 !insertmacro MUI_PAGE_FINISH
122 !insertmacro MUI_UNPAGE_CONFIRM
123 !insertmacro MUI_UNPAGE_INSTFILES
124 !insertmacro MUI_UNPAGE_FINISH
127 ;--------------------------------
128 ;Languages
130 !insertmacro MUI_LANGUAGE "English"
132 ;--------------------------------
133 ;Language Strings
135 LangString DESC_SecOpenVPNUserSpace ${LANG_ENGLISH} "Install ${PRODUCT_NAME} user-space components, including ${PRODUCT_UNIX_NAME}.exe."
137 !ifdef USE_GUI
138 LangString DESC_SecOpenVPNGUI ${LANG_ENGLISH} "Install ${PRODUCT_NAME} GUI by Mathias Sundman"
139 !endif
141 !ifdef USE_XGUI
142 LangString DESC_SecOpenVPNXGUI ${LANG_ENGLISH} "Install ${PRODUCT_NAME} XML-based GUI"
143 !endif
145 LangString DESC_SecOpenVPNEasyRSA ${LANG_ENGLISH} "Install ${PRODUCT_NAME} RSA scripts for X509 certificate management."
147 LangString DESC_SecOpenSSLDLLs ${LANG_ENGLISH} "Install OpenSSL DLLs locally (may be omitted if DLLs are already installed globally)."
149 LangString DESC_SecPKCS11DLLs ${LANG_ENGLISH} "Install PKCS#11 helper DLLs locally (may be omitted if DLLs are already installed globally)."
151 LangString DESC_SecTAP ${LANG_ENGLISH} "Install/Upgrade the TAP virtual device driver. Will not interfere with CIPE."
153 LangString DESC_SecService ${LANG_ENGLISH} "Install the ${PRODUCT_NAME} service wrapper (${PRODUCT_UNIX_NAME}serv.exe)"
155 LangString DESC_SecOpenSSLUtilities ${LANG_ENGLISH} "Install the OpenSSL Utilities (used for generating public/private key pairs)."
157 LangString DESC_SecAddPath ${LANG_ENGLISH} "Add ${PRODUCT_NAME} executable directory to the current user's PATH."
159 LangString DESC_SecAddShortcuts ${LANG_ENGLISH} "Add ${PRODUCT_NAME} shortcuts to the current user's Start Menu."
161 LangString DESC_SecFileAssociation ${LANG_ENGLISH} "Register ${PRODUCT_NAME} config file association (*.${SERV_CONFIG_EXT})"
163 ;--------------------------------
164 ;Reserve Files
166 ;Things that need to be extracted on first (keep these lines before any File command!)
167 ;Only useful for BZIP2 compression
169 ReserveFile "${GEN}\images\install-whirl.bmp"
171 ;--------------------------------
172 ;Macros
174 !macro WriteRegStringIfUndef ROOT SUBKEY KEY VALUE
175 Push $R0
176 ReadRegStr $R0 "${ROOT}" "${SUBKEY}" "${KEY}"
177 StrCmp $R0 "" +1 +2
178 WriteRegStr "${ROOT}" "${SUBKEY}" "${KEY}" '${VALUE}'
179 Pop $R0
180 !macroend
182 !macro DelRegStringIfUnchanged ROOT SUBKEY KEY VALUE
183 Push $R0
184 ReadRegStr $R0 "${ROOT}" "${SUBKEY}" "${KEY}"
185 StrCmp $R0 '${VALUE}' +1 +2
186 DeleteRegValue "${ROOT}" "${SUBKEY}" "${KEY}"
187 Pop $R0
188 !macroend
190 !macro DelRegKeyIfUnchanged ROOT SUBKEY VALUE
191 Push $R0
192 ReadRegStr $R0 "${ROOT}" "${SUBKEY}" ""
193 StrCmp $R0 '${VALUE}' +1 +2
194 DeleteRegKey "${ROOT}" "${SUBKEY}"
195 Pop $R0
196 !macroend
198 !macro DelRegKeyIfEmpty ROOT SUBKEY
199 Push $R0
200 EnumRegValue $R0 "${ROOT}" "${SUBKEY}" 1
201 StrCmp $R0 "" +1 +2
202 DeleteRegKey /ifempty "${ROOT}" "${SUBKEY}"
203 Pop $R0
204 !macroend
206 ;------------------------------------------
207 ;Set reboot flag based on tapinstall return
209 Function CheckReboot
210 IntCmp $R0 1 "" noreboot noreboot
211 IntOp $R0 0 & 0
212 SetRebootFlag true
213 DetailPrint "REBOOT flag set"
214 noreboot:
215 FunctionEnd
217 ;--------------------------------
218 ;Installer Sections
220 Function .onInit
221 ClearErrors
223 # Verify that user has admin privs
224 UserInfo::GetName
225 IfErrors ok
226 Pop $R0
227 UserInfo::GetAccountType
228 Pop $R1
229 StrCmp $R1 "Admin" ok
230 Messagebox MB_OK "Administrator privileges required to install ${PRODUCT_NAME} [$R0/$R1]"
231 Abort
234 # Delete previous start menu
235 RMDir /r $SMPROGRAMS\${PRODUCT_NAME}
237 !ifdef CHECK_WINDOWS_VERSION
238 # Check windows version
239 Call GetWindowsVersion
240 Pop $1
241 StrCmp $1 "2000" goodwinver
242 StrCmp $1 "XP" goodwinver
243 StrCmp $1 "2003" goodwinver
244 StrCmp $1 "VISTA" goodwinver
246 Messagebox MB_OK "Sorry, ${PRODUCT_NAME} does not currently support Windows $1"
247 Abort
249 goodwinver:
250 System::Call "kernel32::GetCurrentProcess() i .s"
251 System::Call "kernel32::IsWow64Process(i s, *i .r0)"
252 IntCmp $0 0 init32bits
254 ; we are running on 64-bit windows
255 StrCmp $1 "VISTA" vista64bummer
257 # Messagebox MB_OK "Sorry, ${PRODUCT_NAME} doesn't currently support 64-bit Windows."
258 # Abort
260 vista64bummer:
262 # Messagebox MB_OK "Sorry, ${PRODUCT_NAME} doesn't currently support 64-bit Vista because Microsoft doesn't allow the installation of 64 bit unsigned drivers."
263 # Abort
265 init32bits:
267 !endif
269 FunctionEnd
271 !ifndef SF_SELECTED
272 !define SF_SELECTED 1
273 !endif
275 ;--------------------
276 ;Pre-install section
278 Section -pre
280 ; Stop OpenVPN if currently running
281 DetailPrint "Previous Service REMOVE (if exists)"
282 nsExec::ExecToLog '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe" -remove'
283 Pop $R0 # return value/error/timeout
285 !ifdef USE_XGUI
286 DetailPrint "Previous XML Service REMOVE (if exists)"
287 nsExec::ExecToLog '"$INSTDIR\bin\${XGUI_XMLSERV}" -remove'
288 Pop $R0 # return value/error/timeout
289 !endif
291 Sleep 3000
293 SectionEnd
295 Section "${PRODUCT_NAME} User-Space Components" SecOpenVPNUserSpace
297 SetOverwrite on
298 SetOutPath "$INSTDIR\bin"
300 File "${BIN}\${PRODUCT_UNIX_NAME}.exe"
302 SectionEnd
304 !ifdef USE_GUI
305 Section "${PRODUCT_NAME} GUI" SecOpenVPNGUI
307 SetOverwrite on
308 SetOutPath "$INSTDIR\bin"
310 File "${BIN}\${OPENVPN_GUI}"
312 SectionEnd
313 !endif
315 !ifdef USE_XGUI
316 Section "${PRODUCT_NAME} XML-based GUI" SecOpenVPNXGUI
318 SetOverwrite on
320 SetOutPath "$INSTDIR\bin"
321 File "${BIN}\${XGUI_EXE}"
322 File "${BIN}\${XGUI_TRAY}"
323 File "${BIN}\${XGUI_XMLSERV}"
325 SetOutPath "$INSTDIR\${XGUI_HTDOCS}"
326 File "${GEN}\${XGUI_HTDOCS}\*.*"
328 SectionEnd
329 !endif
331 Section "${PRODUCT_NAME} RSA Certificate Management Scripts" SecOpenVPNEasyRSA
333 SetOverwrite on
334 SetOutPath "$INSTDIR\easy-rsa"
336 File "${GEN}\easy-rsa\openssl.cnf.sample"
337 File "${GEN}\easy-rsa\vars.bat.sample"
339 File "${GEN}\easy-rsa\init-config.bat"
341 File "${GEN}\easy-rsa\README.txt"
342 File "${GEN}\easy-rsa\build-ca.bat"
343 File "${GEN}\easy-rsa\build-dh.bat"
344 File "${GEN}\easy-rsa\build-key-server.bat"
345 File "${GEN}\easy-rsa\build-key.bat"
346 File "${GEN}\easy-rsa\build-key-pkcs12.bat"
347 File "${GEN}\easy-rsa\clean-all.bat"
348 File "${GEN}\easy-rsa\index.txt.start"
349 File "${GEN}\easy-rsa\revoke-full.bat"
350 File "${GEN}\easy-rsa\serial.start"
352 SectionEnd
354 Section "${PRODUCT_NAME} Service" SecService
356 SetOverwrite on
358 SetOutPath "$INSTDIR\bin"
359 File "${BIN}\${PRODUCT_UNIX_NAME}serv.exe"
361 SetOutPath "$INSTDIR\config"
363 FileOpen $R0 "$INSTDIR\config\README.txt" w
364 FileWrite $R0 "This directory should contain ${PRODUCT_NAME} configuration files$\r$\n"
365 FileWrite $R0 "each having an extension of .${SERV_CONFIG_EXT}$\r$\n"
366 FileWrite $R0 "$\r$\n"
367 FileWrite $R0 "When ${PRODUCT_NAME} is started as a service, a separate ${PRODUCT_NAME}$\r$\n"
368 FileWrite $R0 "process will be instantiated for each configuration file.$\r$\n"
369 FileClose $R0
371 SetOutPath "$INSTDIR\sample-config"
372 File "${GEN}\samples\sample.${SERV_CONFIG_EXT}"
373 File "${GEN}\samples\client.${SERV_CONFIG_EXT}"
374 File "${GEN}\samples\server.${SERV_CONFIG_EXT}"
376 CreateDirectory "$INSTDIR\log"
377 FileOpen $R0 "$INSTDIR\log\README.txt" w
378 FileWrite $R0 "This directory will contain the log files for ${PRODUCT_NAME}$\r$\n"
379 FileWrite $R0 "sessions which are being run as a service.$\r$\n"
380 FileClose $R0
382 SectionEnd
384 Section "${PRODUCT_NAME} File Associations" SecFileAssociation
385 SectionEnd
387 Section "OpenSSL DLLs" SecOpenSSLDLLs
389 SetOverwrite on
390 SetOutPath "$INSTDIR\bin"
391 File "${LIB}\libeay32.dll"
392 File "${LIB}\libssl32.dll"
394 SectionEnd
396 Section "OpenSSL Utilities" SecOpenSSLUtilities
398 SetOverwrite on
399 SetOutPath "$INSTDIR\bin"
400 File "${BIN}\openssl.exe"
402 SectionEnd
404 Section "PKCS#11 DLLs" SecPKCS11DLLs
406 SetOverwrite on
407 SetOutPath "$INSTDIR\bin"
408 File "${LIB}\libpkcs11-helper-1.dll"
410 SectionEnd
412 Section "TAP Virtual Ethernet Adapter" SecTAP
414 SetOverwrite on
416 FileOpen $R0 "$INSTDIR\bin\addtap.bat" w
417 FileWrite $R0 "rem Add a new TAP virtual ethernet adapter$\r$\n"
418 FileWrite $R0 '"$INSTDIR\bin\tapinstall.exe" install "$INSTDIR\driver\OemWin2k.inf" ${TAP}$\r$\n'
419 FileWrite $R0 "pause$\r$\n"
420 FileClose $R0
422 FileOpen $R0 "$INSTDIR\bin\deltapall.bat" w
423 FileWrite $R0 "echo WARNING: this script will delete ALL TAP virtual adapters (use the device manager to delete adapters one at a time)$\r$\n"
424 FileWrite $R0 "pause$\r$\n"
425 FileWrite $R0 '"$INSTDIR\bin\tapinstall.exe" remove ${TAP}$\r$\n'
426 FileWrite $R0 "pause$\r$\n"
427 FileClose $R0
429 ; Check if we are running on a 64 bit system.
430 System::Call "kernel32::GetCurrentProcess() i .s"
431 System::Call "kernel32::IsWow64Process(i s, *i .r0)"
432 IntCmp $0 0 tap-32bit
434 ; tap-64bit:
436 DetailPrint "We are running on a 64-bit system."
438 SetOutPath "$INSTDIR\bin"
440 File "${GEN}\tapinstall\amd64\tapinstall.exe"
442 SetOutPath "$INSTDIR\driver"
444 File "${GEN}\driver\amd64\OemWin2k.inf"
445 File "${GEN}\driver\amd64\${PRODUCT_TAP_ID}.cat"
446 File "${GEN}\driver\amd64\${TAPDRV}"
448 goto tapend
450 tap-32bit:
452 DetailPrint "We are running on a 32-bit system."
454 SetOutPath "$INSTDIR\bin"
455 File "${GEN}\tapinstall\i386\tapinstall.exe"
457 SetOutPath "$INSTDIR\driver"
458 File "${GEN}\driver\i386\OemWin2k.inf"
459 File "${GEN}\driver\i386\${PRODUCT_TAP_ID}.cat"
460 File "${GEN}\driver\i386\${TAPDRV}"
462 tapend:
464 SectionEnd
466 Section "Add ${PRODUCT_NAME} to PATH" SecAddPath
468 ; remove previously set path (if any)
469 Push "$INSTDIR\bin"
470 Call RemoveFromPath
472 ; append our bin directory to end of current user path
473 Push "$INSTDIR\bin"
474 Call AddToPath
476 SectionEnd
478 Section "Add Shortcuts to Start Menu" SecAddShortcuts
480 SetOverwrite on
481 CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
482 CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}\Documentation"
483 WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} Windows Notes.url" "InternetShortcut" "URL" "http://openvpn.net/INSTALL-win32.html"
484 WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} Manual Page.url" "InternetShortcut" "URL" "http://openvpn.net/man.html"
485 WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} HOWTO.url" "InternetShortcut" "URL" "http://openvpn.net/howto.html"
486 WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} Web Site.url" "InternetShortcut" "URL" "http://openvpn.net/"
487 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall ${PRODUCT_NAME}.lnk" "$INSTDIR\Uninstall.exe"
489 SectionEnd
491 ;--------------------
492 ;Post-install section
494 Section -post
496 SetOverwrite on
498 ; delete old devcon.exe
499 Delete "$INSTDIR\bin\devcon.exe"
501 ; Store README, license, icon
502 SetOverwrite on
503 SetOutPath $INSTDIR
504 !ifndef USE_XGUI
505 File "${GEN}\text\INSTALL-win32.txt"
506 !endif
507 File "${GEN}\text\license.txt"
508 File "${GEN}\images\${PRODUCT_ICON}"
510 ; store sample config files
511 !ifdef SAMPCONF_DIR
512 SetOverwrite on
513 SetOutPath "$INSTDIR\config"
514 !ifdef SAMPCONF_CONF
515 File "${GEN}\conf\${SAMPCONF_CONF}"
516 !endif
517 !ifdef SAMPCONF_CONF2
518 File "${GEN}\conf\${SAMPCONF_CONF2}"
519 !endif
520 !ifdef SAMPCONF_P12
521 File "${GEN}\conf\${SAMPCONF_P12}"
522 !endif
523 !ifdef SAMPCONF_TA
524 File "${GEN}\conf\${SAMPCONF_TA}"
525 !endif
526 !ifdef SAMPCONF_CA
527 File "${GEN}\conf\${SAMPCONF_CA}"
528 !endif
529 !ifdef SAMPCONF_CRT
530 File "${GEN}\conf\${SAMPCONF_CRT}"
531 !endif
532 !ifdef SAMPCONF_KEY
533 File "${GEN}\conf\${SAMPCONF_KEY}"
534 !endif
535 !ifdef SAMPCONF_DH
536 File "${GEN}\conf\${SAMPCONF_DH}"
537 !endif
538 !endif
540 ; Try to extract files if present
541 !ifdef EXTRACT_FILES
542 Push "$INSTDIR"
543 Call MultiFileExtract
544 Pop $R0
545 IntCmp $R0 0 +3 +1 +1
546 DetailPrint "MultiFileExtract Failed status=$R0"
547 goto +2
548 DetailPrint "MultiFileExtract Succeeded"
549 !endif
552 ; install/upgrade TAP driver if selected, using tapinstall.exe
554 SectionGetFlags ${SecTAP} $R0
555 IntOp $R0 $R0 & ${SF_SELECTED}
556 IntCmp $R0 ${SF_SELECTED} "" notap notap
557 ; TAP install/update was selected.
558 ; Should we install or update?
559 ; If tapinstall error occurred, $5 will
560 ; be nonzero.
561 IntOp $5 0 & 0
562 nsExec::ExecToStack '"$INSTDIR\bin\tapinstall.exe" hwids ${TAP}'
563 Pop $R0 # return value/error/timeout
564 IntOp $5 $5 | $R0
565 DetailPrint "tapinstall hwids returned: $R0"
567 ; If tapinstall output string contains "${TAP}" we assume
568 ; that TAP device has been previously installed,
569 ; therefore we will update, not install.
570 Push "${TAP}"
571 Call StrStr
572 Pop $R0
574 IntCmp $5 0 "" tapinstall_check_error tapinstall_check_error
575 IntCmp $R0 -1 tapinstall
577 ;tapupdate:
578 DetailPrint "TAP UPDATE"
579 nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" update "$INSTDIR\driver\OemWin2k.inf" ${TAP}'
580 Pop $R0 # return value/error/timeout
581 Call CheckReboot
582 IntOp $5 $5 | $R0
583 DetailPrint "tapinstall update returned: $R0"
584 Goto tapinstall_check_error
586 tapinstall:
587 DetailPrint "TAP REMOVE OLD TAP"
589 nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" remove TAP0801'
590 Pop $R0 # return value/error/timeout
591 DetailPrint "tapinstall remove TAP0801 returned: $R0"
593 DetailPrint "TAP INSTALL (${TAP})"
594 nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" install "$INSTDIR\driver\OemWin2k.inf" ${TAP}'
595 Pop $R0 # return value/error/timeout
596 Call CheckReboot
597 IntOp $5 $5 | $R0
598 DetailPrint "tapinstall install returned: $R0"
600 tapinstall_check_error:
601 DetailPrint "tapinstall cumulative status: $5"
602 IntCmp $5 0 notap
603 MessageBox MB_OK "An error occurred installing the TAP device driver."
605 notap:
607 ; Store install folder in registry
608 WriteRegStr HKLM SOFTWARE\${PRODUCT_NAME} "" $INSTDIR
610 ; install as a service if requested
611 SectionGetFlags ${SecService} $R0
612 IntOp $R0 $R0 & ${SF_SELECTED}
613 IntCmp $R0 ${SF_SELECTED} "" noserv noserv
615 ; set registry parameters for openvpnserv
616 !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "config_dir" "${SERV_CONFIG_DIR}"
617 !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "config_ext" "${SERV_CONFIG_EXT}"
618 !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "exe_path" "${SERV_EXE_PATH}"
619 !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "log_dir" "${SERV_LOG_DIR}"
620 !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "priority" "${SERV_PRIORITY}"
621 !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "log_append" "${SERV_LOG_APPEND}"
623 ; install openvpnserv as a service (to be started manually from service control manager)
624 DetailPrint "Service INSTALL"
625 nsExec::ExecToLog '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe" -install'
626 Pop $R0 # return value/error/timeout
628 noserv:
629 !ifdef USE_XGUI
630 IfFileExists "$INSTDIR\bin\${XGUI_XMLSERV}" "" fileass
631 ; install and automatically start XML service
632 DetailPrint "XML Service INSTALL"
633 nsExec::ExecToLog '"$INSTDIR\bin\${XGUI_XMLSERV}" -install'
634 Pop $R0 # return value/error/timeout
636 Sleep 2000
638 DetailPrint "XML Service START"
639 nsExec::ExecToLog '"$INSTDIR\bin\${XGUI_XMLSERV}" -start'
640 Pop $R0 # return value/error/timeout
642 !endif
644 ; Create file association if requested
645 fileass:
646 SectionGetFlags ${SecFileAssociation} $R0
647 IntOp $R0 $R0 & ${SF_SELECTED}
648 IntCmp $R0 ${SF_SELECTED} "" noass noass
649 WriteRegStr HKCR ".${SERV_CONFIG_EXT}" "" "${PRODUCT_NAME}File"
650 WriteRegStr HKCR "${PRODUCT_NAME}File" "" "${PRODUCT_NAME} Config File"
651 WriteRegStr HKCR "${PRODUCT_NAME}File\shell" "" "open"
652 WriteRegStr HKCR "${PRODUCT_NAME}File\DefaultIcon" "" "$INSTDIR\${PRODUCT_ICON},0"
653 WriteRegStr HKCR "${PRODUCT_NAME}File\shell\open\command" "" 'notepad.exe "%1"'
654 WriteRegStr HKCR "${PRODUCT_NAME}File\shell\run" "" "Start ${PRODUCT_NAME} on this config file"
655 WriteRegStr HKCR "${PRODUCT_NAME}File\shell\run\command" "" '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe" --pause-exit --config "%1"'
657 ; Create start menu folders
658 noass:
659 CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}\Utilities"
660 CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts"
662 ; Create start menu and desktop shortcuts to OpenVPN GUI
663 !ifdef USE_GUI
664 IfFileExists "$INSTDIR\bin\${OPENVPN_GUI}" "" tryaddxgui
665 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} GUI.lnk" "$INSTDIR\bin\${OPENVPN_GUI}" ""
666 CreateShortcut "$DESKTOP\${PRODUCT_NAME} GUI.lnk" "$INSTDIR\bin\${OPENVPN_GUI}"
667 !endif
669 ; Create start menu and desktop shortcuts to OpenVPN XGUI
670 tryaddxgui:
671 !ifdef USE_XGUI
672 IfFileExists "$INSTDIR\bin\${XGUI_EXE}" "" tryaddtray
673 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${XGUI_TRANSITION_GUI_NAME}.lnk" "$INSTDIR\bin\${XGUI_EXE}" ""
674 # CreateShortcut "$DESKTOP\${XGUI_TRANSITION_GUI_NAME}.lnk" "$INSTDIR\bin\${XGUI_EXE}"
675 tryaddtray:
676 IfFileExists "$INSTDIR\bin\${XGUI_TRAY}" "" tryaddtap
677 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${XGUI_AJAX_GUI_NAME}.lnk" "$INSTDIR\bin\${XGUI_EXE}" ""
678 CreateShortcut "$DESKTOP\${XGUI_AJAX_GUI_NAME}.lnk" "$INSTDIR\bin\${XGUI_TRAY}"
679 !endif
681 ; Create start menu shortcuts to addtap.bat and deltapall.bat
682 tryaddtap:
683 IfFileExists "$INSTDIR\bin\addtap.bat" "" trydeltap
684 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Utilities\Add a new TAP virtual ethernet adapter.lnk" "$INSTDIR\bin\addtap.bat" ""
686 trydeltap:
687 IfFileExists "$INSTDIR\bin\deltapall.bat" "" config_shortcut
688 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Utilities\Delete ALL TAP virtual ethernet adapters.lnk" "$INSTDIR\bin\deltapall.bat" ""
690 ; Create start menu shortcuts for config and log directories
691 config_shortcut:
692 IfFileExists "$INSTDIR\config" "" log_shortcut
693 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts\${PRODUCT_NAME} configuration file directory.lnk" "$INSTDIR\config" ""
695 log_shortcut:
696 IfFileExists "$INSTDIR\log" "" samp_shortcut
697 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts\${PRODUCT_NAME} log file directory.lnk" "$INSTDIR\log" ""
699 samp_shortcut:
700 IfFileExists "$INSTDIR\sample-config" "" genkey_shortcut
701 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts\${PRODUCT_NAME} Sample Configuration Files.lnk" "$INSTDIR\sample-config" ""
703 genkey_shortcut:
704 IfFileExists "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe" "" noshortcuts
705 IfFileExists "$INSTDIR\config" "" noshortcuts
706 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Utilities\Generate a static ${PRODUCT_NAME} key.lnk" "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe" '--pause-exit --verb 3 --genkey --secret "$INSTDIR\config\key.txt"' "$INSTDIR\${PRODUCT_ICON}" 0
708 noshortcuts:
709 ; Create uninstaller
710 WriteUninstaller "$INSTDIR\Uninstall.exe"
712 ; Show up in Add/Remove programs
713 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayName" "${PRODUCT_NAME} ${VERSION}"
714 WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" "$INSTDIR\Uninstall.exe"
715 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayIcon" "$INSTDIR\${PRODUCT_ICON}"
716 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayVersion" "${VERSION}"
718 ; Advise a reboot
719 ;Messagebox MB_OK "IMPORTANT: Rebooting the system is advised in order to finalize TAP driver installation/upgrade (this is an informational message only, pressing OK will not reboot)."
721 SectionEnd
723 ;--------------------------------
724 ;Descriptions
726 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
727 !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNUserSpace} $(DESC_SecOpenVPNUserSpace)
728 !ifdef USE_GUI
729 !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNGUI} $(DESC_SecOpenVPNGUI)
730 !endif
731 !ifdef USE_XGUI
732 !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNXGUI} $(DESC_SecOpenVPNXGUI)
733 !endif
734 !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNEasyRSA} $(DESC_SecOpenVPNEasyRSA)
735 !insertmacro MUI_DESCRIPTION_TEXT ${SecTAP} $(DESC_SecTAP)
736 !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenSSLUtilities} $(DESC_SecOpenSSLUtilities)
737 !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenSSLDLLs} $(DESC_SecOpenSSLDLLs)
738 !insertmacro MUI_DESCRIPTION_TEXT ${SecPKCS11DLLs} $(DESC_SecPKCS11DLLs)
739 !insertmacro MUI_DESCRIPTION_TEXT ${SecAddPath} $(DESC_SecAddPath)
740 !insertmacro MUI_DESCRIPTION_TEXT ${SecAddShortcuts} $(DESC_SecAddShortcuts)
741 !insertmacro MUI_DESCRIPTION_TEXT ${SecService} $(DESC_SecService)
742 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssociation} $(DESC_SecFileAssociation)
743 !insertmacro MUI_FUNCTION_DESCRIPTION_END
745 ;--------------------------------
746 ;Uninstaller Section
748 Function un.onInit
749 ClearErrors
750 UserInfo::GetName
751 IfErrors ok
752 Pop $R0
753 UserInfo::GetAccountType
754 Pop $R1
755 StrCmp $R1 "Admin" ok
756 Messagebox MB_OK "Administrator privileges required to uninstall ${PRODUCT_NAME} [$R0/$R1]"
757 Abort
759 FunctionEnd
761 Section "Uninstall"
763 !ifdef USE_XGUI
764 DetailPrint "XML Service REMOVE"
765 nsExec::ExecToLog '"$INSTDIR\bin\${XGUI_XMLSERV}" -remove'
766 Pop $R0 # return value/error/timeout
767 !endif
769 ; Stop OpenVPN if currently running
770 DetailPrint "Service REMOVE"
771 nsExec::ExecToLog '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe" -remove'
772 Pop $R0 # return value/error/timeout
774 Sleep 3000
776 DetailPrint "TAP REMOVE"
777 nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" remove ${TAP}'
778 Pop $R0 # return value/error/timeout
779 DetailPrint "tapinstall remove returned: $R0"
781 Push "$INSTDIR\bin"
782 Call un.RemoveFromPath
784 RMDir /r $SMPROGRAMS\${PRODUCT_NAME}
786 ; delete sample config files
787 !ifdef SAMPCONF_DIR
788 !ifdef SAMPCONF_CONF
789 Delete "$INSTDIR\config\${SAMPCONF_CONF}"
790 !endif
791 !ifdef SAMPCONF_CONF2
792 Delete "$INSTDIR\config\${SAMPCONF_CONF2}"
793 !endif
794 !ifdef SAMPCONF_P12
795 Delete "$INSTDIR\config\${SAMPCONF_P12}"
796 !endif
797 !ifdef SAMPCONF_TA
798 Delete "$INSTDIR\config\${SAMPCONF_TA}"
799 !endif
800 !ifdef SAMPCONF_CA
801 Delete "$INSTDIR\config\${SAMPCONF_CA}"
802 !endif
803 !ifdef SAMPCONF_CRT
804 Delete "$INSTDIR\config\${SAMPCONF_CRT}"
805 !endif
806 !ifdef SAMPCONF_KEY
807 Delete "$INSTDIR\config\${SAMPCONF_KEY}"
808 !endif
809 !ifdef SAMPCONF_DH
810 Delete "$INSTDIR\config\${SAMPCONF_DH}"
811 !endif
812 !endif
814 !ifdef USE_GUI
815 Delete "$INSTDIR\bin\${OPENVPN_GUI}"
816 Delete "$DESKTOP\${PRODUCT_NAME} GUI.lnk"
817 !endif
819 !ifdef USE_XGUI
820 Delete "$INSTDIR\bin\${XGUI_EXE}"
821 Delete "$INSTDIR\bin\${XGUI_TRAY}"
822 Delete "$INSTDIR\bin\${XGUI_XMLSERV}"
823 RMDir /r "$INSTDIR\${XGUI_HTDOCS}"
824 Delete "$DESKTOP\${XGUI_AJAX_GUI_NAME}.lnk"
825 Delete "$DESKTOP\${XGUI_TRANSITION_GUI_NAME}.lnk"
826 !endif
828 Delete "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe"
829 Delete "$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe"
830 Delete "$INSTDIR\bin\libeay32.dll"
831 Delete "$INSTDIR\bin\libssl32.dll"
832 Delete "$INSTDIR\bin\libpkcs11-helper-1.dll"
833 Delete "$INSTDIR\bin\tapinstall.exe"
834 Delete "$INSTDIR\bin\addtap.bat"
835 Delete "$INSTDIR\bin\deltapall.bat"
837 Delete "$INSTDIR\config\README.txt"
838 Delete "$INSTDIR\config\sample.${SERV_CONFIG_EXT}.txt"
840 Delete "$INSTDIR\log\README.txt"
842 Delete "$INSTDIR\driver\OemWin2k.inf"
843 Delete "$INSTDIR\driver\${PRODUCT_TAP_ID}.cat"
844 Delete "$INSTDIR\driver\${TAPDRV}"
846 Delete "$INSTDIR\bin\openssl.exe"
848 Delete "$INSTDIR\INSTALL-win32.txt"
849 Delete "$INSTDIR\${PRODUCT_ICON}"
850 Delete "$INSTDIR\license.txt"
851 Delete "$INSTDIR\Uninstall.exe"
853 Delete "$INSTDIR\easy-rsa\openssl.cnf.sample"
854 Delete "$INSTDIR\easy-rsa\vars.bat.sample"
855 Delete "$INSTDIR\easy-rsa\init-config.bat"
856 Delete "$INSTDIR\easy-rsa\README.txt"
857 Delete "$INSTDIR\easy-rsa\build-ca.bat"
858 Delete "$INSTDIR\easy-rsa\build-dh.bat"
859 Delete "$INSTDIR\easy-rsa\build-key-server.bat"
860 Delete "$INSTDIR\easy-rsa\build-key.bat"
861 Delete "$INSTDIR\easy-rsa\build-key-pkcs12.bat"
862 Delete "$INSTDIR\easy-rsa\clean-all.bat"
863 Delete "$INSTDIR\easy-rsa\index.txt.start"
864 Delete "$INSTDIR\easy-rsa\revoke-key.bat"
865 Delete "$INSTDIR\easy-rsa\revoke-full.bat"
866 Delete "$INSTDIR\easy-rsa\serial.start"
868 Delete "$INSTDIR\sample-config\*.${PRODUCT_FILE_EXT}"
870 RMDir "$INSTDIR\bin"
871 RMDir "$INSTDIR\config"
872 RMDir "$INSTDIR\driver"
873 RMDir "$INSTDIR\easy-rsa"
874 RMDir "$INSTDIR\sample-config"
875 RMDir /r "$INSTDIR\log"
876 RMDir "$INSTDIR"
878 !insertmacro DelRegKeyIfUnchanged HKCR ".${SERV_CONFIG_EXT}" "${PRODUCT_NAME}File"
879 DeleteRegKey HKCR "${PRODUCT_NAME}File"
880 DeleteRegKey HKLM SOFTWARE\${PRODUCT_NAME}
881 DeleteRegKey HKCU "Software\${PRODUCT_NAME}"
882 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
884 ;Messagebox MB_OK "IMPORTANT: If you intend on reinstalling ${PRODUCT_NAME} after this uninstall, and you are running Win2K, you are strongly urged to reboot before reinstalling (this is an informational message only, pressing OK will not reboot)."
886 SectionEnd