3
3
; used plugins: AccessControl, UserMgr,
4
4
; and AddToPath plugin was created by Victor Spirin for this project
5
5
6
+ !addplugindir Plugins
6
7
!include " postgres.def.nsh"
7
8
8
9
; --------------------------------
@@ -189,7 +190,7 @@ Section $(PostgreSQLString) sec1
189
190
; unregister
190
191
DetailPrint " Unregister the service ..."
191
192
${if} $ServiceID_text != " "
192
- nsExec::Exec ' "$INSTDIR\bin\pg_ctl.exe" unregister -N "$ServiceID_text"'
193
+ nsExec::Exec ' "$INSTDIR\bin\pg_ctl.exe" unregister -N "$ServiceID_text"'
193
194
pop $0
194
195
DetailPrint " pg_ctl.exe unregister return $0"
195
196
${endif}
@@ -237,7 +238,9 @@ Section $(PostgreSQLString) sec1
237
238
ClearErrors
238
239
FileOpen $0 $INSTDIR \scripts\runpgsql.bat w
239
240
IfErrors creatBatErr2
240
- FileWrite $0 ' @echo off$\r$\n PATH $INSTDIR\bin;%PATH%$\r$\n psql.exe -h localhost -U "$UserName_text" -d postgres -p $TextPort_text $\r$\n pause'
241
+ System::Call " kernel32::GetACP() i .r2"
242
+ DetailPrint " ANSI code page $2"
243
+ FileWrite $0 ' @echo off$\r$\n chcp $2$\r$\n PATH $INSTDIR\bin;%PATH%$\r$\n psql.exe -h localhost -U "$UserName_text" -d postgres -p $TextPort_text $\r$\n pause'
241
244
FileClose $0
242
245
243
246
creatBatErr2:
@@ -262,6 +265,13 @@ Section $(PostgreSQLString) sec1
262
265
FileClose $0
263
266
264
267
creatBatErr5:
268
+ ClearErrors
269
+ FileOpen $0 $INSTDIR \scripts\pgpro_upgrade.cmd w
270
+ IfErrors creatBatErr6
271
+ FileWrite $0 ' @echo off$\r$\n set dd=%1$\r \$\n set PGDATA=%dd:"=%$\r$\n PATH $INSTDIR\bin;%PATH%$\r$\n sh.exe "$INSTDIR\bin\pgpro_upgrade"$\r$\n '
272
+ FileClose $0
273
+
274
+ creatBatErr6:
265
275
; for all users
266
276
SetShellVarContext all
267
277
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
@@ -319,8 +329,13 @@ Section $(PostgreSQLString) sec1
319
329
" $INSTDIR\doc\pg-help.ico" " 0"
320
330
321
331
!insertmacro CreateInternetShortcut \
322
- " $SMPROGRAMS\$StartMenuFolder\Documentation\PostgreSQL documentation" \
323
- " $INSTDIR\doc\postgresql\html\index.html" \
332
+ " $SMPROGRAMS\$StartMenuFolder\Documentation\PostgreSQL documentation (EN)" \
333
+ " $INSTDIR\doc\postgresql-en.chm" \
334
+ " $INSTDIR\doc\pg-help.ico" " 0"
335
+
336
+ !insertmacro CreateInternetShortcut \
337
+ " $SMPROGRAMS\$StartMenuFolder\Documentation\PostgreSQL documentation (RU)" \
338
+ " $INSTDIR\doc\postgresql-ru.chm" \
324
339
" $INSTDIR\doc\pg-help.ico" " 0"
325
340
326
341
!insertmacro CreateInternetShortcut \
@@ -329,7 +344,6 @@ Section $(PostgreSQLString) sec1
329
344
" $INSTDIR\doc\pg-help.ico" " 0"
330
345
331
346
!insertmacro MUI_STARTMENU_WRITE_END
332
-
333
347
; Create data dir begin
334
348
${if} $isDataDirExist == 0
335
349
CreateDirectory " $DATA_DIR"
@@ -365,6 +379,7 @@ Section $(PostgreSQLString) sec1
365
379
${else}
366
380
nsExec::ExecToStack /TIMEOUT= 60000 ' "$INSTDIR\bin\initdb.exe" $tempVar \
367
381
--locale="$Locale_text" \
382
+ --encoding=$Coding_text \
368
383
-U "$UserName_text" \
369
384
-D "$DATA_DIR"'
370
385
${endif}
@@ -389,6 +404,14 @@ Section $(PostgreSQLString) sec1
389
404
${if} $isDataDirExist == 0
390
405
${if} $checkNoLocal_state == ${BST_CHECKED}
391
406
!insertmacro _ReplaceInFile " $DATA_DIR\postgresql.conf" " #listen_addresses = 'localhost'" " listen_addresses = '*'"
407
+ ; Add line to pg_hba.conf
408
+ FileOpen $4 " $DATA_DIR\pg_hba.conf" a
409
+ FileSeek $4 0 END
410
+ FileWrite $4 " host$\t all$\t all$\t 0.0.0.0/0$\t md5$\r$\n "
411
+ FileClose $4
412
+ ; Add postgres to Windows Firewall exceptions
413
+ nsisFirewall::AddAuthorizedApplication " $INSTDIR\bin\postgres.exe" " PostgresPro server"
414
+ pop $0
392
415
${else}
393
416
!insertmacro _ReplaceInFile " $DATA_DIR\postgresql.conf" " #listen_addresses = 'localhost'" " listen_addresses = 'localhost'"
394
417
${EndIf}
@@ -407,7 +430,7 @@ Section $(PostgreSQLString) sec1
407
430
${endif}
408
431
${endif}
409
432
${EndIf}
410
-
433
+ ; # Add line to pg_hba.conf
411
434
Call WriteInstallOptions
412
435
DetailPrint " Service $ServiceID_text registration ..."
413
436
nsExec::ExecToStack /TIMEOUT= 60000 ' "$INSTDIR\bin\pg_ctl.exe" register -N "$ServiceID_text" -U "$ServiceAccount_text" -D "$DATA_DIR" -w'
@@ -445,6 +468,15 @@ Section $(PostgreSQLString) sec1
445
468
446
469
AccessControl::GrantOnFile " $INSTDIR\scripts" " $loggedInUser" " FullAccess"
447
470
Pop $0 ; "ok" or "error" + error details
471
+ ${if} $isDataDirExist == 1
472
+ ; there exist data directory. We need to stop service,
473
+ ; run pgpro-upgrade script and
474
+ DetailPrint " Performing catalog upgradeon $DATA_DIR"
475
+ nsExec::ExecToStack ' "$INSTDIR/scripts/pgpro_upgrade" "$DATA_DIR"'
476
+ pop $0
477
+ Pop $1 # printed text, up to ${NSIS_MAX_STRLEN}
478
+ DetailPrint " $1"
479
+ ${endif}
448
480
449
481
DetailPrint " Start server service..."
450
482
Sleep 1000
@@ -493,6 +525,7 @@ Section $(PostgreSQLString) sec1
493
525
WriteRegExpandStr HKLM " SYSTEM\CurrentControlSet\Control\Session Manager\Environment" " PGUSER" " $UserName_text"
494
526
WriteRegExpandStr HKLM " SYSTEM\CurrentControlSet\Control\Session Manager\Environment" " PGPORT" " $TextPort_text"
495
527
WriteRegExpandStr HKLM " SYSTEM\CurrentControlSet\Control\Session Manager\Environment" " PGLOCALEDIR" " $INSTDIR\share\locale\"
528
+ AddToPath::AddToPath " $INSTDIR\bin"
496
529
${endif}
497
530
SectionEnd
498
531
0 commit comments