31
31
!searchreplace SUFFIX ' ${VERSION_SUFFIX}' " -" " ."
32
32
OutFile " pkg/graylog_sidecar_installer_${VERSION}-${REVISION}${SUFFIX}.exe"
33
33
RequestExecutionLevel admin ; Require admin rights
34
- ShowInstDetails " nevershow "
35
- ShowUninstDetails " nevershow "
34
+ ShowInstDetails " show "
35
+ ShowUninstDetails " show "
36
36
37
37
; Variables
38
38
Var Params
50
50
Var TlsSkipVerify
51
51
Var ParamSendStatus
52
52
Var ParamApiToken
53
+ Var ParamNodeId
54
+ Var NodeId
53
55
Var SendStatus
54
56
Var Dialog
55
57
Var Label
56
58
Var GraylogDir
59
+ Var IsUpgrade
60
+ Var LogFile
61
+ Var LogMsgText
57
62
58
63
59
64
; --------------------------------
60
65
; Modern UI Configuration
61
66
62
67
!define MUI_ICON " graylog.ico"
68
+ !define MUI_WELCOMEPAGE_TITLE " Graylog Sidecar ${VERSION}-${REVISION}${SUFFIX} Installation / Upgrade"
69
+ !define MUI_WELCOMEPAGE_TEXT " This setup is gonna guide you through the installation / upgrade of the Graylog Sidecar.\r\n\r\n \
70
+ If an already configured Sidecar is detected ('sidecar.yml' present), it will perform an upgrade.\r\n \r\n\
71
+ Click Next to continue."
72
+
63
73
!insertmacro MUI_PAGE_WELCOME
64
74
!insertmacro MUI_PAGE_LICENSE " ../LICENSE"
65
75
!insertmacro MUI_UNPAGE_WELCOME
82
92
!insertmacro MUI_LANGUAGE " English"
83
93
!insertmacro WordFind
84
94
!insertmacro WordFind2X
95
+ !insertmacro GetTime
96
+
97
+ !macro _LogWrite text
98
+ StrCpy $LogMsgText " ${text}"
99
+ ${GetTime} " " " L" $0 $1 $2 $3 $4 $5 $6
100
+ FileWrite $LogFile ' $2$1$0$4$5$6: $LogMsgText$\r$\n '
101
+ System::Call ' kernel32::GetStdHandle(i -11)i.r9'
102
+ System::Call ' kernel32::AttachConsole(i -1)'
103
+ FileWrite $9 " $LogMsgText$\r$\n "
104
+ !macroend
105
+ !define LogWrite " !insertmacro _LogWrite"
106
+
85
107
86
108
!macro Check_X64
87
109
${If} ${RunningX64}
92
114
Strcpy $GraylogDir " $PROGRAMFILES32\Graylog"
93
115
${EndIf}
94
116
Strcpy $INSTDIR " $GraylogDir\sidecar"
117
+ CreateDirectory $INSTDIR
95
118
!macroend
96
119
120
+ !macro Check_Upgrade
121
+ ${If} ${FileExists} " $INSTDIR\sidecar.yml"
122
+ Strcpy $IsUpgrade " true"
123
+ ${LogWrite} " Existing installation detected. Performing upgrade."
124
+ ${Else}
125
+ Strcpy $IsUpgrade " false"
126
+ ${LogWrite} " No previous installation detected. Running installation mode."
127
+ ${EndIf}
128
+ !macroend
129
+
130
+
97
131
; --------------------------------
98
132
; Data
99
133
@@ -109,14 +143,6 @@ Section "Install"
109
143
CreateDirectory " $INSTDIR\module"
110
144
SetOutPath " $INSTDIR"
111
145
112
- ${If} ${RunningX64}
113
- File " collectors/winlogbeat/windows/x86_64/winlogbeat.exe"
114
- File " collectors/filebeat/windows/x86_64/filebeat.exe"
115
- ${Else}
116
- File " collectors/winlogbeat/windows/x86/winlogbeat.exe"
117
- File " collectors/filebeat/windows/x86/filebeat.exe"
118
- ${EndIf}
119
-
120
146
SetOverwrite off
121
147
File /oname= sidecar.yml " ../sidecar-windows-example.yml"
122
148
SetOverwrite on
@@ -128,7 +154,10 @@ Section "Install"
128
154
!insertmacro _IfKeyExists HKLM " SYSTEM\CurrentControlSet\Services" " graylog-sidecar"
129
155
Pop $R0
130
156
${If} $R0 = 1
131
- ExecWait ' "$INSTDIR\graylog-sidecar.exe" -service stop'
157
+ nsExec::ExecToStack ' "$INSTDIR\graylog-sidecar.exe" -service stop'
158
+ Pop $0
159
+ Pop $1
160
+ ${LogWrite} " Stopping existing Sidecar Service: [exit $0] Stdout: $1"
132
161
${EndIf}
133
162
134
163
${If} ${RunningX64}
@@ -137,9 +166,21 @@ Section "Install"
137
166
File /oname= graylog-sidecar.exe " ../build/${VERSION}/windows/386/graylog-sidecar.exe"
138
167
${EndIf}
139
168
169
+ ; Install beats collectors
170
+ ${If} ${RunningX64}
171
+ File " collectors/winlogbeat/windows/x86_64/winlogbeat.exe"
172
+ File " collectors/filebeat/windows/x86_64/filebeat.exe"
173
+ ${Else}
174
+ File " collectors/winlogbeat/windows/x86/winlogbeat.exe"
175
+ File " collectors/filebeat/windows/x86/filebeat.exe"
176
+ ${EndIf}
177
+
140
178
; When we stop the Sidecar service we also turn it on again
141
179
${If} $R0 = 1
142
- ExecWait ' "$INSTDIR\graylog-sidecar.exe" -service start'
180
+ nsExec::ExecToStack ' "$INSTDIR\graylog-sidecar.exe" -service start'
181
+ Pop $0
182
+ Pop $1
183
+ ${LogWrite} " Restarting existing Sidecar Service: [exit $0] Stdout: $1"
143
184
${EndIf}
144
185
145
186
WriteUninstaller " $INSTDIR\uninstall.exe"
@@ -185,6 +226,7 @@ Section "Post"
185
226
${GetOptions} $Params " -TLS_SKIP_VERIFY=" $ParamTlsSkipVerify
186
227
${GetOptions} $Params " -SEND_STATUS=" $ParamSendStatus
187
228
${GetOptions} $Params " -APITOKEN=" $ParamApiToken
229
+ ${GetOptions} $Params " -NODEID=" $ParamNodeId
188
230
189
231
${If} $ParamServerUrl != " "
190
232
StrCpy $ServerUrl $ParamServerUrl
@@ -204,6 +246,9 @@ Section "Post"
204
246
${If} $ParamApiToken != " "
205
247
StrCpy $ApiToken $ParamApiToken
206
248
${EndIf}
249
+ ${If} $ParamNodeId != " "
250
+ StrCpy $NodeId $ParamNodeId
251
+ ${EndIf}
207
252
208
253
; set defaults
209
254
${If} $ServerUrl == " "
@@ -218,14 +263,34 @@ Section "Post"
218
263
${If} $SendStatus == " "
219
264
StrCpy $SendStatus " true"
220
265
${EndIf}
266
+ ${If} $NodeId == " "
267
+ ; sidecar.yml needs double escapes
268
+ ${WordReplace} " file:$INSTDIR\node-id" " \" " \\" " +" $NodeId
269
+ ${EndIf}
221
270
222
271
!insertmacro _ReplaceInFile " $INSTDIR\sidecar.yml" " <SERVERURL>" $ServerUrl
223
272
!insertmacro _ReplaceInFile " $INSTDIR\sidecar.yml" " <NODENAME>" $NodeName
224
273
!insertmacro _ReplaceInFile " $INSTDIR\sidecar.yml" " <UPDATEINTERVAL>" $UpdateInterval
225
274
!insertmacro _ReplaceInFile " $INSTDIR\sidecar.yml" " <TLSSKIPVERIFY>" $TlsSkipVerify
226
275
!insertmacro _ReplaceInFile " $INSTDIR\sidecar.yml" " <SENDSTATUS>" $SendStatus
227
276
!insertmacro _ReplaceInFile " $INSTDIR\sidecar.yml" " <APITOKEN>" $ApiToken
277
+ !insertmacro _ReplaceInFile " $INSTDIR\sidecar.yml" " <NODEID>" $NodeId
278
+
279
+ ; Install sidecar service
280
+ ${If} $IsUpgrade == ' false'
281
+ nsExec::ExecToStack ' "$INSTDIR\graylog-sidecar.exe" -service install'
282
+ Pop $0
283
+ Pop $1
284
+ ${LogWrite} " Installing new Sidecar Service: [exit $0] Stdout: $1"
285
+
286
+ nsExec::ExecToStack ' "$INSTDIR\graylog-sidecar.exe" -service start'
287
+ Pop $0
288
+ Pop $1
289
+ ${LogWrite} " Starting new Sidecar Service: [exit $0] Stdout: $1"
290
+ ${EndIf}
228
291
292
+ ${LogWrite} " Installer/Upgrader finished."
293
+ FileClose $LogFile
229
294
SectionEnd
230
295
231
296
; --------------------------------
@@ -254,13 +319,20 @@ SectionEnd
254
319
; Functions
255
320
256
321
Function .onInit
322
+ !insertmacro Check_X64
323
+
324
+ FileOpen $LogFile " $INSTDIR\installerlog.txt" w
325
+
326
+ ${LogWrite} " $\r$\n " ; Powershell seems to swallow the first line
327
+ ${LogWrite} " Starting Sidecar ${VERSION}-${REVISION}${SUFFIX} installer/upgrader."
328
+
257
329
; check admin rights
258
330
Call CheckAdmin
259
331
260
332
; check concurrent un/installations
261
333
Call CheckConcurrent
262
334
263
- !insertmacro Check_X64
335
+ !insertmacro Check_Upgrade
264
336
FunctionEnd
265
337
266
338
Function un.oninit
@@ -276,6 +348,10 @@ FunctionEnd
276
348
277
349
278
350
Function nsDialogsPage
351
+ ${If} $IsUpgrade == ' true'
352
+ Abort
353
+ ${EndIf}
354
+
279
355
nsDialogs::Create 1018
280
356
281
357
0 commit comments