Skip to content

Commit d05ea6a

Browse files
committed
Windows installer updated.
1 parent b8abc7b commit d05ea6a

9 files changed

+198
-32
lines changed

demo-docker/mongo_seed/files/demo_data.json

Lines changed: 14 additions & 14 deletions
Large diffs are not rendered by default.

platform-windows/create_services.bat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,24 @@ REM See log rotation options https://nssm.cc/usage#io
2828
nssm install JSON_SCADA_cs_data_processor "C:\json-scada\platform-windows\nodejs-runtime\node.exe" "C:\json-scada\src\cs_data_processor\cs_data_processor.js" 1 1 "c:\json-scada\conf\json-scada.json"
2929
nssm set JSON_SCADA_cs_data_processor AppDirectory "C:\json-scada\src\cs_data_processor"
3030
nssm set JSON_SCADA_cd_data_processor Start SERVICE_AUTO_START
31+
3132
nssm install JSON_SCADA_server_realtime "C:\json-scada\platform-windows\nodejs-runtime\node.exe" "C:\json-scada\src\server_realtime\index.js" NOAUTH
3233
nssm set JSON_SCADA_server_realtime AppDirectory "C:\json-scada\src\server_realtime"
3334
nssm set JSON_SCADA_server_realtime Start SERVICE_AUTO_START
3435

36+
37+
nssm install JSON_SCADA_demo_simul "C:\json-scada\platform-windows\nodejs-runtime\node.exe" "C:\json-scada\src\demo_simul\index.js"
38+
nssm set JSON_SCADA_demo_simul AppDirectory "C:\json-scada\src\demo_simul"
39+
nssm set JSON_SCADA_demo_simul SERVICE_DEMAND_START
40+
3541
nssm install JSON_SCADA_alarm_beep "C:\json-scada\platform-windows\nodejs-runtime\node.exe" "C:\json-scada\src\alarm_beep\alarm_beep.js"
3642
nssm set JSON_SCADA_alarm_beep AppDirectory "C:\json-scada\src\alarm_beep"
3743
nssm set JSON_SCADA_alarm_beep Start SERVICE_AUTO_START
3844

3945
nssm install JSON_SCADA_process_rtdata "C:\json-scada\sql\process_pg_rtdata.bat"
4046
nssm set JSON_SCADA_process_rtdata AppDirectory "C:\json-scada\sql"
4147
nssm set JSON_SCADA_process_rtdata Start SERVICE_AUTO_START
48+
4249
nssm install JSON_SCADA_process_hist "C:\json-scada\sql\process_pg_hist.bat"
4350
nssm set JSON_SCADA_process_hist AppDirectory "C:\json-scada\sql"
4451
nssm set JSON_SCADA_process_hist Start SERVICE_AUTO_START

platform-windows/initial_setup.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b)
44
cd \json-scada\platform-windows\
55

66
call postgresql-initdb.bat
7+
ping -n 15 127.0.0.1
78
copy /Y ..\conf-templates\pg_hba.conf postgresql-data\
89
copy /Y ..\conf-templates\postgresql.conf postgresql-data\
910
call postgresql-create_service.bat

platform-windows/json-scada.nsi

Lines changed: 141 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ RequestExecutionLevel admin
1414

1515
;--------------------------------
1616

17-
!define VERSION "v.0.1"
18-
!define VERSION_ "0.1.0.0"
17+
!define VERSION "v.0.2"
18+
!define VERSION_ "0.2.0.0"
1919

2020
Function .onInit
2121
System::Call 'keexrnel32::CreateMutexA(i 0, i 0, t "MutexJsonScadaInstall") i .r1 ?e'
@@ -113,9 +113,16 @@ SetRegView 64
113113
nsExec::Exec 'net stop JSON_SCADA_server_realtime'
114114
nsExec::Exec 'net stop JSON_SCADA_process_rtdata'
115115
nsExec::Exec 'net stop JSON_SCADA_process_hist'
116-
nsExec::Exec 'net stop JSON_SCADA_iec104'
117-
nsExec::Exec 'net stop JSON_SCADA_iec104_server'
118-
nsExec::Exec 'net stop JSON_SCADA_dnp3'
116+
nsExec::Exec 'net stop JSON_SCADA_iec101client'
117+
nsExec::Exec 'net stop JSON_SCADA_iec101server'
118+
nsExec::Exec 'net stop JSON_SCADA_iec104client'
119+
nsExec::Exec 'net stop JSON_SCADA_iec104server'
120+
nsExec::Exec 'net stop JSON_SCADA_plctags'
121+
nsExec::Exec 'net stop JSON_SCADA_dnp3client'
122+
nsExec::Exec 'net stop JSON_SCADA_process_hist'
123+
nsExec::Exec 'net stop JSON_SCADA_process_rtdata'
124+
nsExec::Exec 'net stop JSON_SCADA_process_nginx'
125+
nsExec::Exec 'net stop JSON_SCADA_process_php'
119126
nsExec::Exec 'c:\json-scada\platform-windows\stop_services.bat'
120127
nsExec::Exec '"c:\json-scada\platform-windows\postgresql-runtime\bin\pg_ctl" stop -D c:\json-scada\platform-windows\postgresql-runtime'
121128
nsExec::Exec 'c:\json-scada\platform-windows\stop_services.bat'
@@ -180,7 +187,7 @@ SetRegView 64
180187
CreateDirectory "$INSTDIR\mongo_seed"
181188
; CreateDirectory "$INSTDIR\sql"
182189
CreateDirectory "$INSTDIR\src"
183-
CreateDirectory "$INSTDIR\PowerBI"
190+
; CreateDirectory "$INSTDIR\PowerBI"
184191
; CreateDirectory "$INSTDIR\Opc.Ua.CertificateGenerator"
185192
CreateDirectory "$INSTDIR\platform-windows"
186193
CreateDirectory "$INSTDIR\platform-windows\grafana-runtime"
@@ -196,6 +203,13 @@ SetRegView 64
196203
CreateDirectory "$INSTDIR\platform-windows\postgresql-runtime"
197204
CreateDirectory "$INSTDIR\platform-windows\nginx_php-runtime"
198205

206+
; This is to try to avoid this Postgresql error:
207+
; https://edwin.baculsoft.com/2014/05/fixing-postgresql-error-initdb-could-not-change-permissions-of-directory-permission-denied/
208+
; (S-1-5-32-545)=Users (S-1-1-0)=Everyone
209+
; https://docs.microsoft.com/pt-br/troubleshoot/windows-server/identity/security-identifiers-in-windows
210+
AccessControl::GrantOnFile "$INSTDIR\platform-windows\postgresql-data" "(S-1-5-32-545)" "FullAccess"
211+
AccessControl::GrantOnFile "$INSTDIR\platform-windows\postgresql-data" "(S-1-1-0)" "FullAccess"
212+
199213
SetOutPath $INSTDIR
200214

201215
File /a ".\release_notes.txt"
@@ -207,6 +221,7 @@ SetRegView 64
207221

208222
SetOutPath $INSTDIR\platform-windows
209223
File /a "..\platform-windows\*.bat"
224+
File /a "..\platform-windows\*.ps1"
210225
File /a "..\platform-windows\nssm.exe"
211226
File /a "..\platform-windows\vc_redist.x64.exe"
212227

@@ -258,6 +273,9 @@ SetRegView 64
258273
SetOutPath $INSTDIR\src\htdocs-login
259274
File /a /r "..\src\htdocs-login\*.*"
260275

276+
SetOutPath $INSTDIR\src\demo_simul
277+
File /a /r "..\src\demo_simul\*.*"
278+
261279
SetOutPath $INSTDIR\src\alarm_beep
262280
File /a /r "..\src\alarm_beep\*.*"
263281

@@ -519,20 +537,128 @@ Section "Uninstall"
519537

520538
; Fecha processos
521539

540+
!define SC `$SYSDIR\sc.exe`
541+
542+
ExecWait `"${SC}" stop "JSON_SCADA_process_demo_simul"`
543+
Sleep 50
544+
ExecWait `"${SC}" delete "JSON_SCADA_process_demo_simul"`
545+
ClearErrors
546+
547+
ExecWait `"${SC}" stop "JSON_SCADA_process_rtdata"`
548+
Sleep 50
549+
ExecWait `"${SC}" delete "JSON_SCADA_process_rtdata"`
550+
ClearErrors
551+
552+
ExecWait `"${SC}" stop "JSON_SCADA_process_alarm_beep"`
553+
Sleep 50
554+
ExecWait `"${SC}" delete "JSON_SCADA_process_alarm_beep"`
555+
ClearErrors
556+
557+
ExecWait `"${SC}" stop "JSON_SCADA_process_php"`
558+
Sleep 50
559+
ExecWait `"${SC}" delete "JSON_SCADA_process_php"`
560+
ClearErrors
561+
562+
ExecWait `"${SC}" stop "JSON_SCADA_process_nginx"`
563+
Sleep 50
564+
ExecWait `"${SC}" delete "JSON_SCADA_process_nginx"`
565+
ClearErrors
566+
567+
ExecWait `"${SC}" stop "JSON_SCADA_i104m"`
568+
Sleep 50
569+
ExecWait `"${SC}" delete "JSON_SCADA_i104m"`
570+
ClearErrors
571+
572+
ExecWait `"${SC}" stop "JSON_SCADA_plctags"`
573+
Sleep 50
574+
ExecWait `"${SC}" delete "JSON_SCADA_plctags"`
575+
ClearErrors
576+
577+
ExecWait `"${SC}" stop "JSON_SCADA_iec101client"`
578+
Sleep 50
579+
ExecWait `"${SC}" delete "JSON_SCADA_iec101client"`
580+
ClearErrors
581+
582+
ExecWait `"${SC}" stop "JSON_SCADA_iec104client"`
583+
Sleep 50
584+
ExecWait `"${SC}" delete "JSON_SCADA_iec104client"`
585+
ClearErrors
586+
587+
ExecWait `"${SC}" stop "JSON_SCADA_dnp3client"`
588+
Sleep 50
589+
ExecWait `"${SC}" delete "JSON_SCADA_dnp3client"`
590+
ClearErrors
591+
592+
ExecWait `"${SC}" stop "JSON_SCADA_iec101server"`
593+
Sleep 50
594+
ExecWait `"${SC}" delete "JSON_SCADA_iec101server"`
595+
ClearErrors
596+
597+
ExecWait `"${SC}" stop "JSON_SCADA_iec104server"`
598+
Sleep 50
599+
ExecWait `"${SC}" delete "JSON_SCADA_iec104server"`
600+
ClearErrors
601+
602+
ExecWait `"${SC}" stop "JSON_SCADA_cs_data_processor"`
603+
Sleep 50
604+
ExecWait `"${SC}" delete "JSON_SCADA_cs_data_processor"`
605+
ClearErrors
606+
607+
ExecWait `"${SC}" stop "JSON_SCADA_calculations"`
608+
Sleep 50
609+
ExecWait `"${SC}" delete "JSON_SCADA_calculations"`
610+
ClearErrors
611+
612+
ExecWait `"${SC}" stop "JSON_SCADA_mongodb"`
613+
Sleep 50
614+
ExecWait `"${SC}" delete "JSON_SCADA_mongodb"`
615+
ClearErrors
616+
617+
ExecWait `"${SC}" stop "JSON_SCADA_postgresql"`
618+
Sleep 50
619+
ExecWait `"${SC}" delete "JSON_SCADA_postgresql"`
620+
ClearErrors
621+
622+
ExecWait `"${SC}" stop "JSON_SCADA_postgresql"`
623+
Sleep 50
624+
ExecWait `"${SC}" delete "JSON_SCADA_postgresql"`
625+
ClearErrors
626+
627+
ExecWait `"${SC}" stop "JSON_SCADA_process_hist"`
628+
Sleep 50
629+
ExecWait `"${SC}" delete "JSON_SCADA_process_hist"`
630+
ClearErrors
631+
632+
ExecWait `"${SC}" stop "JSON_SCADA_process_rtdata"`
633+
Sleep 50
634+
ExecWait `"${SC}" delete "JSON_SCADA_process_rtdata"`
635+
ClearErrors
636+
637+
ExecWait `"${SC}" stop "JSON_SCADA_postgresql"`
638+
Sleep 50
639+
ExecWait `"${SC}" delete "JSON_SCADA_postgresql"`
640+
ClearErrors
641+
522642
ExecWait '"$0" /C "$INSTDIR\platform-windows\mongodb-stop.bat"'
523643
ExecWait '"$0" /C "$INSTDIR\platform-windows\postgresql-stop.bat"'
524644
ExecWait '"$0" /C "$INSTDIR\platform-windows\stop_services.bat"'
525645
Sleep 5000
526-
ExecWait '"$0" /C "$INSTDIR\platform-windows\remove_services.bat"'
527-
Sleep 1000
528-
nsExec::Exec `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\sql\\%'" CALL TERMINATE`
529-
Sleep 1000
530-
nsExec::Exec `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\browser-runtime\\%'" CALL TERMINATE`
531-
nsExec::Exec `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\mongodb-runtime\\%'" CALL TERMINATE`
532-
nsExec::Exec `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\inkscape-runtime\\%'" CALL TERMINATE`
533-
nsExec::Exec `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\%'" CALL TERMINATE`
534-
nsExec::Exec `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\bin\\%'" CALL TERMINATE`
646+
ExecWait `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\sql\\%'" CALL TERMINATE`
535647
Sleep 1000
648+
ExecWait `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\grafana-runtime\\bin\\%'" CALL TERMINATE`
649+
ExecWait `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\nginx_php-runtime\\php\\%'" CALL TERMINATE`
650+
ExecWait `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\nginx_php-runtime\\%'" CALL TERMINATE`
651+
ExecWait `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\nodejs-runtime\\%'" CALL TERMINATE`
652+
ExecWait `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\browser-runtime\\%'" CALL TERMINATE`
653+
ExecWait `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\mongodb-runtime\\%'" CALL TERMINATE`
654+
ExecWait `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\inkscape-runtime\\%'" CALL TERMINATE`
655+
ExecWait `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\%'" CALL TERMINATE`
656+
ExecWait `wmic PROCESS WHERE "COMMANDLINE LIKE '%\\platform-windows\\%'" CALL TERMINATE`
657+
ExecWait `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\bin\\%'" CALL TERMINATE`
658+
ExecWait `wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\%'" CALL TERMINATE`
659+
Sleep 5000
660+
ExecWait '"$0" /C "$INSTDIR\platform-windows\remove_services.bat"'
661+
Sleep 5000
536662

537663
RMDir /r "$INSTDIR\bin"
538664
RMDir /r "$INSTDIR\platform-windows"
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
echo THIS WILL INITIALIZE THE POSTGRESQL DATABASE!
22

3-
c:\json-scada\platform-windows\postgresql-runtime\bin\initdb.exe -D c:\json-scada\platform-windows\postgresql-data --username=postgres --auth=trust -E UTF8 --locale=en_US.UTF-8
3+
if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b)
4+
5+
REM In some cases the data folder should be given rights to group "Everyone"=S-1-1-0
6+
icacls "C:\json-scada\platform-windows\postgresql-data" /t /grant *S-1-1-0:F
7+
8+
c:\json-scada\platform-windows\postgresql-runtime\bin\initdb.exe -D c:\json-scada\platform-windows\postgresql-data --username=postgres --auth=trust -E UTF8 --locale=en-US

platform-windows/release_notes.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ Inkscape+SAGE:
120120

121121
-------------------------------------------------------------------
122122

123+
Notes for version 0.2:
124+
125+
- Fixed PostgreSQL initdb problems, locale, timing, Windows user rights.
126+
- Added demo_simul service for offline simulation and testing (must be manually started).
127+
- Fixed uninstall services removal.
128+
129+
-------------------------------------------------------------------
130+
123131
Notes for version 0.1:
124132

125133
- First Windows binary release.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Get-service | Where-Object {$_.Name -match "^JSON_SCADA_"} | Select-Object -ExpandProperty Name | foreach { & sc.exe STOP $_ }
2+
Get-service | Where-Object {$_.Name -match "^JSON_SCADA_"} | Select-Object -ExpandProperty Name | foreach { & sc.exe DELETE $_ }

platform-windows/remove_services.bat

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ rem Stop services
88

99
call stop_services.bat
1010

11+
REM FORCE STOP OF ANY ACTIVE SERVICE OR PROCESS!
12+
wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\sql\\%'" CALL TERMINATE
13+
wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\grafana-runtime\\bin\\%'" CALL TERMINATE
14+
wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\nginx_php-runtime\\php\\%'" CALL TERMINATE
15+
wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\nginx_php-runtime\\%'" CALL TERMINATE
16+
wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\nodejs-runtime\\%'" CALL TERMINATE
17+
wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\browser-runtime\\%'" CALL TERMINATE
18+
wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\mongodb-runtime\\%'" CALL TERMINATE
19+
wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\inkscape-runtime\\%'" CALL TERMINATE
20+
wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\platform-windows\\%'" CALL TERMINATE
21+
wmic PROCESS WHERE "COMMANDLINE LIKE '%\\platform-windows\\%'" CALL TERMINATE
22+
wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\bin\\%'" CALL TERMINATE
23+
wmic PROCESS WHERE "COMMANDLINE LIKE '%c:\\json-scada\\%'" CALL TERMINATE
24+
1125
rem Remove service without confimation
1226

1327
sc delete JSON_SCADA_postgresql
@@ -19,6 +33,7 @@ nssm remove JSON_SCADA_calculations confirm
1933
nssm remove JSON_SCADA_process_rtdata confirm
2034
nssm remove JSON_SCADA_process_hist confirm
2135
nssm remove JSON_SCADA_alarm_beep confirm
36+
nssm remove JSON_SCADA_demo_simul confirm
2237

2338
nssm remove JSON_SCADA_nginx confirm
2439
nssm remove JSON_SCADA_php confirm
@@ -31,3 +46,5 @@ nssm remove JSON_SCADA_dnp3client confirm
3146
nssm remove JSON_SCADA_i104m confirm
3247
nssm remove JSON_SCADA_plctags confirm
3348

49+
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""remove_jsonscada_services.ps1""' -Verb RunAs}"
50+

sql/create_tables.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
CREATE DATABASE "json_scada"
55
WITH OWNER "postgres"
66
ENCODING 'UTF8'
7-
LC_COLLATE = 'en_US.UTF-8'
8-
LC_CTYPE = 'en_US.UTF-8'
7+
LC_COLLATE = 'en-US'
8+
LC_CTYPE = 'en-US'
99
TEMPLATE template0;
1010

1111
\c json_scada

0 commit comments

Comments
 (0)