First commit. It's working!
Page custom StackSelectCreate StackSelectLeave " - Select stack"
Function StackSelectCreate
; Only show this page if both WAMPStack and WAPPStack are installed.
StrCmp $wampstack_installed 0 "" +3
Call StackSelectLeave
Return
StrCmp $wappstack_installed 0 "" +3
Call StackSelectLeave
Return
StrCmp $XPUI_ABORTED 1 "" +2
Abort
!insertmacro XPUI_INSTALLOPTIONS_EXTRACT_AS "pages\StackSelect.ini" "StackSelect.ini"
!insertmacro XPUI_HEADER_TEXT "Select server stack" "Choose which BitNami stack installation you want to use to run $(^Name)."
!insertmacro XPUI_INSTALLOPTIONS_DISPLAY "StackSelect.ini"
FunctionEnd
Function StackSelectLeave
; Here is where we make the final decision on which stack will be used.
IfFileExists "$PLUGINSDIR\StackSelect.ini" "" OnlyOneStackInstalled
!macro ConfigCheck
IfFileExists "$stack_instdir\apps\${PRODUCT_SHORTNAME}\htdocs\config.php" 0 +3
MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Setup has found that $(^Name) is already installed on this stack. If you continue, the existing installation's configuration file will be deleted and your existing website will be replaced with a fresh one.$\n$\nDo you want to delete your existing $(^Name) website?" IDYES +2
Abort
!macroend
; Both stacks are installed; decide based on user selection
ReadINIStr $0 "$PLUGINSDIR\StackSelect.ini" "Field 1" "State"
StrCmp $0 1 "" UserSelectedWAPP
; User selected WAMP
Call BNSetVarsForWAMP
!insertmacro ConfigCheck
Return
UserSelectedWAPP:
; User selected WAPP
Call BNSetVarsForWAPP
!insertmacro ConfigCheck
Return
OnlyOneStackInstalled:
StrCmp $wampstack_installed 0 +3
; MySQL
Call BNSetVarsForWAMP
!insertmacro ConfigCheck
Return
; PostgreSQL
Call BNSetVarsForWAPP
!insertmacro ConfigCheck
Return
FunctionEnd
Function BNSetVarsForWAMP
StrCpy $stack_type "WAMP"
StrCpy $stack_instdir "$wampstack_installed"
StrCpy $db_driver "mysql"
StrCpy $db_dbmsname "MySQL"
StrCpy $db_rootuser "root"
ReadINIStr $db_port "$stack_instdir\properties.ini" "MySQL" "mysql_port"
StrCpy $stack_portbit ""
ReadINIStr $0 "$stack_instdir\properties.ini" "Apache" "apache_server_port"
StrCmp $0 "80" +2
StrCpy $stack_portbit ":$0"
FunctionEnd
Function BNSetVarsForWAPP
StrCpy $stack_type "WAPP"
StrCpy $stack_instdir "$wappstack_installed"
StrCpy $db_driver "postgresql"
StrCpy $db_dbmsname "PostgreSQL"
StrCpy $db_rootuser "postgres"
; NOTE: WAPPStack doesn't record the port of PostgreSQL - we have to assume the default
StrCpy $db_port 5432
StrCpy $stack_portbit ""
ReadINIStr $0 "$stack_instdir\properties.ini" "Apache" "apache_server_port"
StrCmp $0 "80" +2
StrCpy $stack_portbit ":$0"
FunctionEnd