~ubuntu-branches/ubuntu/saucy/openvpn/saucy-proposed

« back to all changes in this revision

Viewing changes to win/openvpn.nsi

  • Committer: Package Import Robot
  • Author(s): Stéphane Graber
  • Date: 2013-05-24 17:42:45 UTC
  • mfrom: (1.1.19) (10.2.22 sid)
  • Revision ID: package-import@ubuntu.com-20130524174245-g9y6wlforycufqy5
Tags: 2.3.1-2ubuntu1
* Merge from Debian unstable. Remaining changes:
  - debian/openvpn.init.d:
    + Do not use start-stop-daemon and </dev/null to avoid blocking boot.
    + Show per-VPN result messages.
    + Add "--script-security 2" by default for backwards compatabliity.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
; ****************************************************************************
2
 
; * Copyright (C) 2002-2010 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
 
; ****************************************************************************
7
 
 
8
 
; OpenVPN install script for Windows, using NSIS
9
 
 
10
 
; Start menu entries don't get uninstalled properly on Windows Vista/7 unless we
11
 
; explicitly state that the installer requires admin privileges. This is
12
 
; caused by backwards compatibility tricks used on those platforms. For details,
13
 
; see http://nsis.sourceforge.net/Shortcuts_removal_fails_on_Windows_Vista
14
 
RequestExecutionLevel admin
15
 
 
16
 
SetCompressor lzma
17
 
 
18
 
!include "MUI.nsh"
19
 
 
20
 
# Include basic build settings
21
 
!include "settings.in"
22
 
 
23
 
# Include variables generated dynamically from version.m4 by wb.py
24
 
!include "version_m4_vars.tmp"
25
 
 
26
 
;!include "guidefs.nsi"
27
 
!include "setpath.nsi"
28
 
 
29
 
!ifdef EXTRACT_FILES
30
 
!include "MultiFileExtract.nsi"
31
 
!endif
32
 
 
33
 
!define GEN "..\dist"
34
 
!define BIN "${GEN}\bin"
35
 
!define EASYRSA "..\easy-rsa"
36
 
 
37
 
!define PRODUCT_ICON "icon.ico"
38
 
 
39
 
!ifdef PRODUCT_TAP_DEBUG
40
 
!define DBG_POSTFIX "-DBG"
41
 
!else
42
 
!define DBG_POSTFIX ""
43
 
!endif
44
 
 
45
 
!define VERSION "${PRODUCT_VERSION}${DBG_POSTFIX}"
46
 
 
47
 
!define TAP "${PRODUCT_TAP_ID}"
48
 
!define TAPDRV "${TAP}.sys"
49
 
 
50
 
; Default service settings
51
 
!define SERV_CONFIG_DIR   "$INSTDIR\config"
52
 
!define SERV_CONFIG_EXT   "${PRODUCT_FILE_EXT}"
53
 
!define SERV_EXE_PATH     "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe"
54
 
!define SERV_LOG_DIR      "$INSTDIR\log"
55
 
!define SERV_PRIORITY     "NORMAL_PRIORITY_CLASS"
56
 
!define SERV_LOG_APPEND   "0"
57
 
 
58
 
;--------------------------------
59
 
;Configuration
60
 
 
61
 
  ;General
62
 
 
63
 
  OutFile "${GEN}\${PRODUCT_UNIX_NAME}-${VERSION}${OUTFILE_LABEL}-install.exe"
64
 
 
65
 
  ShowInstDetails show
66
 
  ShowUninstDetails show
67
 
 
68
 
  ;Folder selection page
69
 
  InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
70
 
  
71
 
  ;Remember install folder
72
 
  InstallDirRegKey HKCU "Software\${PRODUCT_NAME}" ""
73
 
 
74
 
;--------------------------------
75
 
;Modern UI Configuration
76
 
 
77
 
  Name "${PRODUCT_NAME} ${VERSION} ${TITLE_LABEL}"
78
 
 
79
 
  !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} only runs on XP, or higher.\r\n\r\n\r\n"
80
 
 
81
 
  !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."
82
 
 
83
 
  !define MUI_COMPONENTSPAGE_SMALLDESC
84
 
  !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\INSTALL-win32.txt"
85
 
  !define MUI_FINISHPAGE_NOAUTOCLOSE
86
 
  !define MUI_ABORTWARNING
87
 
  !define MUI_ICON "..\images\${PRODUCT_ICON}"
88
 
  !define MUI_UNICON "..\images\${PRODUCT_ICON}"
89
 
  !define MUI_HEADERIMAGE
90
 
  !define MUI_HEADERIMAGE_BITMAP "..\images\install-whirl.bmp"
91
 
  !define MUI_UNFINISHPAGE_NOAUTOCLOSE
92
 
 
93
 
  !insertmacro MUI_PAGE_WELCOME
94
 
  !insertmacro MUI_PAGE_LICENSE "..\COPYRIGHT.GPL"
95
 
  !insertmacro MUI_PAGE_COMPONENTS
96
 
  !insertmacro MUI_PAGE_DIRECTORY
97
 
  !insertmacro MUI_PAGE_INSTFILES
98
 
  !insertmacro MUI_PAGE_FINISH
99
 
  
100
 
  !insertmacro MUI_UNPAGE_CONFIRM
101
 
  !insertmacro MUI_UNPAGE_INSTFILES  
102
 
  !insertmacro MUI_UNPAGE_FINISH
103
 
 
104
 
 
105
 
;--------------------------------
106
 
;Languages
107
 
 
108
 
  !insertmacro MUI_LANGUAGE "English"
109
 
  
110
 
;--------------------------------
111
 
;Language Strings
112
 
 
113
 
  LangString DESC_SecOpenVPNUserSpace ${LANG_ENGLISH} "Install ${PRODUCT_NAME} user-space components, including ${PRODUCT_UNIX_NAME}.exe."
114
 
 
115
 
!ifdef USE_GUI
116
 
  LangString DESC_SecOpenVPNGUI ${LANG_ENGLISH} "Install ${PRODUCT_NAME} GUI by Mathias Sundman"
117
 
!endif
118
 
 
119
 
  LangString DESC_SecOpenVPNEasyRSA ${LANG_ENGLISH} "Install ${PRODUCT_NAME} RSA scripts for X509 certificate management."
120
 
 
121
 
  LangString DESC_SecOpenSSLDLLs ${LANG_ENGLISH} "Install OpenSSL DLLs locally (may be omitted if DLLs are already installed globally)."
122
 
 
123
 
  LangString DESC_SecPKCS11DLLs ${LANG_ENGLISH} "Install PKCS#11 helper DLLs locally (may be omitted if DLLs are already installed globally)."
124
 
 
125
 
  LangString DESC_SecLZO2DLLs ${LANG_ENGLISH} "Install LZO2 DLLs locally (may be omitted if DLLs are already installed globally)."
126
 
 
127
 
  LangString DESC_SecMSVCR90DLL ${LANG_ENGLISH} "Install Microsoft Visual C 9.0 Runtime (may be omitted if it is already installed globally)."
128
 
 
129
 
  LangString DESC_SecTAP ${LANG_ENGLISH} "Install/Upgrade the TAP virtual device driver.  Will not interfere with CIPE."
130
 
 
131
 
  LangString DESC_SecService ${LANG_ENGLISH} "Install the ${PRODUCT_NAME} service wrapper (${PRODUCT_UNIX_NAME}serv.exe)"
132
 
 
133
 
  LangString DESC_SecOpenSSLUtilities ${LANG_ENGLISH} "Install the OpenSSL Utilities (used for generating public/private key pairs)."
134
 
 
135
 
  LangString DESC_SecAddPath ${LANG_ENGLISH} "Add ${PRODUCT_NAME} executable directory to the current user's PATH."
136
 
 
137
 
  LangString DESC_SecAddShortcuts ${LANG_ENGLISH} "Add ${PRODUCT_NAME} shortcuts to the current user's Start Menu."
138
 
 
139
 
  LangString DESC_SecFileAssociation ${LANG_ENGLISH} "Register ${PRODUCT_NAME} config file association (*.${SERV_CONFIG_EXT})"
140
 
 
141
 
;--------------------------------
142
 
;Reserve Files
143
 
  
144
 
  ;Things that need to be extracted on first (keep these lines before any File command!)
145
 
  ;Only useful for BZIP2 compression
146
 
  
147
 
  ReserveFile "..\images\install-whirl.bmp"
148
 
 
149
 
;--------------------------------
150
 
;Macros
151
 
 
152
 
!macro WriteRegStringIfUndef ROOT SUBKEY KEY VALUE
153
 
Push $R0
154
 
ReadRegStr $R0 "${ROOT}" "${SUBKEY}" "${KEY}"
155
 
StrCmp $R0 "" +1 +2
156
 
WriteRegStr "${ROOT}" "${SUBKEY}" "${KEY}" '${VALUE}'
157
 
Pop $R0
158
 
!macroend
159
 
 
160
 
!macro DelRegStringIfUnchanged ROOT SUBKEY KEY VALUE
161
 
Push $R0
162
 
ReadRegStr $R0 "${ROOT}" "${SUBKEY}" "${KEY}"
163
 
StrCmp $R0 '${VALUE}' +1 +2
164
 
DeleteRegValue "${ROOT}" "${SUBKEY}" "${KEY}"
165
 
Pop $R0
166
 
!macroend
167
 
 
168
 
!macro DelRegKeyIfUnchanged ROOT SUBKEY VALUE
169
 
Push $R0
170
 
ReadRegStr $R0 "${ROOT}" "${SUBKEY}" ""
171
 
StrCmp $R0 '${VALUE}' +1 +2
172
 
DeleteRegKey "${ROOT}" "${SUBKEY}"
173
 
Pop $R0
174
 
!macroend
175
 
 
176
 
!macro DelRegKeyIfEmpty ROOT SUBKEY
177
 
Push $R0
178
 
EnumRegValue $R0 "${ROOT}" "${SUBKEY}" 1
179
 
StrCmp $R0 "" +1 +2
180
 
DeleteRegKey /ifempty "${ROOT}" "${SUBKEY}"
181
 
Pop $R0
182
 
!macroend
183
 
 
184
 
;------------------------------------------
185
 
;Set reboot flag based on tapinstall return
186
 
 
187
 
Function CheckReboot
188
 
  IntCmp $R0 1 "" noreboot noreboot
189
 
  IntOp $R0 0 & 0
190
 
  SetRebootFlag true
191
 
  DetailPrint "REBOOT flag set"
192
 
 noreboot:
193
 
FunctionEnd
194
 
 
195
 
;--------------------------------
196
 
;Installer Sections
197
 
 
198
 
Function .onInit
199
 
  ClearErrors
200
 
 
201
 
# Verify that user has admin privs
202
 
  UserInfo::GetName
203
 
  IfErrors ok
204
 
  Pop $R0
205
 
  UserInfo::GetAccountType
206
 
  Pop $R1
207
 
  StrCmp $R1 "Admin" ok
208
 
    Messagebox MB_OK "Administrator privileges required to install ${PRODUCT_NAME} [$R0/$R1]"
209
 
    Abort
210
 
  ok:
211
 
 
212
 
# Delete previous start menu
213
 
  RMDir /r $SMPROGRAMS\${PRODUCT_NAME}
214
 
 
215
 
# FIXME: reimplement Windows version checking code that was located here, but 
216
 
# disabled intentionally to avoid Windows 7 issues. This should do it:
217
 
#
218
 
# http://nsis.sourceforge.net/Get_Windows_version
219
 
#
220
 
# Blacklisting should be safer than whitelisting used originally.
221
 
 
222
 
FunctionEnd
223
 
 
224
 
!ifndef SF_SELECTED
225
 
!define SF_SELECTED 1
226
 
!endif
227
 
 
228
 
;--------------------
229
 
;Pre-install section
230
 
 
231
 
Section -pre
232
 
 
233
 
  ; Stop OpenVPN if currently running
234
 
  DetailPrint "Previous Service REMOVE (if exists)"
235
 
  nsExec::ExecToLog '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe" -remove'
236
 
  Pop $R0 # return value/error/timeout
237
 
 
238
 
  Sleep 3000
239
 
 
240
 
  # Fix for Trac ticket 120. Remove after 2.3 has been released.
241
 
  !ifdef USE_GUI
242
 
    SetShellVarContext current
243
 
    Delete "$DESKTOP\${PRODUCT_NAME} GUI.lnk"
244
 
  !endif
245
 
 
246
 
SectionEnd
247
 
 
248
 
Section "${PRODUCT_NAME} User-Space Components" SecOpenVPNUserSpace
249
 
 
250
 
  SetOverwrite on
251
 
  SetOutPath "$INSTDIR\bin"
252
 
 
253
 
  File "${BIN}\${PRODUCT_UNIX_NAME}.exe"
254
 
 
255
 
SectionEnd
256
 
 
257
 
!ifdef USE_GUI
258
 
Section "${PRODUCT_NAME} GUI" SecOpenVPNGUI
259
 
 
260
 
  SetOverwrite on
261
 
  SetOutPath "$INSTDIR\bin"
262
 
 
263
 
  File "${BIN}\${OPENVPN_GUI}"
264
 
 
265
 
SectionEnd
266
 
!endif
267
 
 
268
 
Section "${PRODUCT_NAME} RSA Certificate Management Scripts" SecOpenVPNEasyRSA
269
 
 
270
 
  SetOverwrite on
271
 
  SetOutPath "$INSTDIR\easy-rsa"
272
 
 
273
 
  # FIXME: the easy-rsa directory would need cleaning up
274
 
 
275
 
  # Original nsi script looked for ${EASYRSA}\2.0\openssl.cnf.sample. A newer
276
 
  # openssl.cnf is needed on OpenVPN 2.2+.
277
 
  File "${EASYRSA}\2.0\openssl-1.0.0.cnf"
278
 
 
279
 
  File "${EASYRSA}\Windows\vars.bat.sample"
280
 
 
281
 
  File "${EASYRSA}\Windows\init-config.bat"
282
 
 
283
 
  File "${EASYRSA}\Windows\README.txt"
284
 
  File "${EASYRSA}\Windows\build-ca.bat"
285
 
  File "${EASYRSA}\Windows\build-dh.bat"
286
 
  File "${EASYRSA}\Windows\build-key-server.bat"
287
 
  File "${EASYRSA}\Windows\build-key.bat"
288
 
  File "${EASYRSA}\Windows\build-key-pkcs12.bat"
289
 
  File "${EASYRSA}\Windows\clean-all.bat"
290
 
  File "${EASYRSA}\Windows\index.txt.start"
291
 
  File "${EASYRSA}\Windows\revoke-full.bat"
292
 
  File "${EASYRSA}\Windows\serial.start"
293
 
 
294
 
SectionEnd
295
 
 
296
 
Section "${PRODUCT_NAME} Service" SecService
297
 
 
298
 
  SetOverwrite on
299
 
 
300
 
  SetOutPath "$INSTDIR\bin"
301
 
  File "${BIN}\${PRODUCT_UNIX_NAME}serv.exe"
302
 
 
303
 
  SetOutPath "$INSTDIR\config"
304
 
 
305
 
  FileOpen $R0 "$INSTDIR\config\README.txt" w
306
 
  FileWrite $R0 "This directory should contain ${PRODUCT_NAME} configuration files$\r$\n"
307
 
  FileWrite $R0 "each having an extension of .${SERV_CONFIG_EXT}$\r$\n"
308
 
  FileWrite $R0 "$\r$\n"
309
 
  FileWrite $R0 "When ${PRODUCT_NAME} is started as a service, a separate ${PRODUCT_NAME}$\r$\n"
310
 
  FileWrite $R0 "process will be instantiated for each configuration file.$\r$\n"
311
 
  FileClose $R0
312
 
 
313
 
  SetOutPath "$INSTDIR\sample-config"
314
 
  File "${GEN}\samples\sample.${SERV_CONFIG_EXT}"
315
 
  File "${GEN}\samples\client.${SERV_CONFIG_EXT}"
316
 
  File "${GEN}\samples\server.${SERV_CONFIG_EXT}"
317
 
 
318
 
  CreateDirectory "$INSTDIR\log"
319
 
  FileOpen $R0 "$INSTDIR\log\README.txt" w
320
 
  FileWrite $R0 "This directory will contain the log files for ${PRODUCT_NAME}$\r$\n"
321
 
  FileWrite $R0 "sessions which are being run as a service.$\r$\n"
322
 
  FileClose $R0
323
 
 
324
 
SectionEnd
325
 
 
326
 
Section "${PRODUCT_NAME} File Associations" SecFileAssociation
327
 
SectionEnd
328
 
 
329
 
Section "OpenSSL DLLs" SecOpenSSLDLLs
330
 
 
331
 
  SetOverwrite on
332
 
  SetOutPath "$INSTDIR\bin"
333
 
  File "${BIN}\libeay32.dll"
334
 
  File "${BIN}\ssleay32.dll"
335
 
 
336
 
SectionEnd
337
 
 
338
 
Section "OpenSSL Utilities" SecOpenSSLUtilities
339
 
 
340
 
  SetOverwrite on
341
 
  SetOutPath "$INSTDIR\bin"
342
 
  File "${BIN}\openssl.exe"
343
 
 
344
 
SectionEnd
345
 
 
346
 
Section "PKCS#11 DLLs" SecPKCS11DLLs
347
 
 
348
 
  SetOverwrite on
349
 
  SetOutPath "$INSTDIR\bin"
350
 
  File "${BIN}\libpkcs11-helper-1.dll"
351
 
 
352
 
SectionEnd
353
 
 
354
 
Section "LZO2 DLLs" SecLZO2DLLs
355
 
 
356
 
  SetOverwrite on
357
 
  SetOutPath "$INSTDIR\bin"
358
 
  File "${BIN}\lzo2.dll"
359
 
 
360
 
SectionEnd
361
 
 
362
 
Section "Microsoft Visual C 9.0 Runtime DLL" SecMSVCR90DLL
363
 
 
364
 
  SetOverwrite on
365
 
  SetOutPath "$INSTDIR\bin"
366
 
  File "${BIN}\Microsoft.VC90.CRT\msvcr90.dll"
367
 
  File "${BIN}\Microsoft.VC90.CRT\Microsoft.VC90.CRT.manifest"
368
 
 
369
 
SectionEnd
370
 
 
371
 
 
372
 
 
373
 
 
374
 
Section "TAP Virtual Ethernet Adapter" SecTAP
375
 
 
376
 
  SetOverwrite on
377
 
 
378
 
  # Generate TAP driver install script dynamically
379
 
  FileOpen $R0 "$INSTDIR\bin\addtap.bat" w
380
 
  FileWrite $R0 "rem Add a new TAP virtual ethernet adapter$\r$\n"
381
 
  FileWrite $R0 '"$INSTDIR\bin\tapinstall.exe" install "$INSTDIR\driver\OemWin2k.inf" ${TAP}$\r$\n'
382
 
  FileWrite $R0 "pause$\r$\n"
383
 
  FileClose $R0
384
 
 
385
 
  # Generate TAP driver removal script dynamically
386
 
  FileOpen $R0 "$INSTDIR\bin\deltapall.bat" w
387
 
  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"
388
 
  FileWrite $R0 "pause$\r$\n"
389
 
  FileWrite $R0 '"$INSTDIR\bin\tapinstall.exe" remove ${TAP}$\r$\n'
390
 
  FileWrite $R0 "pause$\r$\n"
391
 
  FileClose $R0
392
 
 
393
 
  ; Check if we are running on a 64 bit system.
394
 
  System::Call "kernel32::GetCurrentProcess() i .s"
395
 
  System::Call "kernel32::IsWow64Process(i s, *i .r0)"
396
 
  IntCmp $0 0 tap-32bit
397
 
 
398
 
; tap-64bit:
399
 
 
400
 
  DetailPrint "We are running on a 64-bit system."
401
 
 
402
 
  SetOutPath "$INSTDIR\bin"
403
 
 
404
 
  File "${GEN}\amd64\tapinstall.exe"
405
 
 
406
 
  SetOutPath "$INSTDIR\driver"
407
 
 
408
 
  File "${GEN}\amd64\OemWin2k.inf"
409
 
  File "${GEN}\amd64\${TAPDRV}"
410
 
 
411
 
  # Don't try to install TAP driver signature if it does not exist.
412
 
  File /nonfatal "${GEN}\amd64\${PRODUCT_TAP_ID}.cat"
413
 
 
414
 
goto tapend
415
 
 
416
 
tap-32bit:
417
 
 
418
 
  DetailPrint "We are running on a 32-bit system."
419
 
 
420
 
  SetOutPath "$INSTDIR\bin"
421
 
  File "${GEN}\i386\tapinstall.exe"
422
 
 
423
 
  SetOutPath "$INSTDIR\driver"
424
 
  File "${GEN}\i386\OemWin2k.inf"
425
 
  File "${GEN}\i386\${TAPDRV}"
426
 
 
427
 
  # Don't try to install TAP driver signature if it does not exist.
428
 
  File /nonfatal "${GEN}\i386\${PRODUCT_TAP_ID}.cat"
429
 
 
430
 
  tapend:
431
 
 
432
 
SectionEnd
433
 
 
434
 
Section "Add ${PRODUCT_NAME} to PATH" SecAddPath
435
 
 
436
 
  ; remove previously set path (if any)
437
 
  Push "$INSTDIR\bin"
438
 
  Call RemoveFromPath
439
 
 
440
 
  ; append our bin directory to end of current user path
441
 
  Push "$INSTDIR\bin"
442
 
  Call AddToPath
443
 
 
444
 
SectionEnd
445
 
 
446
 
Section "Add Shortcuts to Start Menu" SecAddShortcuts
447
 
 
448
 
  ; Required to handle shortcuts properly on Vista/7
449
 
  SetShellVarContext all
450
 
  SetOverwrite on
451
 
  CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
452
 
  CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}\Documentation"
453
 
  WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} Windows Notes.url" "InternetShortcut" "URL" "http://openvpn.net/INSTALL-win32.html"
454
 
  WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} Manual Page.url" "InternetShortcut" "URL" "http://openvpn.net/man.html"
455
 
  WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} HOWTO.url" "InternetShortcut" "URL" "http://openvpn.net/howto.html"
456
 
  WriteINIStr "$SMPROGRAMS\${PRODUCT_NAME}\Documentation\${PRODUCT_NAME} Web Site.url" "InternetShortcut" "URL" "http://openvpn.net/"
457
 
  CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall ${PRODUCT_NAME}.lnk" "$INSTDIR\Uninstall.exe"
458
 
 
459
 
SectionEnd
460
 
 
461
 
;--------------------
462
 
;Post-install section
463
 
 
464
 
Section -post
465
 
 
466
 
  SetOverwrite on
467
 
 
468
 
  ; delete old tapinstall.exe
469
 
  ;Delete "$INSTDIR\bin\tapinstall.exe"
470
 
 
471
 
  ; Store README, license, icon
472
 
  SetOverwrite on
473
 
  SetOutPath $INSTDIR
474
 
  File "..\INSTALL-win32.txt"
475
 
  File "..\COPYRIGHT.GPL"
476
 
  File "..\images\${PRODUCT_ICON}"
477
 
 
478
 
  ; store sample config files
479
 
  !ifdef SAMPCONF_DIR
480
 
    SetOverwrite on
481
 
    SetOutPath "$INSTDIR\config"
482
 
  !ifdef SAMPCONF_CONF
483
 
    File "${GEN}\conf\${SAMPCONF_CONF}"
484
 
  !endif
485
 
  !ifdef SAMPCONF_CONF2
486
 
    File "${GEN}\conf\${SAMPCONF_CONF2}"
487
 
  !endif
488
 
  !ifdef SAMPCONF_P12
489
 
    File "${GEN}\conf\${SAMPCONF_P12}"
490
 
  !endif
491
 
  !ifdef SAMPCONF_TA
492
 
    File "${GEN}\conf\${SAMPCONF_TA}"
493
 
  !endif
494
 
  !ifdef SAMPCONF_CA
495
 
    File "${GEN}\conf\${SAMPCONF_CA}"
496
 
  !endif
497
 
  !ifdef SAMPCONF_CRT
498
 
    File "${GEN}\conf\${SAMPCONF_CRT}"
499
 
  !endif
500
 
  !ifdef SAMPCONF_KEY
501
 
    File "${GEN}\conf\${SAMPCONF_KEY}"
502
 
  !endif
503
 
  !ifdef SAMPCONF_DH
504
 
    File "${GEN}\conf\${SAMPCONF_DH}"
505
 
  !endif
506
 
  !endif
507
 
 
508
 
  ; Try to extract files if present
509
 
  !ifdef EXTRACT_FILES
510
 
    Push "$INSTDIR"
511
 
    Call MultiFileExtract
512
 
    Pop $R0
513
 
    IntCmp $R0 0 +3 +1 +1
514
 
    DetailPrint "MultiFileExtract Failed status=$R0"
515
 
    goto +2
516
 
    DetailPrint "MultiFileExtract Succeeded"
517
 
  !endif
518
 
 
519
 
  ;
520
 
  ; install/upgrade TAP driver if selected, using tapinstall.exe
521
 
  ;
522
 
  SectionGetFlags ${SecTAP} $R0
523
 
  IntOp $R0 $R0 & ${SF_SELECTED}
524
 
  IntCmp $R0 ${SF_SELECTED} "" notap notap
525
 
    ; TAP install/update was selected.
526
 
    ; Should we install or update?
527
 
    ; If tapinstall error occurred, $5 will
528
 
    ; be nonzero.
529
 
    IntOp $5 0 & 0
530
 
    nsExec::ExecToStack '"$INSTDIR\bin\tapinstall.exe" hwids ${TAP}'
531
 
    Pop $R0 # return value/error/timeout
532
 
    IntOp $5 $5 | $R0
533
 
    DetailPrint "tapinstall hwids returned: $R0"
534
 
 
535
 
    ; If tapinstall output string contains "${TAP}" we assume
536
 
    ; that TAP device has been previously installed,
537
 
    ; therefore we will update, not install.
538
 
    Push "${TAP}"
539
 
    Call StrStr
540
 
    Pop $R0
541
 
 
542
 
    IntCmp $5 0 "" tapinstall_check_error tapinstall_check_error
543
 
    IntCmp $R0 -1 tapinstall
544
 
 
545
 
 ;tapupdate:
546
 
    DetailPrint "TAP UPDATE"
547
 
    nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" update "$INSTDIR\driver\OemWin2k.inf" ${TAP}'
548
 
    Pop $R0 # return value/error/timeout
549
 
    Call CheckReboot
550
 
    IntOp $5 $5 | $R0
551
 
    DetailPrint "tapinstall update returned: $R0"
552
 
    Goto tapinstall_check_error
553
 
 
554
 
 tapinstall:
555
 
    DetailPrint "TAP REMOVE OLD TAP"
556
 
 
557
 
    nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" remove TAP0801'
558
 
    Pop $R0 # return value/error/timeout
559
 
    DetailPrint "tapinstall remove TAP0801 returned: $R0"
560
 
 
561
 
    DetailPrint "TAP INSTALL (${TAP})"
562
 
    nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" install "$INSTDIR\driver\OemWin2k.inf" ${TAP}'
563
 
    Pop $R0 # return value/error/timeout
564
 
    Call CheckReboot
565
 
    IntOp $5 $5 | $R0
566
 
    DetailPrint "tapinstall install returned: $R0"
567
 
 
568
 
 tapinstall_check_error:
569
 
    DetailPrint "tapinstall cumulative status: $5"
570
 
    IntCmp $5 0 notap
571
 
    MessageBox MB_OK "An error occurred installing the TAP device driver."
572
 
 
573
 
 notap:
574
 
 
575
 
  ; Store install folder in registry
576
 
  WriteRegStr HKLM SOFTWARE\${PRODUCT_NAME} "" $INSTDIR
577
 
 
578
 
  ; install as a service if requested
579
 
  SectionGetFlags ${SecService} $R0
580
 
  IntOp $R0 $R0 & ${SF_SELECTED}
581
 
  IntCmp $R0 ${SF_SELECTED} "" noserv noserv
582
 
 
583
 
    ; set registry parameters for openvpnserv   
584
 
    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "config_dir"  "${SERV_CONFIG_DIR}"
585
 
    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "config_ext"  "${SERV_CONFIG_EXT}"
586
 
    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "exe_path"    "${SERV_EXE_PATH}"
587
 
    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "log_dir"     "${SERV_LOG_DIR}"
588
 
    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "priority"    "${SERV_PRIORITY}"
589
 
    !insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\${PRODUCT_NAME}" "log_append"  "${SERV_LOG_APPEND}"
590
 
 
591
 
    ; install openvpnserv as a service (to be started manually from service control manager)
592
 
    DetailPrint "Service INSTALL"
593
 
    nsExec::ExecToLog '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe" -install'
594
 
    Pop $R0 # return value/error/timeout
595
 
 
596
 
 noserv:
597
 
 
598
 
  ; Create file association if requested
599
 
 fileass:
600
 
  SectionGetFlags ${SecFileAssociation} $R0
601
 
  IntOp $R0 $R0 & ${SF_SELECTED}
602
 
  IntCmp $R0 ${SF_SELECTED} "" noass noass
603
 
    WriteRegStr HKCR ".${SERV_CONFIG_EXT}" "" "${PRODUCT_NAME}File"
604
 
    WriteRegStr HKCR "${PRODUCT_NAME}File" "" "${PRODUCT_NAME} Config File"
605
 
    WriteRegStr HKCR "${PRODUCT_NAME}File\shell" "" "open"
606
 
    WriteRegStr HKCR "${PRODUCT_NAME}File\DefaultIcon" "" "$INSTDIR\${PRODUCT_ICON},0"
607
 
    WriteRegStr HKCR "${PRODUCT_NAME}File\shell\open\command" "" 'notepad.exe "%1"'
608
 
    WriteRegStr HKCR "${PRODUCT_NAME}File\shell\run" "" "Start ${PRODUCT_NAME} on this config file"
609
 
    WriteRegStr HKCR "${PRODUCT_NAME}File\shell\run\command" "" '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe" --pause-exit --config "%1"'
610
 
 
611
 
 ; Create start menu folders
612
 
 noass:
613
 
  CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}\Utilities"
614
 
  CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts"
615
 
 
616
 
  ; Create start menu and desktop shortcuts to OpenVPN GUI
617
 
  !ifdef USE_GUI
618
 
      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME} GUI.lnk" "$INSTDIR\bin\${OPENVPN_GUI}" ""
619
 
      CreateShortcut "$DESKTOP\${PRODUCT_NAME} GUI.lnk" "$INSTDIR\bin\${OPENVPN_GUI}"
620
 
  !endif
621
 
 
622
 
 ; Create start menu shortcuts to addtap.bat and deltapall.bat
623
 
 tryaddtap:
624
 
    IfFileExists "$INSTDIR\bin\addtap.bat" "" trydeltap
625
 
      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Utilities\Add a new TAP virtual ethernet adapter.lnk" "$INSTDIR\bin\addtap.bat" ""
626
 
 
627
 
 trydeltap:
628
 
    IfFileExists "$INSTDIR\bin\deltapall.bat" "" config_shortcut
629
 
      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Utilities\Delete ALL TAP virtual ethernet adapters.lnk" "$INSTDIR\bin\deltapall.bat" ""
630
 
 
631
 
 ; Create start menu shortcuts for config and log directories
632
 
 config_shortcut:
633
 
    IfFileExists "$INSTDIR\config" "" log_shortcut
634
 
      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts\${PRODUCT_NAME} configuration file directory.lnk" "$INSTDIR\config" ""
635
 
 
636
 
 log_shortcut:
637
 
    IfFileExists "$INSTDIR\log" "" samp_shortcut
638
 
      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts\${PRODUCT_NAME} log file directory.lnk" "$INSTDIR\log" ""
639
 
 
640
 
 samp_shortcut:
641
 
    IfFileExists "$INSTDIR\sample-config" "" genkey_shortcut
642
 
      CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Shortcuts\${PRODUCT_NAME} Sample Configuration Files.lnk" "$INSTDIR\sample-config" ""
643
 
 
644
 
 genkey_shortcut:
645
 
    IfFileExists "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe" "" noshortcuts
646
 
      IfFileExists "$INSTDIR\config" "" noshortcuts
647
 
        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
648
 
 
649
 
 noshortcuts:
650
 
  ; Create uninstaller
651
 
  WriteUninstaller "$INSTDIR\Uninstall.exe"
652
 
 
653
 
  ; Show up in Add/Remove programs
654
 
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayName" "${PRODUCT_NAME} ${VERSION}"
655
 
  WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" "$INSTDIR\Uninstall.exe"
656
 
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayIcon" "$INSTDIR\${PRODUCT_ICON}"
657
 
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayVersion" "${VERSION}"
658
 
 
659
 
  ; Advise a reboot
660
 
  ;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)."
661
 
 
662
 
SectionEnd
663
 
 
664
 
;--------------------------------
665
 
;Descriptions
666
 
 
667
 
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
668
 
  !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNUserSpace} $(DESC_SecOpenVPNUserSpace)
669
 
  !ifdef USE_GUI
670
 
    !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNGUI} $(DESC_SecOpenVPNGUI)
671
 
  !endif
672
 
  !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNEasyRSA} $(DESC_SecOpenVPNEasyRSA)
673
 
  !insertmacro MUI_DESCRIPTION_TEXT ${SecTAP} $(DESC_SecTAP)
674
 
  !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenSSLUtilities} $(DESC_SecOpenSSLUtilities)
675
 
  !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenSSLDLLs} $(DESC_SecOpenSSLDLLs)
676
 
  !insertmacro MUI_DESCRIPTION_TEXT ${SecPKCS11DLLs} $(DESC_SecPKCS11DLLs)
677
 
  !insertmacro MUI_DESCRIPTION_TEXT ${SecLZO2DLLs} $(DESC_SecLZO2DLLs)
678
 
  !insertmacro MUI_DESCRIPTION_TEXT ${SecMSVCR90DLL} $(DESC_SecMSVCR90DLL)
679
 
  !insertmacro MUI_DESCRIPTION_TEXT ${SecAddPath} $(DESC_SecAddPath)
680
 
  !insertmacro MUI_DESCRIPTION_TEXT ${SecAddShortcuts} $(DESC_SecAddShortcuts)
681
 
 
682
 
  !insertmacro MUI_DESCRIPTION_TEXT ${SecService} $(DESC_SecService)
683
 
  !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssociation} $(DESC_SecFileAssociation)
684
 
!insertmacro MUI_FUNCTION_DESCRIPTION_END
685
 
 
686
 
;--------------------------------
687
 
;Uninstaller Section
688
 
 
689
 
Function un.onInit
690
 
  ClearErrors
691
 
  UserInfo::GetName
692
 
  IfErrors ok
693
 
  Pop $R0
694
 
  UserInfo::GetAccountType
695
 
  Pop $R1
696
 
  StrCmp $R1 "Admin" ok
697
 
    Messagebox MB_OK "Administrator privileges required to uninstall ${PRODUCT_NAME} [$R0/$R1]"
698
 
    Abort
699
 
  ok:
700
 
FunctionEnd
701
 
 
702
 
Section "Uninstall"
703
 
 
704
 
  ; Required to handle shortcuts properly on Vista/7
705
 
  SetShellVarContext all
706
 
 
707
 
  ; Stop OpenVPN if currently running
708
 
 
709
 
  DetailPrint "Service REMOVE"
710
 
  nsExec::ExecToLog '"$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe" -remove'
711
 
  Pop $R0 # return value/error/timeout
712
 
  
713
 
  Sleep 3000
714
 
 
715
 
  DetailPrint "TAP REMOVE"
716
 
  nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" remove ${TAP}'
717
 
  Pop $R0 # return value/error/timeout
718
 
  DetailPrint "tapinstall remove returned: $R0"
719
 
 
720
 
  Push "$INSTDIR\bin"
721
 
  Call un.RemoveFromPath
722
 
 
723
 
  RMDir /r $SMPROGRAMS\${PRODUCT_NAME}
724
 
 
725
 
  ; delete sample config files
726
 
  !ifdef SAMPCONF_DIR
727
 
  !ifdef SAMPCONF_CONF
728
 
    Delete "$INSTDIR\config\${SAMPCONF_CONF}"
729
 
  !endif
730
 
  !ifdef SAMPCONF_CONF2
731
 
    Delete "$INSTDIR\config\${SAMPCONF_CONF2}"
732
 
  !endif
733
 
  !ifdef SAMPCONF_P12
734
 
    Delete "$INSTDIR\config\${SAMPCONF_P12}"
735
 
  !endif
736
 
  !ifdef SAMPCONF_TA
737
 
    Delete "$INSTDIR\config\${SAMPCONF_TA}"
738
 
  !endif
739
 
  !ifdef SAMPCONF_CA
740
 
    Delete "$INSTDIR\config\${SAMPCONF_CA}"
741
 
  !endif
742
 
  !ifdef SAMPCONF_CRT
743
 
    Delete "$INSTDIR\config\${SAMPCONF_CRT}"
744
 
  !endif
745
 
  !ifdef SAMPCONF_KEY
746
 
    Delete "$INSTDIR\config\${SAMPCONF_KEY}"
747
 
  !endif
748
 
  !ifdef SAMPCONF_DH
749
 
    Delete "$INSTDIR\config\${SAMPCONF_DH}"
750
 
  !endif
751
 
  !endif
752
 
 
753
 
  !ifdef USE_GUI
754
 
    Delete "$INSTDIR\bin\${OPENVPN_GUI}"
755
 
    Delete "$DESKTOP\${PRODUCT_NAME} GUI.lnk"
756
 
  !endif
757
 
 
758
 
  # Files installed by openvpn-2.2-beta5 and earlier
759
 
  Delete "$INSTDIR\easy-rsa\openssl.cnf.sample"
760
 
  Delete "$INSTDIR\license"
761
 
  Delete "$INSTDIR\bin\libssl32.dll"
762
 
 
763
 
  Delete "$INSTDIR\bin\${PRODUCT_UNIX_NAME}.exe"
764
 
  Delete "$INSTDIR\bin\${PRODUCT_UNIX_NAME}serv.exe"
765
 
  Delete "$INSTDIR\bin\libeay32.dll"
766
 
  Delete "$INSTDIR\bin\ssleay32.dll"
767
 
  Delete "$INSTDIR\bin\libpkcs11-helper-1.dll"
768
 
  Delete "$INSTDIR\bin\lzo2.dll"
769
 
  Delete "$INSTDIR\bin\msvcr90.dll"
770
 
  Delete "$INSTDIR\bin\Microsoft.VC90.CRT.manifest"
771
 
  Delete "$INSTDIR\bin\tapinstall.exe"
772
 
  Delete "$INSTDIR\bin\addtap.bat"
773
 
  Delete "$INSTDIR\bin\deltapall.bat"
774
 
 
775
 
  Delete "$INSTDIR\config\README.txt"
776
 
  Delete "$INSTDIR\config\sample.${SERV_CONFIG_EXT}.txt"
777
 
 
778
 
  Delete "$INSTDIR\log\README.txt"
779
 
 
780
 
  Delete "$INSTDIR\driver\OemWin2k.inf"
781
 
  Delete "$INSTDIR\driver\${PRODUCT_TAP_ID}.cat"
782
 
  Delete "$INSTDIR\driver\${TAPDRV}"
783
 
 
784
 
  Delete "$INSTDIR\bin\openssl.exe"
785
 
 
786
 
  Delete "$INSTDIR\INSTALL-win32.txt"
787
 
  Delete "$INSTDIR\${PRODUCT_ICON}"
788
 
  Delete "$INSTDIR\COPYRIGHT.GPL"
789
 
  Delete "$INSTDIR\Uninstall.exe"
790
 
 
791
 
  Delete "$INSTDIR\easy-rsa\openssl.cnf"
792
 
  Delete "$INSTDIR\easy-rsa\vars.bat.sample"
793
 
  Delete "$INSTDIR\easy-rsa\init-config.bat"
794
 
  Delete "$INSTDIR\easy-rsa\README.txt"
795
 
  Delete "$INSTDIR\easy-rsa\build-ca.bat"
796
 
  Delete "$INSTDIR\easy-rsa\build-dh.bat"
797
 
  Delete "$INSTDIR\easy-rsa\build-key-server.bat"
798
 
  Delete "$INSTDIR\easy-rsa\build-key.bat"
799
 
  Delete "$INSTDIR\easy-rsa\build-key-pkcs12.bat"
800
 
  Delete "$INSTDIR\easy-rsa\clean-all.bat"
801
 
  Delete "$INSTDIR\easy-rsa\index.txt.start"
802
 
  Delete "$INSTDIR\easy-rsa\revoke-key.bat"
803
 
  Delete "$INSTDIR\easy-rsa\revoke-full.bat"
804
 
  Delete "$INSTDIR\easy-rsa\serial.start"
805
 
 
806
 
  Delete "$INSTDIR\sample-config\*.${PRODUCT_FILE_EXT}"
807
 
 
808
 
  RMDir "$INSTDIR\bin"
809
 
  RMDir "$INSTDIR\config"
810
 
  RMDir "$INSTDIR\driver"
811
 
  RMDir "$INSTDIR\easy-rsa"
812
 
  RMDir "$INSTDIR\sample-config"
813
 
  RMDir /r "$INSTDIR\log"
814
 
  RMDir "$INSTDIR"
815
 
 
816
 
  !insertmacro DelRegKeyIfUnchanged HKCR ".${SERV_CONFIG_EXT}" "${PRODUCT_NAME}File"
817
 
  DeleteRegKey HKCR "${PRODUCT_NAME}File"
818
 
  DeleteRegKey HKLM SOFTWARE\${PRODUCT_NAME}
819
 
  DeleteRegKey HKCU "Software\${PRODUCT_NAME}"
820
 
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
821
 
 
822
 
SectionEnd