📄 ejabberd.nsi
字号:
StrCmp $ADMIN 0 0 showpage Abort showpage: !insertmacro MUI_HEADER_TEXT $(TEXT_CU_TITLE) $(TEXT_CU_SUBTITLE) !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "CheckService.ini" !insertmacro MUI_INSTALLOPTIONS_SHOWFunctionEndFunction LeaveCheckService !insertmacro MUI_INSTALLOPTIONS_READ $0 "CheckService.ini" "Field 2" "State" StrCmp $0 0 0 autostart StrCpy $ENABLE_SERVICE 0 Goto endfun autostart: StrCpy $ENABLE_SERVICE 1 endfun:FunctionEndLangString TEXT_CR_TITLE ${LANG_ENGLISH} "Unsatisfied Requirements"LangString TEXT_CR_SUBTITLE ${LANG_ENGLISH} "Unsatisfied Ejabberd requirements found."Function CheckReqs Push "HKLM" Call FindErlang Pop $ERLANG_PATH Pop $ERLANG_VERSION StrCmp $ERLANG_PATH "" 0 abort Push "HKCU" Call FindErlang Pop $ERLANG_PATH Pop $ERLANG_VERSION StrCmp $ERLANG_PATH "" 0 abort !insertmacro MUI_HEADER_TEXT $(TEXT_CR_TITLE) $(TEXT_CR_SUBTITLE) !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "CheckReqs.ini" GetDlgItem $R0 $HWNDPARENT 1 EnableWindow $R0 0 !insertmacro MUI_INSTALLOPTIONS_SHOW abort: AbortFunctionEndFunction LeaveCheckReqs AbortFunctionEndFunction CheckReqs1 Push "HKLM" Call FindOpenSSL Pop $OPENSSL_PATH Pop $OPENSSL_VERSION StrCmp $OPENSSL_PATH "" 0 abort Push "HKCU" Call FindOpenSSL Pop $OPENSSL_PATH Pop $OPENSSL_VERSION StrCmp $OPENSSL_PATH "" 0 abort !insertmacro MUI_HEADER_TEXT $(TEXT_CR_TITLE) $(TEXT_CR_SUBTITLE) !ifdef HACKED_INSTALLOPTIONS !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "CheckReqs1H.ini" !insertmacro MUI_INSTALLOPTIONS_READ $0 "CheckReqs1H.ini" "Field 3" "State" GetDlgItem $1 $HWNDPARENT 1 EnableWindow $1 $0 !else !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "CheckReqs1.ini" !endif !insertmacro MUI_INSTALLOPTIONS_SHOW abort: AbortFunctionEndFunction LeaveCheckReqs1 !ifdef HACKED_INSTALLOPTIONS !insertmacro MUI_INSTALLOPTIONS_READ $0 "CheckReqs1H.ini" "Settings" "State" StrCmp $0 0 validate ;Next button? StrCmp $0 3 checkbox ;checkbox? Abort ;Return to the page checkbox: !insertmacro MUI_INSTALLOPTIONS_READ $0 "CheckReqs1H.ini" "Field 3" "State" GetDlgItem $1 $HWNDPARENT 1 EnableWindow $1 $0 Abort validate: !endifFunctionEndFunction FindErlang Exch $R0 Push $R1 Push $R2 Push $R3 Push $R4 Push $R5 StrCpy $R1 0 StrCpy $R2 "SOFTWARE\Ericsson\Erlang" loop: StrCmp $R0 HKLM h1 EnumRegKey $R3 HKCU $R2 $R1 Goto l1 h1: EnumRegKey $R3 HKLM $R2 $R1 l1: IntOp $R1 $R1 + 1 StrCmp $R3 "" endloop ClearErrors StrCmp $R0 HKLM h2 ReadRegStr $R4 HKCU "$R2\$R3" "" Goto l2 h2: ReadRegStr $R4 HKLM "$R2\$R3" "" l2: IfFileExists "$R4\bin\erl.exe" 0 loop Push $REQUIRED_ERLANG_VERSION Push $R3 Call CompareVersions Pop $R5 StrCmp $R5 1 get Goto loop endloop: StrCpy $R4 "" get: StrCpy $R0 $R4 StrCpy $R1 $R3 Pop $R5 Pop $R4 Pop $R3 Pop $R2 Exch $R1 Exch Exch $R0FunctionEndFunction FindOpenSSL Exch $R0 Push $R1 Push $R2 Push $R3 Push $R4 Push $R5 StrCpy $R1 0 StrCpy $R2 "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenSSL_is1" StrCmp $R0 HKLM h1 ReadRegStr $R3 HKCU "$R2" "DisplayName" ReadRegStr $R4 HKCU "$R2" "Inno Setup: App Path" Goto l1 h1: ReadRegStr $R3 HKLM "$R2" "DisplayName" ReadRegStr $R4 HKLM "$R2" "Inno Setup: App Path" l1: IfFileExists "$R4\bin\openssl.exe" 0 notfound Goto get ; TODO check version ;Push $REQUIRED_OPENSSL_VERSION ;Push $R3 ;Call CompareVersions ;Pop $R5 ;StrCmp $R5 1 get notfound: StrCpy $R4 "" get: StrCpy $R0 $R4 StrCpy $R1 $R3 Pop $R5 Pop $R4 Pop $R3 Pop $R2 Exch $R1 Exch Exch $R0FunctionEnd;----------------------------------------------------------------------; CompareVersions; input:; top of stack = existing version; top of stack-1 = needed version; output:; top of stack = 1 if current version => neded version, else 0; version is a string in format "xx.xx.xx.xx" (number of interger sections ; can be different in needed and existing versions)Function CompareVersions ; stack: existing ver | needed ver Exch $R0 Exch Exch $R1 ; stack: $R1|$R0 Push $R1 Push $R0 ; stack: e|n|$R1|$R0 ClearErrors loop: IfErrors VersionNotFound Strcmp $R0 "" VersionTestEnd Call ParseVersion Pop $R0 Exch Call ParseVersion Pop $R1 Exch IntCmp $R1 $R0 +1 VersionOk VersionNotFound Pop $R0 Push $R0 goto loop VersionTestEnd: Pop $R0 Pop $R1 Push $R1 Push $R0 StrCmp $R0 $R1 VersionOk VersionNotFound VersionNotFound: StrCpy $R0 "0" Goto end VersionOk: StrCpy $R0 "1"end: ; stack: e|n|$R1|$R0 Exch $R0 Pop $R0 Exch $R0 ; stack: res|$R1|$R0 Exch ; stack: $R1|res|$R0 Pop $R1 ; stack: res|$R0 Exch Pop $R0 ; stack: resFunctionEnd;-----------------------------------------------------------------------; ParseVersion; input:; top of stack = version string ("xx.xx.xx.xx"); output: ; top of stack = first number in version ("xx"); top of stack-1 = rest of the version string ("xx.xx.xx")Function ParseVersion Exch $R1 ; version Push $R2 Push $R3 StrCpy $R2 1 loop: StrCpy $R3 $R1 1 $R2 StrCmp $R3 "." loopend StrLen $R3 $R1 IntCmp $R3 $R2 loopend loopend IntOp $R2 $R2 + 1 Goto loop loopend: Push $R1 StrCpy $R1 $R1 $R2 Exch $R1 StrLen $R3 $R1 IntOp $R3 $R3 - $R2 IntOp $R2 $R2 + 1 StrCpy $R1 $R1 $R3 $R2 Push $R1 Exch 2 Pop $R3 Exch 2 Pop $R2 Exch 2 Pop $R1FunctionEndFunction FindFiles Exch $R5 # callback function Exch Exch $R4 # file name Exch 2 Exch $R0 # directory Push $R1 Push $R2 Push $R3 Push $R6 Push $R0 # first dir to search StrCpy $R3 1 nextDir: Pop $R0 IntOp $R3 $R3 - 1 ClearErrors FindFirst $R1 $R2 "$R0\*.*" nextFile: StrCmp $R2 "." gotoNextFile StrCmp $R2 ".." gotoNextFile StrCmp $R2 $R4 0 isDir Push "$R0\$R2" Call $R5 Pop $R6 StrCmp $R6 "stop" 0 isDir loop: StrCmp $R3 0 done Pop $R0 IntOp $R3 $R3 - 1 Goto loop isDir: IfFileExists "$R0\$R2\*.*" 0 gotoNextFile IntOp $R3 $R3 + 1 Push "$R0\$R2" gotoNextFile: FindNext $R1 $R2 IfErrors 0 nextFile done: FindClose $R1 StrCmp $R3 0 0 nextDir Pop $R6 Pop $R3 Pop $R2 Pop $R1 Pop $R0 Pop $R5 Pop $R4FunctionEnd
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -