-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.nsi
634 lines (466 loc) · 19.2 KB
/
main.nsi
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
;; Copyright (C) 2019, Junta de Andalucía <[email protected]>
;; https://www.juntadeandalucia.es/
;; Author Abraham Macias <[email protected]>
;;
;; This file is part of Guadalinex.
;;
;; This software is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;;
;; This software is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this package; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
;;
!define PRODUCT_NAME "GECOS"
!define PRODUCT_PUBLISHER "Junta de Andalucia"
!define PRODUCT_WEB_SITE "https://www.juntadeandalucia.es/"
!define PRODUCT_FULL_NAME "${PRODUCT_NAME} client"
!define PRODUCT_VERSION 2.3.0.0
!define OUT_DIR "."
!define SETUP_NAME gecos_v2.3
!define COPYRIGHT_YEAR 2019
!define BASENAME "${PRODUCT_FULL_NAME}"
!define LOG_NAME "install.log"
!define SHORTCUT "${PRODUCT_NAME}.lnk"
!define SHORTCUT_ICON "gecos.ico"
!define UNINSTALL_REGKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\gecos"
!include "FileFunc.nsh"
!include "WinMessages.nsh"
!include "MUI.nsh"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "media\header.bmp"
!define MUI_HEADERIMAGE_UNBITMAP "media\header.bmp"
!define MUI_WELCOMEFINISHPAGE_BITMAP "media\startlogo.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "media\startlogo.bmp"
!define MUI_ICON "media\wizard.ico"
!define MUI_UNICON ${MUI_ICON}
!define MUI_ABORTWARNING
!define MUI_UNABORTWARNING
;General
;Name and file
Name "${PRODUCT_FULL_NAME}"
OutFile "${OUT_DIR}\${SETUP_NAME}.exe"
BrandingText "Copyright (C) ${COPYRIGHT_YEAR} Junta de Andalucia"
;Default installation folder
InstallDir "$PROGRAMFILES\${PRODUCT_PUBLISHER}\${PRODUCT_NAME}"
;Get installation folder from registry if available
InstallDirRegKey HKLM "Software\${PRODUCT_PUBLISHER}" "${PRODUCT_NAME}"
VIAddVersionKey ProductName "${PRODUCT_NAME}"
VIAddVersionKey CompanyName "${PRODUCT_PUBLISHER}"
VIAddVersionKey ProductVersion "${PRODUCT_VERSION}"
VIAddVersionKey FileVersion "${PRODUCT_VERSION}"
VIAddVersionKey FileDescription "GECOS (Guadalinex Edición COrporativa eStandar)"
VIAddVersionKey LegalCopyright "Copyright (C) ${COPYRIGHT_YEAR} Junta de Andalucía"
VIProductVersion "${PRODUCT_VERSION}"
;--------------------------------
;Generic variables
Var Dialog
Var Label
Var Text
Var skipGecosCCLink
;--------------------------------
;Interface Settings
;--------------------------------
;Pages
; Installer parameters and pages order
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_LICENSEPAGE_RADIOBUTTONS
!define MUI_FINISHPAGE_LINK "Visit our web site"
!define MUI_FINISHPAGE_LINK_LOCATION ${PRODUCT_WEB_SITE}
!define MUI_FINISHPAGE_TEXT "${PRODUCT_FULL_NAME} has been installed on your computer.\n\nClick Finish to close this wizard.\n"
!define MUI_FINISHPAGE_TEXT_LARGE
# !define MUI_FINISHPAGE_RUN "$INSTDIR/${EXE_NAME}"
# !define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Show installation log"
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\${LOG_NAME}"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "media/LICENSE.txt"
!insertmacro MUI_PAGE_DIRECTORY
Page custom NetworkInterefacesShow NetworkInterefacesLeave
Page custom LoadGECOSCCSetupData LoadGECOSCCSetupDataLeave
Page custom LoadGECOSCCSetupDataShow
Page custom LoadWorkstationData LoadWorkstationDataLeave
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
; Uninstaller Parameters and pages order
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_FINISHPAGE_TITLE_3LINES
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
UninstPage custom un.UnlinkGECOSCC un.UnlinkGECOSCCLeave
UninstPage custom un.UnlinkGECOSCCShow
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Spanish"
!define GECOS_DEFAULT_LANGFILE "translations\Default.nsh"
!include "langmacros.nsh"
!insertmacro GECOS_MACRO_INCLUDE_LANGFILE "ENGLISH" "translations\English.nsh"
!insertmacro GECOS_MACRO_INCLUDE_LANGFILE "SPANISH" "translations\Spanish.nsh"
; Check network interfaces
!include network_interface.nsh
; Load GECOS CC setup data
!include GECOSSetupData.nsh
; Load registry macros
!include reg.nsh
; Load string macros
!include strings.nsh
; Tools files
!include toolsfiles.nsh
; X64 file system redirection
!include x64.nsh
;--------------------------------
;Reserve Files
;If you are using solid compression, files that are required before
;the actual installation should be stored first in the data block,
;because this will make your installer start faster.
!insertmacro MUI_RESERVEFILE_LANGDLL
ReserveFile "python27.dll"
ReserveFile "isurl.py"
ReserveFile "validate_gecos_credentials.py"
ReserveFile "get_autoconf_data.py"
ReserveFile "check_workstation_name.py"
ReserveFile "get_ou.py"
ReserveFile "gecoscclink_step01.py"
ReserveFile "gecoscclink_step02.py"
ReserveFile "gecoscclink_step03.py"
ReserveFile "templates\chef.control"
ReserveFile "templates\client.rb"
ReserveFile "templates\gcc.control"
ReserveFile "templates\knife.rb"
ReserveFile "gecoscculink.py"
ReserveFile "get_connection_data.py"
!include reserved.nsh
Function .onInit
; to install for all user
SetShellVarContext all
!insertmacro MUI_LANGDLL_DISPLAY
check_chef_version:
; Check if any version of opscode chef is installed
!insertmacro GetAppInstalledKey "Chef Client "
Pop $R4
${if} $R4 != ""
ReadRegStr $R2 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\$R4" "DisplayName"
StrCmp $R2 "Chef Client v12.22.5" sameversion
; There is a different version of opscode chef installed --> uninstall it!
IfSilent uninst
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
$(DIFFERENT_CHEF_VERSION_MESSAGE) \
IDOK uninst
Abort
uninst:
ReadRegStr $R3 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\$R4" "UninstallString"
${StrRep} '$R0' '$R3' '/I' '/X'
IfSilent silent_chef_uninst
ExecWait '$R0'
Goto check_chef_version
silent_chef_uninst:
ExecWait '$R0 /q'
Goto check_chef_version
sameversion:
${EndIf}
${GetParameters} $R0
ClearErrors
${GetOptions} $R0 /URL= $CmdUrl
${GetOptions} $R0 /USERNAME= $CmdUsername
${GetOptions} $R0 /PASSWORD= $CmdPassword
${GetOptions} $R0 /OU= $CmdOU
!insertmacro PrepareGECOSPythonFiles ""
; Get Windows default workstation name
ReadRegStr $WorkstationName HKLM "System\CurrentControlSet\Control\ComputerName\ActiveComputerName" "ComputerName"
FunctionEnd
Function un.onInit
; to uninstall for all user
SetShellVarContext all
!insertmacro MUI_LANGDLL_DISPLAY
!insertmacro PrepareGECOSPythonFiles "un."
FunctionEnd
Section "Main Section" SecMain
SetOutPath "$INSTDIR"
;Store installation folder
WriteRegStr HKLM "Software\${PRODUCT_PUBLISHER}" "${PRODUCT_NAME}" $INSTDIR
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "${UNINSTALL_REGKEY}" "Comments" "${PRODUCT_FULL_NAME}"
WriteRegStr HKLM "${UNINSTALL_REGKEY}" "DisplayIcon" "$INSTDIR\${SHORTCUT_ICON},0"
WriteRegStr HKLM "${UNINSTALL_REGKEY}" "DisplayName" "${PRODUCT_FULL_NAME} (${PRODUCT_VERSION})"
WriteRegStr HKLM "${UNINSTALL_REGKEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr HKLM "${UNINSTALL_REGKEY}" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "${UNINSTALL_REGKEY}" "Publisher" "${PRODUCT_PUBLISHER}"
WriteRegStr HKLM "${UNINSTALL_REGKEY}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
WriteRegStr HKLM "${UNINSTALL_REGKEY}" "URLInfoUbout" "${PRODUCT_WEB_SITE}"
WriteRegDWORD HKLM "${UNINSTALL_REGKEY}" "NoModify" "1"
WriteRegDWORD HKLM "${UNINSTALL_REGKEY}" "NoRepair" "1"
; SetOutPath "$APPDATA\${PRODUCT_PUBLISHER}\${PRODUCT_NAME}"
; SetOverwrite ifnewer
SectionEnd
Section "SecMedia" SecMedia
SetOutPath "$INSTDIR\"
SetOverwrite ifnewer
File "media\gecos.ico"
SectionEnd
Section "un.SecMedia" SecUnMedia
Delete "$INSTDIR\gecos.ico"
SectionEnd
Section "Shortcut Section" SecShortcut
SetOutPath "$INSTDIR"
CreateDirectory "$SMPROGRAMS\${PRODUCT_PUBLISHER}"
WriteIniStr "$SMPROGRAMS\${PRODUCT_PUBLISHER}\Website.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
;CreateShortCut "$SMPROGRAMS\${PRODUCT_PUBLISHER}\${SHORTCUT}" "$INSTDIR\${EXE_NAME}"
SectionEnd
Section "un.Shortcut Section" SecUnShortcut
Delete "$SMPROGRAMS\${PRODUCT_PUBLISHER}\${SHORTCUT}"
;Delete "$SMPROGRAMS\${PRODUCT_PUBLISHER}\Website.url"
;RMDir "$SMPROGRAMS\${PRODUCT_PUBLISHER}"
SectionEnd
Section "Uninstall"
; Check if opscode chef was deleted (if it was not deleted this is probably a silent uninstall)
!insertmacro IfAppInstalled "Chef Client v12.22.5"
Pop $R0
${if} $R0 != 0
nsislog::log "$INSTDIR\${LOG_NAME}" "Uninstall Opscode Chef"
ExecWait 'msiexec /q /x "$INSTDIR\chef-client-12.22.5-1-x86.msi"'
RMDir /r c:\chef
RMDir /r c:\etc
RMDir /r c:\opscode
${EndIf}
; Stop GECOS notifier
ExecWait '$INSTDIR\tools\gecos-snitch-client.exe --exit'
Sleep 1000
; Ensure GECOS notifier is stopped
ExecWait 'taskkill /f /im gecos-notifier.exe'
Sleep 1000
RMDir /r "$INSTDIR\tools"
RMDir /r "$INSTDIR"
RMDir /r "$APPDATA\${PRODUCT_PUBLISHER}\${PRODUCT_NAME}"
RMDir "$APPDATA\${PRODUCT_PUBLISHER}"
Delete "$INSTDIR\Uninstall.exe"
DeleteRegKey HKLM "${UNINSTALL_REGKEY}"
; Do no start notifier
DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "GECOS notifier"
; Do no start gecos-user-login script
DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "GECOS user login"
; Delete gecos-first-login script shortcut from Startup programs
Delete "$SMSTARTUP\ gecos-first-login.lnk"
; Remove tools from PATH
ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
${StrRep} $0 "$1" ";$INSTDIR\tools" ""
${StrRep} $1 "$0" "%SystemRoot%" "$WINDIR"
${StrRep} $0 "$1" "%SYSTEMROOT%" "$WINDIR"
WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$0"
; Remove scheduled tasks
ExecWait 'schtasks /Delete /TN chef-client-wrapper /F'
ExecWait 'schtasks /Delete /TN chef-client-wrapper-od /F'
; Delete %APPDATA%\gecos\firstart\firstart.conf
ReadEnvStr $0 APPDATA
Delete "$0\gecos\firstart\firstart.conf"
DeleteRegValue HKLM "Software\${PRODUCT_PUBLISHER}" "${PRODUCT_NAME}"
DeleteRegKey /ifempty HKLM "Software\${PRODUCT_PUBLISHER}"
SectionEnd
; Opscode Chef 12 client installation ==============================================================================
Section "ChefClient"
File "chef-client-12.22.5-1-x86.msi"
!insertmacro IfAppInstalled "Chef Client v12.22.5"
Pop $R0
${if} $R0 == 0
nsislog::log "$INSTDIR\${LOG_NAME}" "Chef not installed --> Install it!"
ExecWait 'msiexec /qn /i "$INSTDIR\chef-client-12.22.5-1-x86.msi"'
${Else}
nsislog::log "$INSTDIR\${LOG_NAME}" "Chef already installed!"
${EndIf}
SectionEnd
; Tools installation ==============================================================================
Section "ToolsInstalation"
!insertmacro PrepareToolsFiles
; Add registry entry to start the notifier
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "GECOS notifier" "$INSTDIR\tools\gecos-notifier.exe"
; Add registry entry to start the gecos-user-login script
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "GECOS user login" "$INSTDIR\tools\gecos-user-login.exe"
; Add gecos-first-login script shortcut to Startup programs
CreateShortCut "$SMSTARTUP\gecos-first-login.lnk" "$INSTDIR\tools\gecos-first-login.exe"
; Add tools directory to PATH
ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
; Add chef-client-wrapper as a scheduled task
; https://technet.microsoft.com/en-us/library/cc748993(v=ws.11).aspx
ExecWait 'schtasks /Create /TN chef-client-wrapper /TR "\"$INSTDIR\tools\gecos-chef-client-wrapper.exe\"" /sc DAILY /st 07:00 /f /RI 30 /du 24:00 /RL HIGHEST /ru SYSTEM'
; Create the event 777 to execute the chef-client-wrapper on demand
ExecWait 'schtasks /Delete /TN chef-client-wrapper-od /F'
ExecWait 'eventcreate /ID 777 /L APPLICATION /T INFORMATION /SO GecosNotifier /D Initiate'
; Add chef-client-wrapper on demand to be executed on 777 event
ExecWait 'schtasks /Create /TN chef-client-wrapper-od /TR "\"$INSTDIR\tools\gecos-chef-client-wrapper.exe\"" /RL HIGHEST /ru SYSTEM /SC ONEVENT /EC Application /MO *[System/EventID=777]'
; Set permissions to the task folder
${If} ${RunningX64}
${DisableX64FSRedirection}
${EndIf}
AccessControl::GrantOnFile "$WINDIR\System32\Tasks" "(BU)" "GenericRead"
Pop $0 ; get "ok" or "error"
StrCmp $0 "ok" dirPermissionOk
Pop $0 ; get error message
nsislog::log "$INSTDIR\${LOG_NAME}" "Error setting permissions to $WINDIR\System32\Tasks: $0"
dirPermissionOk:
; Set permissions to the task
AccessControl::GrantOnFile "$WINDIR\System32\Tasks\chef-client-wrapper" "(BU)" "GenericRead + GenericExecute"
Pop $0 ; get "ok" or error msg
StrCmp $0 "ok" permissionOk
Pop $0 ; get error message
nsislog::log "$INSTDIR\${LOG_NAME}" "Error setting permissions to $WINDIR\System32\Tasks\chef-client-wrapper: $0"
permissionOk:
${If} ${RunningX64}
${EnableX64FSRedirection}
${EndIf}
; Delete %APPDATA%\gecos\firstart\firstart.conf
ReadEnvStr $0 APPDATA
Delete "$0\gecos\firstart\firstart.conf"
Push $1
Push "$INSTDIR"
Call StrContains
Pop $0
StrCmp $0 "" notfound
nsislog::log "$INSTDIR\${LOG_NAME}" "Tools already added in PATH!"
Goto done
notfound:
nsislog::log "$INSTDIR\${LOG_NAME}" "Add tools to PATH!"
${StrRep} $0 "$1" "%SystemRoot%" "$WINDIR"
${StrRep} $1 "$0" "%SYSTEMROOT%" "$WINDIR"
WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$1;$INSTDIR\tools"
done:
SetRebootFlag true
SectionEnd
; Connect with GECOS CC (step 1) =============================================================================================
Section "CreateSetupFiles" CreateSetupFiles_ID
; Skip this step if C:\chef\client.pem exist
IfFileExists C:\chef\client.pem CreateSetupFiles_end
SectionSetText ${CreateSetupFiles_ID} "Creating setup files..."
SetOutPath "$INSTDIR"
nsislog::log "$INSTDIR\${LOG_NAME}" " "
nsislog::log "$INSTDIR\${LOG_NAME}" "Software installed. Now connect with GECOS CC... "
DetailPrint "Software installed. Now connect with GECOS CC... "
${If} $NodeName == ""
GetFunctionAddress $1 EnabledAdaptersCallback
IpConfig::GetEnabledNetworkAdaptersIDsCB $1
${EndIf}
${If} $GecosCC_URL == ""
StrCpy $GecosCC_URL $CmdUrl
${EndIf}
${If} $GecosCC_User == ""
StrCpy $GecosCC_User $CmdUsername
${EndIf}
${If} $GecosCC_Pass == ""
StrCpy $GecosCC_Pass $CmdPassword
; Validate credentials trying to connect to GECOS CC
StrCpy $0 $GecosCC_URL
StrCpy $1 $GecosCC_User
StrCpy $2 $GecosCC_Pass
nsPython::execFile "$PLUGINSDIR\validate_gecos_credentials.py"
${EndIf}
${If} $SelectedOU == ""
StrCpy $SelectedOU $CmdOU
${EndIf}
; Create setup files
StrCpy $0 $GecosCC_URL
StrCpy $1 $GecosCC_User
StrCpy $2 $GecosCC_Pass
StrCpy $3 $SelectedOU
StrCpy $4 $WorkstationName
StrCpy $5 $NodeName
nsislog::log "$INSTDIR\${LOG_NAME}" "GECOS CC connection data: "
nsislog::log "$INSTDIR\${LOG_NAME}" " URL: $GecosCC_URL"
nsislog::log "$INSTDIR\${LOG_NAME}" " User: $GecosCC_User"
nsislog::log "$INSTDIR\${LOG_NAME}" " Workstation name: $WorkstationName"
nsislog::log "$INSTDIR\${LOG_NAME}" " Node Name: $NodeName"
nsPython::execFile "$PLUGINSDIR\gecoscclink_step01.py"
Pop $7
${If} $7 == "error"
nsislog::log "$INSTDIR\${LOG_NAME}" "ConnectWithGECOSCC: ERROR creating setup files! $4 ($5)"
DetailPrint "ERROR creating setup files! $4 ($5)"
Abort
${EndIf}
${If} $6 == "false"
DetailPrint "ERROR creating setup files!"
Abort
${EndIf}
CreateSetupFiles_end:
SectionEnd
; Connect with GECOS CC (step 2) =============================================================================================
Section "LinkToChef" LinkToChef_ID
; Skip this step if C:\chef\client.pem exist
IfFileExists C:\chef\client.pem LinkToChef_skip
SectionSetText ${LinkToChef_ID} "Preparing to link to Chef server..."
SetOutPath "$INSTDIR"
CreateDirectory "$INSTDIR\data"
File "/oname=$INSTDIR\data\base.json" "data\base.json"
CreateDirectory "$INSTDIR\data\report-handlers"
File "/oname=$INSTDIR\data\report-handlers\gecoshandlers.rb" "data\report-handlers\gecoshandlers.rb"
File "/oname=$INSTDIR\LICENSE.txt" "LICENSE.txt"
nsislog::log "$INSTDIR\${LOG_NAME}" " "
nsislog::log "$INSTDIR\${LOG_NAME}" "Linking to Chef server... "
DetailPrint "Linking to Chef server... "
; Link to Chef
StrCpy $0 $GecosCC_URL
StrCpy $1 $GecosCC_User
StrCpy $2 $GecosCC_Pass
StrCpy $3 $SelectedOU
StrCpy $4 $WorkstationName
StrCpy $5 $NodeName
nsPython::execFile "$PLUGINSDIR\gecoscclink_step02.py"
Pop $7
${If} $7 == "error"
nsislog::log "$INSTDIR\${LOG_NAME}" "ConnectWithGECOSCC: ERROR linking to Chef server! $4 ($5)"
DetailPrint "ERROR linking to Chef server! $4 ($5)"
Abort
${EndIf}
${If} $6 == "false"
DetailPrint "ERROR linking to Chef server!"
Abort
${EndIf}
StrCpy $skipGecosCCLink "false"
Goto LinkToChef_end
LinkToChef_skip:
nsislog::log "$INSTDIR\${LOG_NAME}" "Skip Chef server link!"
StrCpy $skipGecosCCLink "true"
LinkToChef_end:
SectionEnd
; Connect with GECOS CC (step 3) =============================================================================================
Section "LinkToCC" LinkToCC_ID
; Skip this step if necessary
${If} $skipGecosCCLink == "true"
Goto LinkToCC_skip
${EndIf}
SectionSetText ${LinkToCC_ID} "Linking to GECOS CC server..."
SetOutPath "$INSTDIR"
nsislog::log "$INSTDIR\${LOG_NAME}" " "
nsislog::log "$INSTDIR\${LOG_NAME}" "Linking to GECOS CC server... "
DetailPrint "Linking to GECOS CC server... "
; Link to GECOS CC
StrCpy $0 $GecosCC_URL
StrCpy $1 $GecosCC_User
StrCpy $2 $GecosCC_Pass
StrCpy $3 $SelectedOU
StrCpy $4 $WorkstationName
StrCpy $5 $NodeName
nsPython::execFile "$PLUGINSDIR\gecoscclink_step03.py"
Pop $7
${If} $7 == "error"
nsislog::log "$INSTDIR\${LOG_NAME}" "ConnectWithGECOSCC: ERROR linking to GECOS CC server! $4 ($5)"
DetailPrint "ERROR linking to GECOS CC server! $4 ($5)"
Abort
${EndIf}
${If} $6 == "false"
DetailPrint "ERROR linking to GECOS CC server!"
Abort
${EndIf}
nsislog::log "$INSTDIR\${LOG_NAME}" " "
nsislog::log "$INSTDIR\${LOG_NAME}" "Successfuly linked to GECOS CC server!"
Goto LinkToCC_end
LinkToCC_skip:
nsislog::log "$INSTDIR\${LOG_NAME}" "Skip GECOS CC server link!"
LinkToCC_end:
SectionEnd