1
-
2
1
; PostgeSQL install Script
3
2
; Written by Postgres Professional, Postgrespro.ru
4
3
; used plugins: AccessControl, UserMgr,
@@ -245,14 +244,20 @@ Section $(componentClient) secClient
245
244
246
245
; MessageBox MB_OK|MB_ICONINFORMATION "pg_old_dir: $PG_OLD_DIR"
247
246
; Call ChecExistInstall ;get port number for psql
247
+ IfSilent 0 +2
248
+ Call ChecExistInstall
249
+
248
250
var /GLOBAL isStopped
249
251
StrCpy $isStopped 0
250
252
251
253
254
+ ; MessageBox MB_OK|MB_ICONINFORMATION "pg_old_dir: $PG_OLD_DIR"
255
+
252
256
${if} $PG_OLD_DIR != " " ; exist PG install
253
- MessageBox MB_YESNO |MB_ICONQUESTION " $(MESS_STOP_SERVER)" IDYES doitStop IDNO noyetStop
257
+ MessageBox MB_YESNO |MB_ICONQUESTION " $(MESS_STOP_SERVER)" /SD IDYES IDYES doitStop IDNO noyetStop
254
258
noyetStop:
255
- Return
259
+ ; Return
260
+ Abort
256
261
doitStop:
257
262
DetailPrint " Stop the server ..."
258
263
${if} $OLD_DATA_DIR != " "
@@ -357,25 +362,41 @@ SectionEnd
357
362
Section $(componentServer) sec1
358
363
359
364
365
+ ; MessageBox MB_OK|MB_ICONINFORMATION "componentServer"
366
+ IfSilent 0 +2
367
+ Call CheckDataDir
368
+
369
+ ; MessageBox MB_OK|MB_ICONINFORMATION "OLD_DATA_DIR=$OLD_DATA_DIR"
370
+
371
+ FileOpen $LogFile $INSTDIR \install.log w ; Opens a Empty File an fills it
372
+
360
373
${if} $PG_OLD_DIR != " " ; exist PG install
361
374
${if} $isStopped == 0
362
- MessageBox MB_YESNO |MB_ICONQUESTION " $(MESS_STOP_SERVER)" IDYES doitStop IDNO noyetStop
375
+ MessageBox MB_YESNO |MB_ICONQUESTION " $(MESS_STOP_SERVER)" /SD IDYES IDYES doitStop IDNO noyetStop
363
376
noyetStop:
364
- Return
377
+ ; Return
378
+ FileClose $LogFile
379
+ Abort
365
380
doitStop:
366
- DetailPrint " Stop the server ..."
367
381
${if} $OLD_DATA_DIR != " "
382
+ DetailPrint " Stop the server ..."
383
+ FileWrite $LogFile " Stop the server ...$\r$\n "
384
+ FileWrite $LogFile ' "$PG_OLD_DIR\bin\pg_ctl.exe" stop -D "$OLD_DATA_DIR" -m fast -w$\r$\n '
368
385
nsExec::Exec ' "$PG_OLD_DIR\bin\pg_ctl.exe" stop -D "$OLD_DATA_DIR" -m fast -w'
369
386
pop $0
387
+ FileWrite $LogFile " pg_ctl.exe stop return $0 $\r$\n "
370
388
DetailPrint " pg_ctl.exe stop return $0"
371
389
${endif}
372
390
${endif}
373
391
374
392
; unregister
393
+ FileWrite $LogFile " Unregister the service ...$\r$\n "
375
394
DetailPrint " Unregister the service ..."
376
395
${if} $OldServiceID_text != " "
396
+ FileWrite $LogFile ' "$PG_OLD_DIR\bin\pg_ctl.exe" unregister -N "$OldServiceID_text"$\r$\n '
377
397
nsExec::Exec ' "$PG_OLD_DIR\bin\pg_ctl.exe" unregister -N "$OldServiceID_text"'
378
398
pop $0
399
+ FileWrite $LogFile " pg_ctl.exe unregister return $0 $\r$\n "
379
400
DetailPrint " pg_ctl.exe unregister return $0"
380
401
${endif}
381
402
${endif}
@@ -395,7 +416,7 @@ Section $(componentServer) sec1
395
416
396
417
; File "License.txt"
397
418
398
- FileOpen $LogFile $INSTDIR \install.log w ; Opens a Empty File an fills it
419
+ ; FileOpen $LogFile $INSTDIR\install.log w ;Opens a Empty File an fills it
399
420
400
421
401
422
CreateDirectory " $INSTDIR\scripts"
@@ -411,7 +432,7 @@ Section $(componentServer) sec1
411
432
WriteUninstaller " $INSTDIR\Uninstall.exe"
412
433
413
434
; write uninstall strings
414
- FileWrite $LogFile " Write to register\r$\n "
435
+ FileWrite $LogFile " Write to register$ \r$\n"
415
436
416
437
Call writeUnistallReg
417
438
@@ -526,10 +547,10 @@ Section $(componentServer) sec1
526
547
pop $0
527
548
528
549
!insertmacro MUI_STARTMENU_WRITE_END
529
- ; Create data dir begin
530
- FileWrite $LogFile " Create data dir begin$\r$\n "
531
550
532
551
${if} $isDataDirExist == 0
552
+ ; Create data dir begin
553
+ FileWrite $LogFile " Create data dir begin$\r$\n "
533
554
CreateDirectory " $DATA_DIR"
534
555
; AccessControl::GrantOnFile "$DATA_DIR" "(BU)" "FullAccess" ;GenericWrite
535
556
; Pop $0 ;"ok" or "error" + error details
@@ -616,8 +637,8 @@ Section $(componentServer) sec1
616
637
${EndIf}
617
638
${endif}
618
639
; Create data dir end
619
- FileWrite $LogFile " Create postgresql.conf $\r$\n "
620
640
${if} $isDataDirExist == 0
641
+ FileWrite $LogFile " Create postgresql.conf $\r$\n "
621
642
${if} $checkNoLocal_state == ${BST_CHECKED}
622
643
!insertmacro _ReplaceInFile " $DATA_DIR\postgresql.conf" " #listen_addresses = 'localhost'" " listen_addresses = '*'"
623
644
; Add line to pg_hba.conf
@@ -1362,25 +1383,21 @@ Function nsDialogServerExist
1362
1383
nsDialogs::Show
1363
1384
FunctionEnd
1364
1385
1365
- Function ChecExistDataDir
1366
- ${Unless} ${SectionIsSelected} ${sec1}
1367
- Abort
1368
- ${EndUnless}
1386
+ ; check existing datadir function
1387
+ Function CheckDataDir
1369
1388
${If} ${FileExists} " $DATA_DIR\*.*"
1370
1389
StrCpy $isDataDirExist 1
1371
1390
${ElseIf} ${FileExists} " $DATA_DIR"
1372
1391
StrCpy $isDataDirExist -1
1373
1392
${Else}
1374
1393
StrCpy $isDataDirExist 0
1375
- Abort
1376
1394
${EndIf}
1377
-
1395
+
1378
1396
${If} ${FileExists} " $DATA_DIR\postgresql.conf"
1379
1397
ClearErrors
1380
1398
${ConfigRead} " $DATA_DIR\postgresql.conf" " port" $R0
1381
1399
${if} ${Errors}
1382
1400
StrCpy $isDataDirExist 0
1383
- Abort
1384
1401
${EndIf}
1385
1402
${StrRep} ' $0' ' $R0' ' =' ' '
1386
1403
${StrRep} ' $1' ' $0' ' ' ' '
@@ -1392,9 +1409,50 @@ Function ChecExistDataDir
1392
1409
StrCpy $TextPort_text $0
1393
1410
${Else}
1394
1411
StrCpy $isDataDirExist 0
1395
- Abort
1396
1412
${EndIf}
1397
1413
1414
+
1415
+ FunctionEnd
1416
+
1417
+ ; check existing datadir dialog
1418
+ Function ChecExistDataDir
1419
+ ${Unless} ${SectionIsSelected} ${sec1}
1420
+ Abort
1421
+ ${EndUnless}
1422
+
1423
+ Call CheckDataDir
1424
+ ${if} $isDataDirExist = 0
1425
+ Abort
1426
+ ${endif}
1427
+ ; ${If} ${FileExists} "$DATA_DIR\*.*"
1428
+ ; StrCpy $isDataDirExist 1
1429
+ ; ${ElseIf} ${FileExists} "$DATA_DIR"
1430
+ ; StrCpy $isDataDirExist -1
1431
+ ; ${Else}
1432
+ ; StrCpy $isDataDirExist 0
1433
+ ; Abort
1434
+ ; ${EndIf}
1435
+
1436
+ ; ${If} ${FileExists} "$DATA_DIR\postgresql.conf"
1437
+ ; ClearErrors
1438
+ ; ${ConfigRead} "$DATA_DIR\postgresql.conf" "port" $R0
1439
+ ; ${if} ${Errors}
1440
+ ; StrCpy $isDataDirExist 0
1441
+ ; Abort
1442
+ ; ${EndIf}
1443
+ ; ${StrRep} '$0' '$R0' '=' ''
1444
+ ; ${StrRep} '$1' '$0' ' ' ''
1445
+
1446
+ ; StrCpy $0 $1 5
1447
+
1448
+ ; ${StrRep} '$1' '$0' '$\t' ''
1449
+ ; ${StrRep} '$0' '$1' '#' ''
1450
+ ; StrCpy $TextPort_text $0
1451
+ ; ${Else}
1452
+ ; StrCpy $isDataDirExist 0
1453
+ ; Abort
1454
+ ; ${EndIf}
1455
+
1398
1456
${if} $PG_OLD_DIR != " " ; exist PG install
1399
1457
Abort
1400
1458
${endif}
@@ -2274,6 +2332,22 @@ ${EndIf}
2274
2332
StrCpy $isDataChecksums " $1"
2275
2333
${endif}
2276
2334
2335
+ ReadINIStr $1 $0 options servicesccount
2336
+ ${if} " $1" != " "
2337
+ StrCpy $ServiceAccount_text " $1"
2338
+ ${endif}
2339
+ ReadINIStr $1 $0 options servicepassword
2340
+ ${if} " $1" != " "
2341
+ StrCpy $servicePassword_text " $1"
2342
+ ${endif}
2343
+ ReadINIStr $1 $0 options serviceid
2344
+ ${if} " $1" != " "
2345
+ StrCpy $ServiceID_text " $1"
2346
+ ${endif}
2347
+ ReadINIStr $1 $0 options islibc
2348
+ ${if} " $1" != " "
2349
+ StrCpy $Collation_text " libc"
2350
+ ${endif}
2277
2351
2278
2352
2279
2353
FunctionEnd
0 commit comments