Update setup.nsi

This commit is contained in:
Parthiv Patel 2018-03-24 15:31:28 +00:00
parent 5cbf1470e6
commit 85cc4448ea

View File

@ -1,477 +1,477 @@
# Part of Odoo,Flectra. See LICENSE file for full copyright and licensing details. # Part of Odoo,Flectra. See LICENSE file for full copyright and licensing details.
# TODO: Avoid to uninstall the database # TODO: Avoid to uninstall the database
# TODO: We can update the server or the clients without to uninstall the all-in-one # TODO: We can update the server or the clients without to uninstall the all-in-one
# TODO: Add startmenu handling (link to localhost + uninstall) # TODO: Add startmenu handling (link to localhost + uninstall)
!include 'MUI2.nsh' !include 'MUI2.nsh'
!include 'FileFunc.nsh' !include 'FileFunc.nsh'
!include 'LogicLib.nsh' !include 'LogicLib.nsh'
!include 'Sections.nsh' !include 'Sections.nsh'
!include 'x64.nsh' !include 'x64.nsh'
!macro IfKeyExists ROOT MAIN_KEY KEY !macro IfKeyExists ROOT MAIN_KEY KEY
# This macro comes from http://nsis.sourceforge.net/Check_for_a_Registry_Key # This macro comes from http://nsis.sourceforge.net/Check_for_a_Registry_Key
Push $R0 Push $R0
Push $R1 Push $R1
Push $R2 Push $R2
# XXX bug if ${ROOT}, ${MAIN_KEY} or ${KEY} use $R0 or $R1 # XXX bug if ${ROOT}, ${MAIN_KEY} or ${KEY} use $R0 or $R1
StrCpy $R1 "0" # loop index StrCpy $R1 "0" # loop index
StrCpy $R2 "0" # not found StrCpy $R2 "0" # not found
${Do} ${Do}
EnumRegKey $R0 ${ROOT} "${MAIN_KEY}" "$R1" EnumRegKey $R0 ${ROOT} "${MAIN_KEY}" "$R1"
${If} $R0 == "${KEY}" ${If} $R0 == "${KEY}"
StrCpy $R2 "1" # found StrCpy $R2 "1" # found
${Break} ${Break}
${EndIf} ${EndIf}
IntOp $R1 $R1 + 1 IntOp $R1 $R1 + 1
${LoopWhile} $R0 != "" ${LoopWhile} $R0 != ""
ClearErrors ClearErrors
Exch 2 Exch 2
Pop $R0 Pop $R0
Pop $R1 Pop $R1
Exch $R2 Exch $R2
!macroend !macroend
!define PUBLISHER 'FlectraHQ' !define PUBLISHER 'FlectraHQ'
!ifndef MAJOR_VERSION !ifndef MAJOR_VERSION
!define MAJOR_VERSION '1' !define MAJOR_VERSION '1'
!endif !endif
!ifndef MINOR_VERSION !ifndef MINOR_VERSION
!define MINOR_VERSION '0' !define MINOR_VERSION '0'
!endif !endif
!ifndef REVISION_VERSION !ifndef REVISION_VERSION
!define REVISION_VERSION 'alpha1' !define REVISION_VERSION 'alpha1'
!endif !endif
!ifndef VERSION !ifndef VERSION
!define VERSION "0" !define VERSION "0"
#!define VERSION "${MAJOR_VERSION}.${MINOR_VERSION}-r${REVISION_VERSION}" #!define VERSION "${MAJOR_VERSION}.${MINOR_VERSION}-r${REVISION_VERSION}"
!endif !endif
!define PRODUCT_NAME "Flectra" !define PRODUCT_NAME "Flectra"
!define DISPLAY_NAME "${PRODUCT_NAME} ${MAJOR_VERSION}.${MINOR_VERSION}" !define DISPLAY_NAME "${PRODUCT_NAME} ${MAJOR_VERSION}.${MINOR_VERSION}"
!define REGISTRY_ROOT HKLM !define REGISTRY_ROOT HKLM
!define UNINSTALL_BASE_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall" !define UNINSTALL_BASE_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall"
!define UNINSTALL_REGISTRY_KEY "${UNINSTALL_BASE_REGISTRY_KEY}\${DISPLAY_NAME}" !define UNINSTALL_REGISTRY_KEY "${UNINSTALL_BASE_REGISTRY_KEY}\${DISPLAY_NAME}"
!define UNINSTALL_REGISTRY_KEY_SERVER "${UNINSTALL_BASE_REGISTRY_KEY}\Flectra Server ${VERSION}" !define UNINSTALL_REGISTRY_KEY_SERVER "${UNINSTALL_BASE_REGISTRY_KEY}\Flectra Server ${VERSION}"
!define REGISTRY_KEY "Software\${DISPLAY_NAME}" !define REGISTRY_KEY "Software\${DISPLAY_NAME}"
!define DEFAULT_POSTGRESQL_HOSTNAME 'localhost' !define DEFAULT_POSTGRESQL_HOSTNAME 'localhost'
!define DEFAULT_POSTGRESQL_PORT 5432 !define DEFAULT_POSTGRESQL_PORT 5432
!define DEFAULT_POSTGRESQL_USERNAME 'openpg' !define DEFAULT_POSTGRESQL_USERNAME 'openpg'
!define DEFAULT_POSTGRESQL_PASSWORD 'openpgpwd' !define DEFAULT_POSTGRESQL_PASSWORD 'openpgpwd'
Name '${DISPLAY_NAME}' Name '${DISPLAY_NAME}'
Caption "${PRODUCT_NAME} ${VERSION} Setup" Caption "${PRODUCT_NAME} ${VERSION} Setup"
OutFile "flectra-allinone-setup-${VERSION}.exe" OutFile "flectra-allinone-setup-${VERSION}.exe"
SetCompressor /FINAL lzma SetCompressor /FINAL lzma
#SetCompress auto #SetCompress auto
ShowInstDetails show ShowInstDetails show
#XPStyle on #XPStyle on
InstallDir "$PROGRAMFILES\Flectra ${VERSION}" InstallDir "$PROGRAMFILES\Flectra ${VERSION}"
InstallDirRegKey HKCU "${REGISTRY_KEY}" "" InstallDirRegKey HKCU "${REGISTRY_KEY}" ""
BrandingText '${PRODUCT_NAME} ${VERSION}' BrandingText '${PRODUCT_NAME} ${VERSION}'
RequestExecutionLevel admin RequestExecutionLevel admin
#VIAddVersionKey "ProductName" "${PRODUCT_NAME}" #VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
#VIAddVersionKey "CompanyName" "${PUBLISHER}" #VIAddVersionKey "CompanyName" "${PUBLISHER}"
#VIAddVersionKey "FileDescription" "Installer of ${DISPLAY_NAME}" #VIAddVersionKey "FileDescription" "Installer of ${DISPLAY_NAME}"
#VIAddVersionKey "LegalCopyright" "${PUBLISHER}" #VIAddVersionKey "LegalCopyright" "${PUBLISHER}"
#VIAddVersionKey "LegalTrademark" "FLECTRA is a trademark of ${PUBLISHER}" #VIAddVersionKey "LegalTrademark" "FLECTRA is a trademark of ${PUBLISHER}"
#VIAddVersionKey "FileVersion" "${MAJOR_VERSION}.${MINOR_VERSION}.${REVISION_VERSION}" #VIAddVersionKey "FileVersion" "${MAJOR_VERSION}.${MINOR_VERSION}.${REVISION_VERSION}"
#VIProductVersion "${MAJOR_VERSION}.${MINOR_VERSION}.${REVISION_VERSION}" #VIProductVersion "${MAJOR_VERSION}.${MINOR_VERSION}.${REVISION_VERSION}"
!insertmacro GetParameters !insertmacro GetParameters
!insertmacro GetOptions !insertmacro GetOptions
Var Option_AllInOne Var Option_AllInOne
Var HasPostgreSQL Var HasPostgreSQL
Var cmdLineParams Var cmdLineParams
Var TextPostgreSQLHostname Var TextPostgreSQLHostname
Var TextPostgreSQLPort Var TextPostgreSQLPort
Var TextPostgreSQLUsername Var TextPostgreSQLUsername
Var TextPostgreSQLPassword Var TextPostgreSQLPassword
Var HWNDPostgreSQLHostname Var HWNDPostgreSQLHostname
Var HWNDPostgreSQLPort Var HWNDPostgreSQLPort
Var HWNDPostgreSQLUsername Var HWNDPostgreSQLUsername
Var HWNDPostgreSQLPassword Var HWNDPostgreSQLPassword
!define STATIC_PATH "static" !define STATIC_PATH "static"
!define PIXMAPS_PATH "${STATIC_PATH}\pixmaps" !define PIXMAPS_PATH "${STATIC_PATH}\pixmaps"
!define POSTGRESQL_EXE_FILENAME "postgresql-9.5.8-1-windows.exe" !define POSTGRESQL_EXE_FILENAME "postgresql-9.5.4-2-windows.exe"
!define POSTGRESQL_EXE "${STATIC_PATH}\${POSTGRESQL_EXE_FILENAME}" !define POSTGRESQL_EXE "${STATIC_PATH}\${POSTGRESQL_EXE_FILENAME}"
!define MUI_ABORTWARNING !define MUI_ABORTWARNING
!define MUI_ICON "${PIXMAPS_PATH}\flectra-icon.ico" !define MUI_ICON "${PIXMAPS_PATH}\flectra-icon.ico"
!define MUI_WELCOMEFINISHPAGE_BITMAP "${PIXMAPS_PATH}\flectra-intro.bmp" !define MUI_WELCOMEFINISHPAGE_BITMAP "${PIXMAPS_PATH}\flectra-intro.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${PIXMAPS_PATH}\flectra-intro.bmp" !define MUI_UNWELCOMEFINISHPAGE_BITMAP "${PIXMAPS_PATH}\flectra-intro.bmp"
!define MUI_HEADERIMAGE !define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${PIXMAPS_PATH}\flectra-slogan.bmp" !define MUI_HEADERIMAGE_BITMAP "${PIXMAPS_PATH}\flectra-slogan.bmp"
!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH !define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
!define MUI_HEADER_TRANSPARENT_TEXT "" !define MUI_HEADER_TRANSPARENT_TEXT ""
!insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${STATIC_PATH}\doc\LICENSE" !insertmacro MUI_PAGE_LICENSE "${STATIC_PATH}\doc\LICENSE"
!define MUI_COMPONENTSPAGE_SMALLDESC !define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE ComponentLeave !define MUI_PAGE_CUSTOMFUNCTION_LEAVE ComponentLeave
!insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_COMPONENTS
Page Custom ShowPostgreSQL LeavePostgreSQL Page Custom ShowPostgreSQL LeavePostgreSQL
!insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_RUN !define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_CHECKED !define MUI_FINISHPAGE_RUN_CHECKED
!define MUI_FINISHPAGE_RUN_TEXT "$(DESC_FinishPageText)" !define MUI_FINISHPAGE_RUN_TEXT "$(DESC_FinishPageText)"
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink" !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
!define MUI_FINISHPAGE_LINK $(DESC_FinishPage_Link) !define MUI_FINISHPAGE_LINK $(DESC_FinishPage_Link)
!define MUI_FINISHPAGE_LINK_LOCATION "https://flectrahq.com/page/contactus" !define MUI_FINISHPAGE_LINK_LOCATION "https://flectrahq.com/page/contactus"
!insertmacro MUI_PAGE_FINISH !insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH !insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French" !insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_RESERVEFILE_LANGDLL !insertmacro MUI_RESERVEFILE_LANGDLL
; English ; English
LangString DESC_FLECTRA_Server ${LANG_ENGLISH} "Install the Flectra Server with all the Flectra standard modules." LangString DESC_FLECTRA_Server ${LANG_ENGLISH} "Install the Flectra Server with all the Flectra standard modules."
LangString DESC_PostgreSQL ${LANG_ENGLISH} "Install the PostgreSQL RDBMS used by Flectra." LangString DESC_PostgreSQL ${LANG_ENGLISH} "Install the PostgreSQL RDBMS used by Flectra."
LangString DESC_FinishPage_Link ${LANG_ENGLISH} "Contact Flectra for Partnership and/or Support" LangString DESC_FinishPage_Link ${LANG_ENGLISH} "Contact Flectra for Partnership and/or Support"
LangString DESC_AtLeastOneComponent ${LANG_ENGLISH} "You have to choose at least one component" LangString DESC_AtLeastOneComponent ${LANG_ENGLISH} "You have to choose at least one component"
LangString DESC_CanNotInstallPostgreSQL ${LANG_ENGLISH} "You can not install the PostgreSQL database without the Flectra Server" LangString DESC_CanNotInstallPostgreSQL ${LANG_ENGLISH} "You can not install the PostgreSQL database without the Flectra Server"
LangString WARNING_HostNameIsEmpty ${LANG_ENGLISH} "The hostname for the connection to the PostgreSQL Server is empty" LangString WARNING_HostNameIsEmpty ${LANG_ENGLISH} "The hostname for the connection to the PostgreSQL Server is empty"
LangString WARNING_UserNameIsEmpty ${LANG_ENGLISH} "The username for the connection to the PostgreSQL Server is empty" LangString WARNING_UserNameIsEmpty ${LANG_ENGLISH} "The username for the connection to the PostgreSQL Server is empty"
LangString WARNING_PasswordIsEmpty ${LANG_ENGLISH} "The password for the connection to the PostgreSQL Server is empty" LangString WARNING_PasswordIsEmpty ${LANG_ENGLISH} "The password for the connection to the PostgreSQL Server is empty"
LangString WARNING_PortIsWrong ${LANG_ENGLISH} "The port for the connexion to the PostgreSQL Server is wrong (default: 5432)" LangString WARNING_PortIsWrong ${LANG_ENGLISH} "The port for the connexion to the PostgreSQL Server is wrong (default: 5432)"
LangString DESC_PostgreSQLPage ${LANG_ENGLISH} "Configure the information for the PostgreSQL connection" LangString DESC_PostgreSQLPage ${LANG_ENGLISH} "Configure the information for the PostgreSQL connection"
LangString DESC_PostgreSQL_Hostname ${LANG_ENGLISH} "Hostname" LangString DESC_PostgreSQL_Hostname ${LANG_ENGLISH} "Hostname"
LangString DESC_PostgreSQL_Port ${LANG_ENGLISH} "Port" LangString DESC_PostgreSQL_Port ${LANG_ENGLISH} "Port"
LangString DESC_PostgreSQL_Username ${LANG_ENGLISH} "Username" LangString DESC_PostgreSQL_Username ${LANG_ENGLISH} "Username"
LangString DESC_PostgreSQL_Password ${LANG_ENGLISH} "Password" LangString DESC_PostgreSQL_Password ${LANG_ENGLISH} "Password"
LangString Profile_AllInOne ${LANG_ENGLISH} "All In One" LangString Profile_AllInOne ${LANG_ENGLISH} "All In One"
LangString Profile_Server ${LANG_ENGLISH} "Server only" LangString Profile_Server ${LANG_ENGLISH} "Server only"
LangString TITLE_FLECTRA_Server ${LANG_ENGLISH} "Flectra Server" LangString TITLE_FLECTRA_Server ${LANG_ENGLISH} "Flectra Server"
LangString TITLE_PostgreSQL ${LANG_ENGLISH} "PostgreSQL Database" LangString TITLE_PostgreSQL ${LANG_ENGLISH} "PostgreSQL Database"
LangString DESC_FinishPageText ${LANG_ENGLISH} "Start Flectra" LangString DESC_FinishPageText ${LANG_ENGLISH} "Start Flectra"
; French ; French
LangString DESC_FLECTRA_Server ${LANG_FRENCH} "Installation du Serveur Flectra avec tous les modules Flectra standards." LangString DESC_FLECTRA_Server ${LANG_FRENCH} "Installation du Serveur Flectra avec tous les modules Flectra standards."
LangString DESC_PostgreSQL ${LANG_FRENCH} "Installation de la base de données PostgreSQL utilisée par Flectra." LangString DESC_PostgreSQL ${LANG_FRENCH} "Installation de la base de données PostgreSQL utilisée par Flectra."
LangString DESC_FinishPage_Link ${LANG_FRENCH} "Contactez Flectra pour un Partenariat et/ou du Support" LangString DESC_FinishPage_Link ${LANG_FRENCH} "Contactez Flectra pour un Partenariat et/ou du Support"
LangString DESC_AtLeastOneComponent ${LANG_FRENCH} "Vous devez choisir au moins un composant" LangString DESC_AtLeastOneComponent ${LANG_FRENCH} "Vous devez choisir au moins un composant"
LangString DESC_CanNotInstallPostgreSQL ${LANG_FRENCH} "Vous ne pouvez pas installer la base de données PostgreSQL sans le serveur Flectra" LangString DESC_CanNotInstallPostgreSQL ${LANG_FRENCH} "Vous ne pouvez pas installer la base de données PostgreSQL sans le serveur Flectra"
LangString WARNING_HostNameIsEmpty ${LANG_FRENCH} "L'adresse pour la connection au serveur PostgreSQL est vide" LangString WARNING_HostNameIsEmpty ${LANG_FRENCH} "L'adresse pour la connection au serveur PostgreSQL est vide"
LangString WARNING_UserNameIsEmpty ${LANG_FRENCH} "Le nom d'utilisateur pour la connection au serveur PostgreSQL est vide" LangString WARNING_UserNameIsEmpty ${LANG_FRENCH} "Le nom d'utilisateur pour la connection au serveur PostgreSQL est vide"
LangString WARNING_PasswordIsEmpty ${LANG_FRENCH} "Le mot de passe pour la connection au serveur PostgreSQL est vide" LangString WARNING_PasswordIsEmpty ${LANG_FRENCH} "Le mot de passe pour la connection au serveur PostgreSQL est vide"
LangString WARNING_PortIsWrong ${LANG_FRENCH} "Le port pour la connection au serveur PostgreSQL est erroné (défaut: 5432)" LangString WARNING_PortIsWrong ${LANG_FRENCH} "Le port pour la connection au serveur PostgreSQL est erroné (défaut: 5432)"
LangString DESC_PostgreSQLPage ${LANG_FRENCH} "Configurez les informations de connection pour le serveur PostgreSQL" LangString DESC_PostgreSQLPage ${LANG_FRENCH} "Configurez les informations de connection pour le serveur PostgreSQL"
LangString DESC_PostgreSQL_Hostname ${LANG_FRENCH} "Hôte" LangString DESC_PostgreSQL_Hostname ${LANG_FRENCH} "Hôte"
LangString DESC_PostgreSQL_Port ${LANG_FRENCH} "Port" LangString DESC_PostgreSQL_Port ${LANG_FRENCH} "Port"
LangString DESC_PostgreSQL_Username ${LANG_FRENCH} "Utilisateur" LangString DESC_PostgreSQL_Username ${LANG_FRENCH} "Utilisateur"
LangString DESC_PostgreSQL_Password ${LANG_FRENCH} "Mot de passe" LangString DESC_PostgreSQL_Password ${LANG_FRENCH} "Mot de passe"
LangString Profile_AllInOne ${LANG_FRENCH} "All In One" LangString Profile_AllInOne ${LANG_FRENCH} "All In One"
LangString Profile_Server ${LANG_FRENCH} "Seulement le serveur" LangString Profile_Server ${LANG_FRENCH} "Seulement le serveur"
LangString TITLE_FLECTRA_Server ${LANG_FRENCH} "Serveur Flectra" LangString TITLE_FLECTRA_Server ${LANG_FRENCH} "Serveur Flectra"
LangString TITLE_PostgreSQL ${LANG_FRENCH} "Installation du serveur de base de données PostgreSQL" LangString TITLE_PostgreSQL ${LANG_FRENCH} "Installation du serveur de base de données PostgreSQL"
LangString DESC_FinishPageText ${LANG_FRENCH} "Démarrer Flectra" LangString DESC_FinishPageText ${LANG_FRENCH} "Démarrer Flectra"
InstType $(Profile_AllInOne) InstType $(Profile_AllInOne)
InstType $(Profile_Server) InstType $(Profile_Server)
Section $(TITLE_FLECTRA_Server) SectionFLECTRA_Server Section $(TITLE_FLECTRA_Server) SectionFLECTRA_Server
SectionIn 1 2 SectionIn 1 2
# TODO: install in a temp dir before # TODO: install in a temp dir before
# Installing winpython # Installing winpython
SetOutPath "$INSTDIR\python" SetOutPath "$INSTDIR\python"
File /r /x "__pycache__" "..\..\..\WinPython\python-3.6.2\*" File /r /x "__pycache__" "..\..\..\WinPython\python-3.6.2\*"
SetOutPath "$INSTDIR\nssm" SetOutPath "$INSTDIR\nssm"
File /r /x "src" "..\..\..\nssm-2.24\*" File /r /x "src" "..\..\..\nssm-2.24\*"
SetOutPath "$INSTDIR\server" SetOutPath "$INSTDIR\server"
File /r /x "${POSTGRESQL_EXE_FILENAME}" /x "wkhtmltopdf" "..\..\*" File /r /x "${POSTGRESQL_EXE_FILENAME}" /x "wkhtmltopdf" "..\..\*"
SetOutPath "$INSTDIR\vcredist" SetOutPath "$INSTDIR\vcredist"
File /r "..\..\..\vcredist\*.exe" File /r "..\..\..\vcredist\*.exe"
# Install Visual C redistribuable files # Install Visual C redistribuable files
DetailPrint "Installing Visual C++ redistributable files" DetailPrint "Installing Visual C++ redistributable files"
${If} ${RunningX64} ${If} ${RunningX64}
nsExec::Exec '"$INSTDIR\vcredist\vc_redist.x64.exe" /q' nsExec::Exec '"$INSTDIR\vcredist\vc_redist.x64.exe" /q'
${Else} ${Else}
nsExec::Exec '"$INSTDIR\vcredist\vc_redist.x86.exe" /q' nsExec::Exec '"$INSTDIR\vcredist\vc_redist.x86.exe" /q'
${EndIf} ${EndIf}
SetOutPath "$INSTDIR\thirdparty" SetOutPath "$INSTDIR\thirdparty"
File /r "${STATIC_PATH}\wkhtmltopdf\*" File /r "${STATIC_PATH}\wkhtmltopdf\*"
File /r "${STATIC_PATH}\less\*" File /r "${STATIC_PATH}\less\*"
# If there is a previous install of the FLECTRA Server, keep the login/password from the config file # If there is a previous install of the FLECTRA Server, keep the login/password from the config file
WriteIniStr "$INSTDIR\server\flectra.conf" "options" "db_host" $TextPostgreSQLHostname WriteIniStr "$INSTDIR\server\flectra.conf" "options" "db_host" $TextPostgreSQLHostname
WriteIniStr "$INSTDIR\server\flectra.conf" "options" "db_user" $TextPostgreSQLUsername WriteIniStr "$INSTDIR\server\flectra.conf" "options" "db_user" $TextPostgreSQLUsername
WriteIniStr "$INSTDIR\server\flectra.conf" "options" "db_password" $TextPostgreSQLPassword WriteIniStr "$INSTDIR\server\flectra.conf" "options" "db_password" $TextPostgreSQLPassword
WriteIniStr "$INSTDIR\server\flectra.conf" "options" "db_port" $TextPostgreSQLPort WriteIniStr "$INSTDIR\server\flectra.conf" "options" "db_port" $TextPostgreSQLPort
# Fix the addons path # Fix the addons path
WriteIniStr "$INSTDIR\server\flectra.conf" "options" "addons_path" "$INSTDIR\server\flectra\addons" WriteIniStr "$INSTDIR\server\flectra.conf" "options" "addons_path" "$INSTDIR\server\flectra\addons,$INSTDIR\server\addons"
WriteIniStr "$INSTDIR\server\flectra.conf" "options" "bin_path" "$INSTDIR\thirdparty" WriteIniStr "$INSTDIR\server\flectra.conf" "options" "bin_path" "$INSTDIR\thirdparty"
# if we're going to install postgresql force it's path, # if we're going to install postgresql force it's path,
# otherwise we consider it's always done and/or correctly tune by users # otherwise we consider it's always done and/or correctly tune by users
${If} $HasPostgreSQL == 0 ${If} $HasPostgreSQL == 0
WriteIniStr "$INSTDIR\server\flectra.conf" "options" "pg_path" "$INSTDIR\PostgreSQL\bin" WriteIniStr "$INSTDIR\server\flectra.conf" "options" "pg_path" "$INSTDIR\PostgreSQL\bin"
${EndIf} ${EndIf}
DetailPrint "Installing Windows service" DetailPrint "Installing Windows service"
nsExec::ExecTOLog '"$INSTDIR\python\python.exe" "$INSTDIR\server\flectra-bin" --stop-after-init --logfile "$INSTDIR\server\flectra.log" -s' nsExec::ExecTOLog '"$INSTDIR\python\python.exe" "$INSTDIR\server\flectra-bin" --stop-after-init --logfile "$INSTDIR\server\flectra.log" -s'
${If} ${RunningX64} ${If} ${RunningX64}
nsExec::ExecToLog '"$INSTDIR\nssm\win64\nssm.exe" install ${SERVICENAME} "$INSTDIR\python\python.exe" "\"$INSTDIR\server\flectra-bin\""' nsExec::ExecToLog '"$INSTDIR\nssm\win64\nssm.exe" install ${SERVICENAME} "$INSTDIR\python\python.exe" "\"$INSTDIR\server\flectra-bin\""'
nsExec::ExecToLog '"$INSTDIR\nssm\win64\nssm.exe" set ${SERVICENAME} AppDirectory "$\"$INSTDIR\server$\""' nsExec::ExecToLog '"$INSTDIR\nssm\win64\nssm.exe" set ${SERVICENAME} AppDirectory "$\"$INSTDIR\server$\""'
${Else} ${Else}
nsExec::ExecToLog '"$INSTDIR\nssm\win32\nssm.exe" install ${SERVICENAME} "$INSTDIR\python\python.exe" "\"$INSTDIR\server\flectra-bin\""' nsExec::ExecToLog '"$INSTDIR\nssm\win32\nssm.exe" install ${SERVICENAME} "$INSTDIR\python\python.exe" "\"$INSTDIR\server\flectra-bin\""'
nsExec::ExecToLog '"$INSTDIR\nssm\win32\nssm.exe" set ${SERVICENAME} AppDirectory "$\"$INSTDIR\server$\""' nsExec::ExecToLog '"$INSTDIR\nssm\win32\nssm.exe" set ${SERVICENAME} AppDirectory "$\"$INSTDIR\server$\""'
${EndIf} ${EndIf}
nsExec::Exec "net stop ${SERVICENAME}" nsExec::Exec "net stop ${SERVICENAME}"
sleep 2 sleep 2
nsExec::Exec "net start ${SERVICENAME}" nsExec::Exec "net start ${SERVICENAME}"
sleep 2 sleep 2
SectionEnd SectionEnd
Section $(TITLE_PostgreSQL) SectionPostgreSQL Section $(TITLE_PostgreSQL) SectionPostgreSQL
SectionIn 1 2 SectionIn 1 2
SetOutPath '$TEMP' SetOutPath '$TEMP'
nsExec::Exec 'net user openpgsvc /delete' nsExec::Exec 'net user openpgsvc /delete'
File ${POSTGRESQL_EXE} File ${POSTGRESQL_EXE}
ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ActiveComputerName" "ComputerName" ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ActiveComputerName" "ComputerName"
StrCmp $0 "" win9x StrCmp $0 "" win9x
Goto done Goto done
win9x: win9x:
ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ComputerName" "ComputerName" ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ComputerName" "ComputerName"
done: done:
Rmdir /r "$INSTDIR\PostgreSQL" Rmdir /r "$INSTDIR\PostgreSQL"
ExecWait '"$TEMP\${POSTGRESQL_EXE_FILENAME}" \ ExecWait '"$TEMP\${POSTGRESQL_EXE_FILENAME}" \
--mode unattended \ --mode unattended \
--prefix "$INSTDIR\PostgreSQL" \ --prefix "$INSTDIR\PostgreSQL" \
--datadir "$INSTDIR\PostgreSQL\data" \ --datadir "$INSTDIR\PostgreSQL\data" \
--servicename "PostgreSQL_For_Flectra" \ --servicename "PostgreSQL_For_Flectra" \
--serviceaccount "openpgsvc" --servicepassword "0p3npgsvcPWD" \ --serviceaccount "openpgsvc" --servicepassword "0p3npgsvcPWD" \
--superaccount "$TextPostgreSQLUsername" --superpassword "$TextPostgreSQLPassword" \ --superaccount "$TextPostgreSQLUsername" --superpassword "$TextPostgreSQLPassword" \
--serverport $TextPostgreSQLPort' --serverport $TextPostgreSQLPort'
SectionEnd SectionEnd
Section -Post Section -Post
WriteRegExpandStr HKLM "${UNINSTALL_REGISTRY_KEY}" "UninstallString" "$INSTDIR\Uninstall.exe" WriteRegExpandStr HKLM "${UNINSTALL_REGISTRY_KEY}" "UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegExpandStr HKLM "${UNINSTALL_REGISTRY_KEY}" "InstallLocation" "$INSTDIR" WriteRegExpandStr HKLM "${UNINSTALL_REGISTRY_KEY}" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "DisplayName" "${DISPLAY_NAME}" WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "DisplayName" "${DISPLAY_NAME}"
WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${MAJOR_VERSION}.${MINOR_VERSION}" WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${MAJOR_VERSION}.${MINOR_VERSION}"
WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "Publisher" "${PUBLISHER}" WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "Publisher" "${PUBLISHER}"
; WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "Version" "${VERSION}" ; WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "Version" "${VERSION}"
; WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "VersionMajor" "${MAJOR_VERSION}.${MINOR_VERSION}" ; WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "VersionMajor" "${MAJOR_VERSION}.${MINOR_VERSION}"
; WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "VersionMinor" "${REVISION_VERSION}" ; WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "VersionMinor" "${REVISION_VERSION}"
WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "HelpLink" "support@flectrahq.com" WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "HelpLink" "support@flectrahq.com"
WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "HelpTelephone" "+65.00.00.00.00" WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "HelpTelephone" "+65.00.00.00.00"
WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "URLInfoAbout" "https://flectrahq.com" WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "URLInfoAbout" "https://flectrahq.com"
WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "Contact" "sales@flectrahq.com" WriteRegStr HKLM "${UNINSTALL_REGISTRY_KEY}" "Contact" "sales@flectrahq.com"
WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "NoModify" "1" WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "NoModify" "1"
WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "NoRepair" "1" WriteRegDWORD HKLM "${UNINSTALL_REGISTRY_KEY}" "NoRepair" "1"
WriteUninstaller "$INSTDIR\Uninstall.exe" WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd SectionEnd
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SectionFLECTRA_Server} $(DESC_FLECTRA_Server) !insertmacro MUI_DESCRIPTION_TEXT ${SectionFLECTRA_Server} $(DESC_FLECTRA_Server)
!insertmacro MUI_DESCRIPTION_TEXT ${SectionPostgreSQL} $(DESC_PostgreSQL) !insertmacro MUI_DESCRIPTION_TEXT ${SectionPostgreSQL} $(DESC_PostgreSQL)
!insertmacro MUI_FUNCTION_DESCRIPTION_END !insertmacro MUI_FUNCTION_DESCRIPTION_END
Section "Uninstall" Section "Uninstall"
# Check if the server is installed # Check if the server is installed
!insertmacro IfKeyExists "HKLM" "${UNINSTALL_REGISTRY_KEY_SERVER}" "UninstallString" !insertmacro IfKeyExists "HKLM" "${UNINSTALL_REGISTRY_KEY_SERVER}" "UninstallString"
Pop $R0 Pop $R0
ReadRegStr $0 HKLM "${UNINSTALL_REGISTRY_KEY_SERVER}" "UninstallString" ReadRegStr $0 HKLM "${UNINSTALL_REGISTRY_KEY_SERVER}" "UninstallString"
ExecWait '"$0" /S' ExecWait '"$0" /S'
nsExec::Exec "net stop ${SERVICENAME}" nsExec::Exec "net stop ${SERVICENAME}"
nsExec::Exec "sc delete ${SERVICENAME}" nsExec::Exec "sc delete ${SERVICENAME}"
sleep 2 sleep 2
Rmdir /r "$INSTDIR\server" Rmdir /r "$INSTDIR\server"
Rmdir /r "$INSTDIR\thirdparty" Rmdir /r "$INSTDIR\thirdparty"
Rmdir /r "$INSTDIR\python" Rmdir /r "$INSTDIR\python"
Rmdir /r "$INSTDIR\nssm" Rmdir /r "$INSTDIR\nssm"
DeleteRegKey HKLM "${UNINSTALL_REGISTRY_KEY}" DeleteRegKey HKLM "${UNINSTALL_REGISTRY_KEY}"
SectionEnd SectionEnd
Function .onInit Function .onInit
Push $R0 Push $R0
${GetParameters} $cmdLineParams ${GetParameters} $cmdLineParams
ClearErrors ClearErrors
Pop $R0 Pop $R0
StrCpy $Option_AllInOne 0 StrCpy $Option_AllInOne 0
StrCpy $HasPostgreSQL 0 StrCpy $HasPostgreSQL 0
StrCpy $TextPostgreSQLHostname ${DEFAULT_POSTGRESQL_HOSTNAME} StrCpy $TextPostgreSQLHostname ${DEFAULT_POSTGRESQL_HOSTNAME}
StrCpy $TextPostgreSQLPort ${DEFAULT_POSTGRESQL_PORT} StrCpy $TextPostgreSQLPort ${DEFAULT_POSTGRESQL_PORT}
StrCpy $TextPostgreSQLUsername ${DEFAULT_POSTGRESQL_USERNAME} StrCpy $TextPostgreSQLUsername ${DEFAULT_POSTGRESQL_USERNAME}
StrCpy $TextPostgreSQLPassword ${DEFAULT_POSTGRESQL_PASSWORD} StrCpy $TextPostgreSQLPassword ${DEFAULT_POSTGRESQL_PASSWORD}
Push $R0 Push $R0
${GetOptions} $cmdLineParams '/allinone' $R0 ${GetOptions} $cmdLineParams '/allinone' $R0
IfErrors +2 0 IfErrors +2 0
StrCpy $Option_AllInOne 1 StrCpy $Option_AllInOne 1
Pop $R0 Pop $R0
StrCmp $Option_AllInOne 1 AllInOneMode StrCmp $Option_AllInOne 1 AllInOneMode
StrCmp $Option_AllInOne 0 NoAllInOneMode StrCmp $Option_AllInOne 0 NoAllInOneMode
AllInOneMode: AllInOneMode:
MessageBox MB_OK|MB_ICONINFORMATION "All In One" MessageBox MB_OK|MB_ICONINFORMATION "All In One"
NoAllInOneMode: NoAllInOneMode:
!insertmacro MUI_LANGDLL_DISPLAY !insertmacro MUI_LANGDLL_DISPLAY
ClearErrors ClearErrors
EnumRegKey $0 HKLM "SOFTWARE\PostgreSQL\Installations" 0 EnumRegKey $0 HKLM "SOFTWARE\PostgreSQL\Installations" 0
IfErrors DoInstallPostgreSQL 0 IfErrors DoInstallPostgreSQL 0
StrCmp $0 "" DoInstallPostgreSQL StrCmp $0 "" DoInstallPostgreSQL
StrCpy $HasPostgreSQL 1 StrCpy $HasPostgreSQL 1
#SectionSetText ${SectionPostgreSQL} "" #SectionSetText ${SectionPostgreSQL} ""
!insertmacro UnselectSection ${SectionPostgreSQL} !insertmacro UnselectSection ${SectionPostgreSQL}
SectionSetFlags ${SectionPostgreSQL} ${SF_RO} SectionSetFlags ${SectionPostgreSQL} ${SF_RO}
DoInstallPostgreSQL: DoInstallPostgreSQL:
FunctionEnd FunctionEnd
Function .onSelChange Function .onSelChange
${If} $HasPostgreSQL == 1 ${If} $HasPostgreSQL == 1
!insertmacro UnselectSection ${SectionPostgreSQL} !insertmacro UnselectSection ${SectionPostgreSQL}
${EndIf} ${EndIf}
FunctionEnd FunctionEnd
Function PostgreSQLOnBack Function PostgreSQLOnBack
FunctionEnd FunctionEnd
Function ShowPostgreSQL Function ShowPostgreSQL
SectionGetFlags ${SectionFLECTRA_Server} $0 SectionGetFlags ${SectionFLECTRA_Server} $0
IntOp $0 $0 & ${SF_SELECTED} IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} LaunchPostgreSQLConfiguration IntCmp $0 ${SF_SELECTED} LaunchPostgreSQLConfiguration
Abort Abort
LaunchPostgreSQLConfiguration: LaunchPostgreSQLConfiguration:
nsDialogs::Create /NOUNLOAD 1018 nsDialogs::Create /NOUNLOAD 1018
Pop $0 Pop $0
${If} $0 == error ${If} $0 == error
Abort Abort
${EndIf} ${EndIf}
GetFunctionAddress $0 PostgreSQLOnBack GetFunctionAddress $0 PostgreSQLOnBack
nsDialogs::OnBack $0 nsDialogs::OnBack $0
${NSD_CreateLabel} 0 0 100% 10u $(DESC_PostgreSQLPage) ${NSD_CreateLabel} 0 0 100% 10u $(DESC_PostgreSQLPage)
Pop $0 Pop $0
${NSD_CreateLabel} 0 45 60u 12u $(DESC_PostgreSQL_Hostname) ${NSD_CreateLabel} 0 45 60u 12u $(DESC_PostgreSQL_Hostname)
Pop $0 Pop $0
${NSD_CreateText} 100 45 150u 12u $TextPostgreSQLHostname ${NSD_CreateText} 100 45 150u 12u $TextPostgreSQLHostname
Pop $HWNDPostgreSQLHostname Pop $HWNDPostgreSQLHostname
${NSD_CreateLabel} 0 75 60u 12u $(DESC_PostgreSQL_Port) ${NSD_CreateLabel} 0 75 60u 12u $(DESC_PostgreSQL_Port)
Pop $0 Pop $0
${NSD_CreateNumber} 100 75 150u 12u $TextPostgreSQLPort ${NSD_CreateNumber} 100 75 150u 12u $TextPostgreSQLPort
Pop $HWNDPostgreSQLPort Pop $HWNDPostgreSQLPort
${NSD_CreateLabel} 0 105 60u 12u $(DESC_PostgreSQL_Username) ${NSD_CreateLabel} 0 105 60u 12u $(DESC_PostgreSQL_Username)
Pop $0 Pop $0
${NSD_CreateText} 100 105 150u 12u $TextPostgreSQLUsername ${NSD_CreateText} 100 105 150u 12u $TextPostgreSQLUsername
Pop $HWNDPostgreSQLUsername Pop $HWNDPostgreSQLUsername
${NSD_CreateLabel} 0 135 60u 12u $(DESC_PostgreSQL_Password) ${NSD_CreateLabel} 0 135 60u 12u $(DESC_PostgreSQL_Password)
Pop $0 Pop $0
${NSD_CreateText} 100 135 150u 12u $TextPostgreSQLPassword ${NSD_CreateText} 100 135 150u 12u $TextPostgreSQLPassword
Pop $HWNDPostgreSQLPassword Pop $HWNDPostgreSQLPassword
nsDialogs::Show nsDialogs::Show
FunctionEnd FunctionEnd
Function LeavePostgreSQL Function LeavePostgreSQL
${NSD_GetText} $HWNDPostgreSQLHostname $TextPostgreSQLHostname ${NSD_GetText} $HWNDPostgreSQLHostname $TextPostgreSQLHostname
${NSD_GetText} $HWNDPostgreSQLPort $TextPostgreSQLPort ${NSD_GetText} $HWNDPostgreSQLPort $TextPostgreSQLPort
${NSD_GetText} $HWNDPostgreSQLUsername $TextPostgreSQLUsername ${NSD_GetText} $HWNDPostgreSQLUsername $TextPostgreSQLUsername
${NSD_GetText} $HWNDPostgreSQLPassword $TextPostgreSQLPassword ${NSD_GetText} $HWNDPostgreSQLPassword $TextPostgreSQLPassword
StrLen $1 $TextPostgreSQLHostname StrLen $1 $TextPostgreSQLHostname
${If} $1 == 0 ${If} $1 == 0
MessageBox MB_ICONEXCLAMATION|MB_OK $(WARNING_HostNameIsEmpty) MessageBox MB_ICONEXCLAMATION|MB_OK $(WARNING_HostNameIsEmpty)
Abort Abort
${EndIf} ${EndIf}
${If} $TextPostgreSQLPort <= 0 ${If} $TextPostgreSQLPort <= 0
${OrIf} $TextPostgreSQLPort > 65535 ${OrIf} $TextPostgreSQLPort > 65535
MessageBox MB_ICONEXCLAMATION|MB_OK $(WARNING_PortIsWrong) MessageBox MB_ICONEXCLAMATION|MB_OK $(WARNING_PortIsWrong)
Abort Abort
${EndIf} ${EndIf}
StrLen $1 $TextPostgreSQLUsername StrLen $1 $TextPostgreSQLUsername
${If} $1 == 0 ${If} $1 == 0
MessageBox MB_ICONEXCLAMATION|MB_OK $(WARNING_UserNameIsEmpty) MessageBox MB_ICONEXCLAMATION|MB_OK $(WARNING_UserNameIsEmpty)
Abort Abort
${EndIf} ${EndIf}
StrLen $1 $TextPostgreSQLPassword StrLen $1 $TextPostgreSQLPassword
${If} $1 == 0 ${If} $1 == 0
MessageBox MB_ICONEXCLAMATION|MB_OK $(WARNING_PasswordIsEmpty) MessageBox MB_ICONEXCLAMATION|MB_OK $(WARNING_PasswordIsEmpty)
Abort Abort
${EndIf} ${EndIf}
FunctionEnd FunctionEnd
Function ComponentLeave Function ComponentLeave
SectionGetFlags ${SectionFLECTRA_Server} $0 SectionGetFlags ${SectionFLECTRA_Server} $0
IntOp $0 $0 & ${SF_SELECTED} IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} Done IntCmp $0 ${SF_SELECTED} Done
SectionGetFlags ${SectionPostgreSQL} $0 SectionGetFlags ${SectionPostgreSQL} $0
IntOp $0 $0 & ${SF_SELECTED} IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} DontInstallPostgreSQL IntCmp $0 ${SF_SELECTED} DontInstallPostgreSQL
ChooseAtLeastOneComponent: ChooseAtLeastOneComponent:
MessageBox MB_ICONEXCLAMATION|MB_OK $(DESC_AtLeastOneComponent) MessageBox MB_ICONEXCLAMATION|MB_OK $(DESC_AtLeastOneComponent)
Abort Abort
DontInstallPostgreSQL: DontInstallPostgreSQL:
MessageBox MB_ICONEXCLAMATION|MB_OK $(DESC_CanNotInstallPostgreSQL) MessageBox MB_ICONEXCLAMATION|MB_OK $(DESC_CanNotInstallPostgreSQL)
Abort Abort
Done: Done:
FunctionEnd FunctionEnd
Function LaunchLink Function LaunchLink
ExecShell "open" "http://localhost:7073/" ExecShell "open" "http://localhost:7073/"
FunctionEnd FunctionEnd