summaryrefslogtreecommitdiff
path: root/win/RiseupVPN-installer.nsi
blob: 5c17018597eb1ec6bfe315df7eb52918299d5cd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
SetCompressor /SOLID lzma

!define PRODUCT_PUBLISHER "LEAP Encryption Access Project"
!include "MUI2.nsh"

Name "RiseupVPN"
Outfile "..\dist\RiseupVPN-installer.exe"
;TODO make the installdir configurable - and set it in the registry.
InstallDir "C:\Program Files\RiseupVPN\"
RequestExecutionLevel admin

!include FileFunc.nsh
!insertmacro GetParameters
!insertmacro GetOptions

;Macros

!macro SelectByParameter SECT PARAMETER DEFAULT
	${GetOptions} $R0 "/${PARAMETER}=" $0
	${If} ${DEFAULT} == 0
		${If} $0 == 1
			!insertmacro SelectSection ${SECT}
		${EndIf}
	${Else}
		${If} $0 != 0
			!insertmacro SelectSection ${SECT}
		${EndIf}
	${EndIf}
!macroend


!define BITMAP_FILE riseupvpn.bmp

!define MUI_ICON "..\assets\riseupvpn.ico"
!define MUI_UNICON "..\assets\riseupvpn.ico"

!define MUI_WELCOMEPAGE_TITLE "RiseupVPN"
!define MUI_WELCOMEPAGE_TEXT "This will install RiseupVPN in your computer. RiseupVPN is a simple, fast and secure VPN Client, powered by Bitmask. \n This VPN service is run by donations from people like you."
#!define MUI_WELCOMEFINISHPAGE_BITMAP "riseup.png"

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
 
 

Section "InstallFiles"
  SetOutPath $INSTDIR 
  WriteUninstaller $INSTDIR\uninstall.exe

  ;Start Menu
  createDirectory "$SMPROGRAMS\RiseupVPN\"
  createShortCut "$SMPROGRAMS\RiseupVPN\RiseupVPN.lnk" "$INSTDIR\bitmask-systray.exe" "" "$INSTDIR\riseupvpn.ico"

  File "readme.txt"
  File "..\staging\nssm.exe"
  File "..\assets\riseupvpn.ico"

  
  File ..\staging\bitmask_helper.exe
  File ..\staging\bitmask-systray.exe
  File ..\staging\libcrypto-1_1-x64.dll
  File ..\staging\liblzo2-2.dll
  File ..\staging\libpkcs11-helper-1.dll
  File ..\staging\libssl-1_1-x64.dll
  File ..\staging\padlock.dll
  File ..\staging\openvpn\openvpn.exe
  File ..\staging\openvpn\tap-windows.exe


SectionEnd

Section "InstallService"
  ; Easy service management thanks to nssm
  ExecWait '"$INSTDIR\nssm.exe" remove riseupvpn-helper confirm'
  ExecWait '"$INSTDIR\nssm.exe" install riseupvpn-helper "$INSTDIR\bitmask_helper.exe"'
  ExecWait '"$INSTDIR\nssm.exe" set riseupvpn-helper AppDirectory "$INSTDIR"'
  ExecWait '"$INSTDIR\nssm.exe" start riseupvpn-helper'

  ; why are these here?
  Delete "C:\riseupvpn.ico"
  Delete "C:\riseupvpn.png"
SectionEnd

Section /o "TAP Virtual Ethernet Adapter" SecTAP
	; Adapted from the windows nsis installer from OpenVPN (openvpn-build repo).
	DetailPrint "Installing TAP (may need confirmation)..."
  	ExecWait '"$INSTDIR\tap-windows.exe" /SELECT_UTILITIES=1'
	;Making it explicit for now. It looks like the /S flag is "silent", isn't it?
  	;ExecWait '"$INSTDIR\tap-windows.exe" /S /SELECT_UTILITIES=1'
	Pop $R0 # return value/error/timeout
	WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RiseupVPN" "tap" "installed"
	DetailPrint "TAP installed!"
SectionEnd

Section "Uninstall"
  ExecWait '"$INSTDIR"\nssm.exe stop riseupvpn-helper'
  ExecWait '"$INSTDIR"\nssm.exe remove riseupvpn-helper confirm'

  Delete $INSTDIR\readme.txt
  Delete $INSTDIR\nssm.exe

  
  Delete $INSTDIR\riseupvpn.ico
  Delete $INSTDIR\openssl.exe
  Delete $INSTDIR\openvpn.exe
  Delete $INSTDIR\ssleay32.dll
  Delete $INSTDIR\libeay32.dll
  Delete $INSTDIR\liblzo2-2.dll
  Delete $INSTDIR\libpkcs11-helper-1.dll
  Delete $INSTDIR\bitmask_helper.exe
  Delete $INSTDIR\bitmask-systray.exe
  Delete $INSTDIR\tap-windows.exe


  ; uninstaller must be always the last thing to remove
  Delete $INSTDIR\uninstall.exe
SectionEnd

Function .onInit
	!insertmacro SelectByParameter ${SecTAP} SELECT_TAP 1
FunctionEnd

;----------------------------------------
;Languages
 
!insertmacro MUI_LANGUAGE "English"