66
77!addplugindir Plugins
88!include " postgres.def.nsh"
9-
109; --------------------------------
1110; Include "Modern UI"
1211!include " MUI2.nsh"
@@ -114,6 +113,19 @@ Var effective_cache_size
114113Var checkBoxDataChecksums
115114Var isDataChecksums
116115
116+ Var checkBoxMoreOptions
117+ Var isShowMoreOptions
118+
119+ Var servicePassword_text
120+ Var servicePassword_editor
121+
122+ Var ServiceAccount_editor
123+ Var ServiceID_editor
124+
125+ Var Collation_editor
126+ Var Collation_text
127+
128+ Var currCommand
117129
118130; Set 'install service' variable
119131; Var service
@@ -163,6 +175,7 @@ Page custom ChecExistDataDir
163175
164176Page custom nsDialogServer nsDialogsServerPageLeave
165177Page custom nsDialogOptimization nsDialogsOptimizationPageLeave
178+ Page custom nsDialogMore nsDialogsMorePageLeave
166179
167180; Start Menu Folder Page Configuration
168181!define MUI_STARTMENUPAGE_DEFAULTFOLDER " ${PG_DEF_BRANDING}"
@@ -537,12 +550,6 @@ Section $(componentServer) sec1
537550 StrCpy $tempVar ' --pwfile "$tempFileName" -A md5 '
538551 ${endif}
539552
540-
541- ${if} $isDataChecksums == ${BST_CHECKED}
542- StrCpy $tempVar ' $tempVar --data-checksums '
543- ${endif}
544-
545-
546553 DetailPrint " Database initialization ..."
547554 AccessControl::GetCurrentUserName
548555 Pop $0 ; or "error"
@@ -553,26 +560,30 @@ Section $(componentServer) sec1
553560
554561 FileWrite $LogFile " Database initialization ...$\r$\n "
555562
556- ${if} " $Locale_text" == " $(DEF_LOCALE_NAME)"
557- FileWrite $LogFile ' "$INSTDIR\bin\initdb.exe" $tempVar \
558- --encoding=$Coding_text -U "$UserName_text" \
559- -D "$DATA_DIR" $\r$\n '
560- ; Initialise the database cluster, and set the appropriate permissions/ownership
561- nsExec::ExecToLog /TIMEOUT= 90000 ' "$INSTDIR\bin\initdb.exe" $tempVar \
563+
564+ StrCpy $currCommand ' "$INSTDIR\bin\initdb.exe" $tempVar \
562565 --encoding=$Coding_text -U "$UserName_text" \
563566 -D "$DATA_DIR"'
567+ ${if} $isDataChecksums == ${BST_CHECKED}
568+ StrCpy $currCommand ' $currCommand --data-checksums'
569+ ${endif}
570+
571+ ${if} " $Locale_text" == " $(DEF_LOCALE_NAME)"
572+ ${if} " $Collation_text" != " $(DEF_COLATE_NAME)"
573+ StrCpy $currCommand ' $currCommand --locale="@$Collation_text"'
574+ ${endif}
564575 ${else}
565- FileWrite $LogFile ' "$INSTDIR\bin\initdb.exe" $tempVar \
566- --locale="$Locale_text" \
567- --encoding=$Coding_text \
568- -U "$UserName_text" \
569- -D "$DATA_DIR" $\r$\n '
570- nsExec::ExecToLog /TIMEOUT= 60000 ' "$INSTDIR\bin\initdb.exe" $tempVar \
571- --locale="$Locale_text" \
572- --encoding=$Coding_text \
573- -U "$UserName_text" \
574- -D "$DATA_DIR"'
576+ StrCpy $currCommand ' $currCommand --locale="$Locale_text"'
577+ ${if} " $Collation_text" != " $(DEF_COLATE_NAME)"
578+ StrCpy $currCommand ' $currCommand --locale="$Locale_text@$Collation_text"'
579+ ${else}
580+ StrCpy $currCommand ' $currCommand --locale="$Locale_text"'
581+ ${endif}
575582 ${endif}
583+ FileWrite $LogFile ' $currCommand $\r$\n '
584+ ; Initialise the database cluster, and set the appropriate permissions/ownership
585+ nsExec::ExecToLog /TIMEOUT= 90000 ' $currCommand'
586+
576587 pop $0
577588 Pop $1 # printed text, up to ${NSIS_MAX_STRLEN}
578589
@@ -683,9 +694,16 @@ Section $(componentServer) sec1
683694 Call WriteInstallOptions
684695 DetailPrint " Service $ServiceID_text registration ..."
685696 FileWrite $LogFile " Service $ServiceID_text registration ... $\r$\n "
686- FileWrite $LogFile ' "$INSTDIR\bin\pg_ctl.exe" register -N "$ServiceID_text" -U "$ServiceAccount_text" -D "$DATA_DIR" -w $\r$\n '
687697
688- nsExec::ExecToStack /TIMEOUT= 60000 ' "$INSTDIR\bin\pg_ctl.exe" register -N "$ServiceID_text" -U "$ServiceAccount_text" -D "$DATA_DIR" -w'
698+ StrCpy $currCommand ' "$INSTDIR\bin\pg_ctl.exe" register -N "$ServiceID_text" -U "$ServiceAccount_text" -D "$DATA_DIR" -w'
699+ ; save without password here
700+ FileWrite $LogFile ' $currCommand $\r$\n '
701+ ${if} $servicePassword_text != " "
702+ StrCpy $currCommand ' $currCommand -P "$servicePassword_text"'
703+ ${endif}
704+ ; FileWrite $LogFile '$currCommand $\r$\n'
705+ nsExec::ExecToLog /TIMEOUT= 60000 ' $currCommand'
706+
689707 Pop $0 # return value/error/timeout
690708 Pop $1 # printed text, up to ${NSIS_MAX_STRLEN}
691709
@@ -1288,6 +1306,7 @@ Function getServerDataFromDlg
12881306
12891307 ${NSD_GetState} $checkBoxEnvVar $isEnvVar
12901308
1309+
12911310 ${NSD_GetState} $checkBoxDataChecksums $isDataChecksums
12921311
12931312
@@ -1427,7 +1446,7 @@ Function nsDialogServer
14271446 Pop $Locale
14281447
14291448 ${NSD_CB_AddString} $Locale " $(DEF_LOCALE_NAME)"
1430- ${if} ${PG_MAJOR_VERSION} = = " 10"
1449+ ${if} ${PG_MAJOR_VERSION} > = " 10"
14311450 ; ; Source URL: https://www.microsoft.com/resources/msdn/goglobal/default.mspx (windows 7)
14321451 ${NSD_CB_AddString} $Locale " af" ; 0x0036 af Afrikaans Afrikaans Afrikaans 1252 850 ZAF AFK
14331452 ${NSD_CB_AddString} $Locale " af-ZA" ; 0x0436 af-ZA Afrikaans (South Africa) Afrikaans Afrikaans (Suid Afrika) 1252 850 ZAF AFK
@@ -1910,7 +1929,7 @@ Function nsDialogServer
19101929 ${endif}
19111930 ${NSD_CB_SelectString} $Locale $Locale_text
19121931
1913- ${NSD_CreateLabel} 0 54u 70u 24u " $(DLG_SUPERUSER)"
1932+ ${NSD_CreateLabel} 0 59u 70u 24u " $(DLG_SUPERUSER)"
19141933 Pop $Label2
19151934
19161935 ${NSD_CreateText} 72u 57u 100u 12u " $UserName_text"
@@ -1938,7 +1957,7 @@ Function nsDialogServer
19381957 ${NSD_CreateCheckBox} 72u 120u 100 % 12u " $(DLG_ENVVAR)"
19391958 Pop $checkBoxEnvVar
19401959 ${NSD_SetState} $checkBoxEnvVar $isEnvVar
1941-
1960+
19421961 GetFunctionAddress $0 getServerDataFromDlg
19431962 nsDialogs::OnBack $0
19441963
@@ -2048,6 +2067,11 @@ Function nsDialogOptimization
20482067 ${NSD_SetState} $rButton1 ${BST_CHECKED}
20492068 ${endif}
20502069
2070+ ${NSD_CreateCheckBox} 20u 100u 100 % 12u " $(MORE_SHOW_MORE)"
2071+ Pop $checkBoxMoreOptions
2072+ ${NSD_SetState} $checkBoxMoreOptions $isShowMoreOptions
2073+
2074+
20512075 GetFunctionAddress $0 nsDialogsOptimizationPageLeave
20522076 nsDialogs::OnBack $0
20532077
@@ -2062,6 +2086,8 @@ Function nsDialogsOptimizationPageLeave
20622086 ${else}
20632087 StrCpy $needOptimization " 0"
20642088 ${endif}
2089+
2090+ ${NSD_GetState} $checkBoxMoreOptions $isShowMoreOptions
20652091FunctionEnd
20662092
20672093Function SetDefaultTcpPort
@@ -2105,9 +2131,11 @@ ${EndIf}
21052131 StrCpy $checkNoLocal_state ${BST_CHECKED}
21062132 StrCpy $isEnvVar ${BST_UNCHECKED} ; ${BST_CHECKED}
21072133 StrCpy $isDataChecksums ${BST_CHECKED} ; ${BST_CHECKED}
2108-
2134+ StrCpy $isShowMoreOptions ${BST_UNCHECKED} ; ${BST_CHECKED}
21092135
21102136 StrCpy $Coding_text " UTF8" ; "UTF-8"
2137+
2138+ StrCpy $Collation_text $(DEF_COLATE_NAME)
21112139
21122140 UserMgr::GetCurrentDomain
21132141 Pop $0
@@ -2309,3 +2337,73 @@ Function IsServerSection
23092337FunctionEnd
23102338
23112339
2340+ Function nsDialogMore
2341+
2342+ ${Unless} ${SectionIsSelected} ${sec1}
2343+ Abort
2344+ ${EndUnless}
2345+
2346+ ${if} $isShowMoreOptions != ${BST_CHECKED}
2347+ Abort
2348+ ${endif}
2349+
2350+ nsDialogs::Create 1018
2351+ Pop $Dialog
2352+
2353+ ${If} $Dialog == error
2354+ Abort
2355+ ${EndIf}
2356+
2357+ # !define PG_DEF_SERVICEACCOUNT "NT AUTHORITY\NetworkService"
2358+ # !define PG_DEF_SERVICEID "postgrespro-enterprise-X64-9.6"
2359+ # isu
2360+
2361+ ${NSD_CreateGroupBox} 0 0 100 % 70u " $(MORE_SERVICE_TITLE)"
2362+ Pop $0
2363+
2364+ ${NSD_CreateLabel} 10u 12u 120u 16u " $(MORE_WINUSER)"
2365+ Pop $Label
2366+
2367+ ${NSD_CreateText} 130u 14u 160u 12u " $ServiceAccount_text"
2368+ Pop $ServiceAccount_editor
2369+
2370+ ${NSD_CreateLabel} 10u 32u 120u 12u " $(MORE_WINPASS)"
2371+ Pop $Label
2372+
2373+ ${NSD_CreatePassword} 130u 30u 160u 12u $servicePassword_text
2374+ Pop $servicePassword_editor
2375+
2376+
2377+ ${NSD_CreateLabel} 10u 52u 120u 16u " $(MORE_SERVICE_NAME)"
2378+ Pop $Label
2379+
2380+ ${NSD_CreateText} 130u 50u 160u 12u " $ServiceID_text"
2381+ Pop $ServiceID_editor
2382+
2383+
2384+ ${if} ${PG_MAJOR_VERSION} >= " 10"
2385+ ${NSD_CreateLabel} 10u 82u 120u 16u " $(MORE_COLATION)"
2386+ Pop $Label
2387+
2388+ ${NSD_CreateDropList} 130u 80u 100u 12u " "
2389+ Pop $Collation_editor
2390+ ${NSD_CB_AddString} $Collation_editor " $(DEF_COLATE_NAME)"
2391+ ${NSD_CB_AddString} $Collation_editor " icu"
2392+ ${NSD_CB_AddString} $Collation_editor " libc"
2393+ ${NSD_CB_SelectString} $Collation_editor $Collation_text
2394+ ${endif}
2395+
2396+ nsDialogs::Show
2397+
2398+ FunctionEnd
2399+
2400+ Function nsDialogsMorePageLeave
2401+ ${NSD_GetText} $ServiceAccount_editor $ServiceAccount_text
2402+ ${NSD_GetText} $servicePassword_editor $servicePassword_text
2403+ ${NSD_GetText} $ServiceID_editor $ServiceID_text
2404+ ${if} ${PG_MAJOR_VERSION} >= " 10"
2405+ ${NSD_GetText} $Collation_editor $Collation_text
2406+ ${endif}
2407+
2408+
2409+ FunctionEnd
0 commit comments