1 | # We need http://nsis.sourceforge.net/NSIS_Simple_Firewall_Plugin
|
---|
2 | # Copy inside the two x86_xxxxx folders inside nsis plugins folder
|
---|
3 | Name "OpenGnsys Agent"
|
---|
4 |
|
---|
5 | # OpenGnsys Agent version
|
---|
6 | !define /file OGA_VERSION "src\VERSION"
|
---|
7 | !define /file OGA_WINVERSION "windows\VERSION"
|
---|
8 |
|
---|
9 | # General Symbol Definitions
|
---|
10 | !define REGKEY "SOFTWARE\OGAgent"
|
---|
11 | !if ${OGA_VERSION} == ${OGA_WINVERSION}
|
---|
12 | !define VERSION ${OGA_WINVERSION}.0
|
---|
13 | !else
|
---|
14 | !define VERSION ${OGA_WINVERSION}.1
|
---|
15 | !endif
|
---|
16 | !define COMPANY "OpenGnsys Project"
|
---|
17 | !define URL https://opengnsys.es
|
---|
18 | !define CONFIGFILE "cfg\ogagent.cfg"
|
---|
19 |
|
---|
20 | # MultiUser Symbol Definitions
|
---|
21 | !define MULTIUSER_EXECUTIONLEVEL Admin
|
---|
22 | !define MULTIUSER_INSTALLMODE_COMMANDLINE
|
---|
23 | !define MULTIUSER_INSTALLMODE_INSTDIR OGAgent
|
---|
24 | !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "${REGKEY}"
|
---|
25 | !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUE "Path"
|
---|
26 |
|
---|
27 | # MUI Symbol Definitions
|
---|
28 | !define MUI_ICON "src\img\oga.ico"
|
---|
29 | !define MUI_FINISHPAGE_NOAUTOCLOSE
|
---|
30 | !define MUI_UNICON "src\img\oga.ico"
|
---|
31 | !define MUI_UNFINISHPAGE_NOAUTOCLOSE
|
---|
32 | !define MUI_LANGDLL_REGISTRY_ROOT HKLM
|
---|
33 | !define MUI_LANGDLL_REGISTRY_KEY ${REGKEY}
|
---|
34 | !define MUI_LANGDLL_REGISTRY_VALUENAME InstallerLanguage
|
---|
35 |
|
---|
36 | # Included files
|
---|
37 | !include MultiUser.nsh
|
---|
38 | !include Sections.nsh
|
---|
39 | !include MUI2.nsh
|
---|
40 | !include nsDialogs.nsh
|
---|
41 | !include LogicLib.nsh
|
---|
42 | !include Filefunc.nsh
|
---|
43 |
|
---|
44 | # Reserved Files
|
---|
45 | !insertmacro MUI_RESERVEFILE_LANGDLL
|
---|
46 |
|
---|
47 | # Variables
|
---|
48 | Var StartMenuGroup
|
---|
49 | Var SERVERIP
|
---|
50 | Var SERVERIP_VALUE
|
---|
51 |
|
---|
52 | # Installer pages
|
---|
53 | !insertmacro MUI_PAGE_WELCOME
|
---|
54 | !insertmacro MUI_PAGE_LICENSE src\license.txt
|
---|
55 | Page custom "ParamsPage" "ParamsPageLeave"
|
---|
56 | !insertmacro MUI_PAGE_DIRECTORY
|
---|
57 | !insertmacro MUI_PAGE_INSTFILES
|
---|
58 | !insertmacro MUI_PAGE_FINISH
|
---|
59 | !insertmacro MUI_UNPAGE_CONFIRM
|
---|
60 | !insertmacro MUI_UNPAGE_INSTFILES
|
---|
61 |
|
---|
62 | # Installer languages
|
---|
63 | !insertmacro MUI_LANGUAGE English
|
---|
64 | !insertmacro MUI_LANGUAGE Spanish
|
---|
65 | !insertmacro MUI_LANGUAGE French
|
---|
66 | !insertmacro MUI_LANGUAGE German
|
---|
67 |
|
---|
68 | # Installer attributes
|
---|
69 | BrandingText "OpenGnsys"
|
---|
70 | OutFile OGAgentSetup-${OGA_VERSION}.exe
|
---|
71 | InstallDir OGAgent
|
---|
72 | CRCCheck on
|
---|
73 | XPStyle on
|
---|
74 | ShowInstDetails hide
|
---|
75 | VIProductVersion "${VERSION}.0.0"
|
---|
76 | VIAddVersionKey /LANG=${LANG_ENGLISH} ProductName "OGAgent"
|
---|
77 | VIAddVersionKey /LANG=${LANG_ENGLISH} ProductVersion "${VERSION}"
|
---|
78 | VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyName "${COMPANY}"
|
---|
79 | VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyWebsite "${URL}"
|
---|
80 | VIAddVersionKey /LANG=${LANG_ENGLISH} FileVersion "${VERSION}"
|
---|
81 | VIAddVersionKey /LANG=${LANG_ENGLISH} FileDescription "OpenGnsys Agent installer"
|
---|
82 | VIAddVersionKey /LANG=${LANG_ENGLISH} LegalCopyright "(c) 2015 Virtual Cable S.L.U."
|
---|
83 | InstallDirRegKey HKLM "${REGKEY}" Path
|
---|
84 | ShowUninstDetails show
|
---|
85 |
|
---|
86 | # Installer sections
|
---|
87 | Section -Main SEC0000
|
---|
88 | SetShellVarContext all
|
---|
89 | SetOutPath $INSTDIR
|
---|
90 | SetOverwrite on
|
---|
91 | File /r src\dist\OGAgent\*.*
|
---|
92 | File windows\VC_redist.x64.exe
|
---|
93 | File src\VERSION
|
---|
94 | WriteRegStr HKLM "${REGKEY}\Components" Main 1
|
---|
95 | SectionEnd
|
---|
96 |
|
---|
97 | Section -post SEC0001
|
---|
98 | WriteIniStr $INSTDIR\${CONFIGFILE} "opengnsys" "remote" "https://$SERVERIP_VALUE/opengnsys/rest"
|
---|
99 | SetShellVarContext current
|
---|
100 | WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
|
---|
101 | SetOutPath $INSTDIR
|
---|
102 | WriteUninstaller $INSTDIR\OGAgentUninstaller.exe
|
---|
103 | SetOutPath $SMPROGRAMS\$StartMenuGroup
|
---|
104 | CreateShortcut "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk" $INSTDIR\OGAgentUninstaller.exe
|
---|
105 | WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
|
---|
106 | WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
|
---|
107 | WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
|
---|
108 | WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
|
---|
109 | WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\OGAgentUninstaller.exe
|
---|
110 | WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\OGAgentUninstaller.exe
|
---|
111 | WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" OGAgentTool $INSTDIR\OGAgentUser.exe
|
---|
112 | WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
|
---|
113 | WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
|
---|
114 | ExecWait '"$INSTDIR\VC_redist.x64.exe" /passive /norestart'
|
---|
115 | # Add the application to the firewall exception list - All Networks - All IP Version - Enabled
|
---|
116 | # SimpleFC::AddApplication "OpenGnsys Agent Service" "$INSTDIR\OGAgentService.exe" 0 2 "" 1
|
---|
117 | # SimpleFC::AdvAddRule [name] [description] [protocol] [direction]
|
---|
118 | # [status] [profile] [action] [application] [service_name] [icmp_types_and_codes]
|
---|
119 | # [group] [local_ports] [remote_ports] [local_address] [remote_address]
|
---|
120 | #
|
---|
121 | SimpleFC::AdvAddRule "OpenGnsys Agent Firewall rules" "Firewall rules for OpenGnsys Agent interaction with broker." "6" "1" \
|
---|
122 | "1" "7" "1" "$INSTDIR\OGAgentService.exe" "" "" \
|
---|
123 | "" "" "" "" ""
|
---|
124 | Pop $0 ; return error(1)/success(0)
|
---|
125 | # Disable fast boot on Windows 10, if registry key exists.
|
---|
126 | ReadRegDWORD $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Power" HiberbootEnabled
|
---|
127 | IfErrors 0 +2
|
---|
128 | WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Power" HiberbootEnabled 0
|
---|
129 | # Install service
|
---|
130 | nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe --startup auto install" # Add service after installation
|
---|
131 | Exec "net start ogagent"
|
---|
132 | Exec "$INSTDIR\OGAgentUser.exe"
|
---|
133 | SectionEnd
|
---|
134 |
|
---|
135 | # Macro for selecting uninstaller sections
|
---|
136 | !macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
|
---|
137 | Push $R0
|
---|
138 | ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
|
---|
139 | StrCmp $R0 1 0 next${UNSECTION_ID}
|
---|
140 | !insertmacro SelectSection "${UNSECTION_ID}"
|
---|
141 | GoTo done${UNSECTION_ID}
|
---|
142 | next${UNSECTION_ID}:
|
---|
143 | !insertmacro UnselectSection "${UNSECTION_ID}"
|
---|
144 | done${UNSECTION_ID}:
|
---|
145 | Pop $R0
|
---|
146 | !macroend
|
---|
147 |
|
---|
148 | # Uninstaller sections
|
---|
149 | Section /o -un.Main UNSEC0000
|
---|
150 | nsExec::Exec "taskkill /F /IM OGAgentUser.exe /T"
|
---|
151 | nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe stop" # Stops the service prior uninstall
|
---|
152 | nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe remove" # Removes the service prior uninstall
|
---|
153 | nsExec::Exec "taskkill /F /IM OGAgentService.exe /T"
|
---|
154 | Delete /REBOOTOK "$INSTDIR\*.*"
|
---|
155 | DeleteRegValue HKLM "${REGKEY}\Components" Main
|
---|
156 | DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" OGAgentTool
|
---|
157 | SectionEnd
|
---|
158 |
|
---|
159 | Section -un.post UNSEC0001
|
---|
160 | # Remove application from the firewall exception list
|
---|
161 | # SimpleFC::RemoveApplication "$INSTDIR\OGAgentService.exe"
|
---|
162 | SimpleFC::AdvRemoveRule "OpenGnsys Agent Firewall rules"
|
---|
163 | Pop $0 ; return error(1)/success(0)
|
---|
164 |
|
---|
165 | SetShellVarContext current
|
---|
166 | StrCpy $StartMenuGroup "OpenGnsys Agent"
|
---|
167 | DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
|
---|
168 | Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk"
|
---|
169 | Delete /REBOOTOK $INSTDIR\OGAgentUninstaller.exe
|
---|
170 | DeleteRegValue HKLM "${REGKEY}" Path
|
---|
171 | DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components"
|
---|
172 | DeleteRegKey /IfEmpty HKLM "${REGKEY}"
|
---|
173 | RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
|
---|
174 | SetShellVarContext all
|
---|
175 | RmDir /r /REBOOTOK $INSTDIR
|
---|
176 | SectionEnd
|
---|
177 |
|
---|
178 | # Installer functions
|
---|
179 | Function .onInit
|
---|
180 | InitPluginsDir
|
---|
181 | Call GetParameters
|
---|
182 | StrCpy $StartMenuGroup "OpenGnsys Agent"
|
---|
183 |
|
---|
184 | !insertmacro MUI_LANGDLL_DISPLAY
|
---|
185 | !insertmacro MULTIUSER_INIT
|
---|
186 | FunctionEnd
|
---|
187 |
|
---|
188 | # Uninstaller functions
|
---|
189 | Function un.onInit
|
---|
190 | StrCpy $StartMenuGroup "OpenGnsys Agent"
|
---|
191 | !insertmacro MUI_UNGETLANGUAGE
|
---|
192 | !insertmacro MULTIUSER_UNINIT
|
---|
193 | !insertmacro SELECT_UNSECTION Main ${UNSEC0000}
|
---|
194 | FunctionEnd
|
---|
195 |
|
---|
196 | # Parameters dialog box
|
---|
197 | Function ParamsPage
|
---|
198 | !insertmacro MUI_HEADER_TEXT "$(PARAMS_TITLE)" ""
|
---|
199 | nsDialogs::Create /NOUNLOAD 1018
|
---|
200 | Pop $0
|
---|
201 | ${If} $0 == error
|
---|
202 | Abort
|
---|
203 | ${EndIf}
|
---|
204 | ${NSD_CreateLabel} 0 0 100% 12u "$(SERVER_LABEL):"
|
---|
205 | Pop $0
|
---|
206 | ${NSD_CreateText} 10% 20u 80% 12u "$SERVERIP_VALUE"
|
---|
207 | Pop $SERVERIP
|
---|
208 | nsDialogs::Show
|
---|
209 | FunctionEnd
|
---|
210 |
|
---|
211 | # Get parameters from the dialog
|
---|
212 | Function ParamsPageLeave
|
---|
213 | ${NSD_GetText} $SERVERIP $SERVERIP_VALUE
|
---|
214 | FunctionEnd
|
---|
215 |
|
---|
216 | # Assign input parameters or default values to variables
|
---|
217 | Function GetParameters
|
---|
218 | ${GetOptions} $CMDLINE "/server" $SERVERIP_VALUE
|
---|
219 | ${If} $SERVERIP_VALUE == ""
|
---|
220 | StrCpy $SERVERIP_VALUE "192.168.2.10"
|
---|
221 | ${EndIf}
|
---|
222 | FunctionEnd
|
---|
223 |
|
---|
224 | # Installer Language Strings
|
---|
225 | LangString PARAMS_TITLE ${LANG_ENGLISH} "Setup parameters"
|
---|
226 | LangString PARAMS_TITLE ${LANG_SPANISH} "Parametros de configuracion"
|
---|
227 | LangString PARAMS_TITLE ${LANG_FRENCH} "Parametres de configuration"
|
---|
228 | LangString PARAMS_TITLE ${LANG_GERMAN} "Setup-Parameter"
|
---|
229 | LangString SERVER_LABEL ${LANG_ENGLISH} "OpenGnsys Server IP Address"
|
---|
230 | LangString SERVER_LABEL ${LANG_SPANISH} "Direccion IP del Servidor OpenGnsys"
|
---|
231 | LangString SERVER_LABEL ${LANG_FRENCH} "Adresse IP du Serveur OpenGnsys"
|
---|
232 | LangString SERVER_LABEL ${LANG_GERMAN} "OpenGnsys-Server-IP-Adresse"
|
---|
233 | LangString ^UninstallLink ${LANG_ENGLISH} "Uninstall $(^Name)"
|
---|
234 | LangString ^UninstallLink ${LANG_SPANISH} "Desinstalar $(^Name)"
|
---|
235 | LangString ^UninstallLink ${LANG_FRENCH} "D�sinstaller $(^Name)"
|
---|
236 | LangString ^UninstallLink ${LANG_GERMAN} "deinstallieren $(^Name)"
|
---|