Skip to content

Commit 3a4ff43

Browse files
committed
Update tcp-port auto selector
1 parent ba83a69 commit 3a4ff43

File tree

1 file changed

+49
-37
lines changed

1 file changed

+49
-37
lines changed

nsis/postgresql.nsi

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
!include "Utf8Converter.nsh"
2222

2323
!include "WinVer.nsh"
24-
24+
!include "Ports.nsh"
2525
!insertmacro VersionCompare
2626

2727
;--------------------------------
@@ -746,45 +746,57 @@ Function ChecExistInstall
746746
${if} $1 != ""
747747
StrCpy $Locale_text $1
748748
${endif}
749-
750-
; calculate free num port - use EnumRegKey
749+
750+
; tcp-port auto selector
751751
${if} $TextPort_text == ""
752-
; todo: compatibility with pg-installers family
753-
StrCpy $0 0
754-
StrCpy $2 5432
755-
756-
;SetRegView 32
757-
SetRegView 64
758-
${While} 1 = 1
759-
EnumRegKey $1 HKLM "SOFTWARE\PostgreSQL\Services" $0
760-
${if} $1 == ""
761-
${ExitWhile}
762-
${endif}
763-
ReadRegDWORD $3 HKLM "SOFTWARE\PostgreSQL\Services\$1" "Port"
764-
${if} $3 >= $2
765-
IntOp $2 $3 + 1
766-
${endif}
767-
IntOp $0 $0 + 1
768-
${EndWhile}
769-
SetRegView 32
770-
StrCpy $0 0
771-
${While} 1 = 1
772-
EnumRegKey $1 HKLM "SOFTWARE\PostgreSQL\Services" $0
773-
${if} $1 == ""
774-
${ExitWhile}
775-
${endif}
776-
ReadRegDWORD $3 HKLM "SOFTWARE\PostgreSQL\Services\$1" "Port"
777-
${if} $3 >= $2
778-
IntOp $2 $3 + 1
752+
StrCpy $TextPort_text 5432
753+
${while} 1 = 1
754+
${if} ${TCPPortOpen} $TextPort_text
755+
IntOp $TextPort_text $TextPort_text + 1
756+
${else}
757+
${exitwhile}
779758
${endif}
780-
781-
IntOp $0 $0 + 1
782-
${EndWhile}
783-
784-
${if} $IsTextPortInIni != 1 ;port can be send in ini file
785-
StrCpy $TextPort_text $2
786-
${endif}
759+
${endwhile}
787760
${endif}
761+
762+
; calculate free num port - use EnumRegKey
763+
; ${if} $TextPort_text == ""
764+
; ; todo: compatibility with pg-installers family
765+
; StrCpy $0 0
766+
; StrCpy $2 5432
767+
768+
; ;SetRegView 32
769+
; SetRegView 64
770+
; ${While} 1 = 1
771+
; EnumRegKey $1 HKLM "SOFTWARE\PostgreSQL\Services" $0
772+
; ${if} $1 == ""
773+
; ${ExitWhile}
774+
; ${endif}
775+
; ReadRegDWORD $3 HKLM "SOFTWARE\PostgreSQL\Services\$1" "Port"
776+
; ${if} $3 >= $2
777+
; IntOp $2 $3 + 1
778+
; ${endif}
779+
; IntOp $0 $0 + 1
780+
; ${EndWhile}
781+
; SetRegView 32
782+
; StrCpy $0 0
783+
; ${While} 1 = 1
784+
; EnumRegKey $1 HKLM "SOFTWARE\PostgreSQL\Services" $0
785+
; ${if} $1 == ""
786+
; ${ExitWhile}
787+
; ${endif}
788+
; ReadRegDWORD $3 HKLM "SOFTWARE\PostgreSQL\Services\$1" "Port"
789+
; ${if} $3 >= $2
790+
; IntOp $2 $3 + 1
791+
; ${endif}
792+
793+
; IntOp $0 $0 + 1
794+
; ${EndWhile}
795+
796+
; ${if} $IsTextPortInIni != 1 ;port can be send in ini file
797+
; StrCpy $TextPort_text $2
798+
; ${endif}
799+
; ${endif}
788800

789801
FunctionEnd
790802

0 commit comments

Comments
 (0)