; GREAT-ER Installer ;(c)2011, Intevation GmbH ;Authors: ; Andre Heinecke aheinecke@intevation.de ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License version 2, ; or, at your option, any later version as published by the Free ; Software Foundation ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ; ;-------------------------------- ; Includes ; Modern UI !include "MUI.nsh" !include "includes\trim.nsh" !include "LogicLib.nsh" ; Add (custom) plugin dir !addplugindir plugins ;-------------------------------- ; Variable declarations Var POSTGRESQL_INSTALLED Var SHOULD_AUTOLOGIN Var DB_PASSWORD Var SERVERNAME ;-------------------------------- ;Version Information (for installer file properties) VIProductVersion "${version_number}" ;needs integer format: x.x.x.x VIAddVersionKey "ProductName" "${productname_short}" VIAddVersionKey "Comments" "${productname_short} is Free Software" VIAddVersionKey "CompanyName" "${company}" VIAddVersionKey "LegalTrademarks" "" VIAddVersionKey "LegalCopyright" "${copyright}" VIAddVersionKey "FileDescription" "${description}" VIAddVersionKey "FileVersion" "${version_number} (build ${version_date})" ;-------------------------------- ; General ; Define Name, File and Installdir of Installer Name "${productname}" OutFile "${setupname}" InstallDir "$PROGRAMFILES\${productname_short}" InstType "Standard" ;-------------------------------- ;Interface Settings !define MUI_ABORTWARNING BrandingText "GREAT-ER 3.0 - PostgreSQL" ; MUI Settings / Header !define MUI_WELCOMEPAGE_TITLE "Welcome to the installation of GREAT-ER 3.0 - PostgreSQL" !define MUI_WELCOMEPAGE_TEXT "This Installer will install \r\n\ The Geo-referenced Regional Exposure Assesment Tool for European Rivers\r\n\ Version ${version_number} using the PostgreSQL Database backend." !define MUI_HEADERIMAGE_BITMAP "" !define MUI_COMPONENTSPAGE_TEXT_TOP "Please select installation type" !define MUI_WELCOMEFINISHPAGE_BITMAP "ressources\welcome_left.bmp" !define MUI_ICON "ressources\greater.ico" ;-------------------------------- ;Pages !define MUI_PAGE_CUSTOMFUNCTION_SHOW PrintNonAdminWarning !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE ${license} !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY Page custom CustomPageOptions Page custom PasswordPage PasswordPageLeave !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !define MUI_PAGE_CUSTOMFUNCTION_SHOW un.PrintNonAdminWarning !insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_COMPONENTS !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH ;-------------------------------- ;Supported Languages !insertmacro MUI_LANGUAGE "English" ;------------------------------- ;Reserve Files !insertmacro MUI_RESERVEFILE_LANGDLL !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ReserveFile "installer-options.ini" ReserveFile "password-options.ini" ;------------------------------- ; Macros for user management !macro GetServerName SERVER_NAME_OUT System::Call 'kernel32.dll::GetComputerNameExW(i 4,w .r0,*i ${NSIS_MAX_STRLEN} r1)i.r2' ${If} $2 = 1 StrCpy ${SERVER_NAME_OUT} "\\$0" ${Else} System::Call "kernel32.dll::GetComputerNameW(t .r0,*i ${NSIS_MAX_STRLEN} r1)i.r2" ${If} $2 = 1 StrCpy ${SERVER_NAME_OUT} "\\$0" ${Else} StrCpy ${SERVER_NAME_OUT} "" ${EndIf} ${EndIf} !macroend !macro DeleteUser SERVER_NAME USERNAME # Delete a user System::Call 'netapi32::NetUserDel(w "${SERVER_NAME}",w "${USERNAME}")i.r0' !macroend ;-------------------------------- ;Installer Sections ;--------------------------- ; General Section - Included in all installations Section "" ; Create uninstaller CreateDirectory "$INSTDIR" SetOutPath "$INSTDIR" WriteUninstaller "$INSTDIR\Uninstall.exe" # Delete old Start menu entries. RMDir /R "$SMPROGRAMS\${productname_short}" SetOutPath "$TEMP" DetailPrint "Installing Microsoft Visual C Runtime Libraries..." File "vcredist_x86.exe" File "vcredist-80_x86.exe" ExecWait '$TEMP\vcredist_x86.exe /q' $0 ExecWait '$TEMP\vcredist-80_x86.exe /q' $0 Delete "$TEMP\vcredist_x86.exe" Delete "$TEMP\vcredist-80_x86.exe" ; Store installation folder WriteRegStr HKLM "Software\${productname_short}" "" $INSTDIR ; Create Registry keys WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "DisplayName" "${productname_short} ${version_date}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "Displayversion_number" "${version_number}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "Displayversion_date" "${version_date}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "NoRepair" 1 SectionEnd ;------------------ ;PostgreSQL Installation Section "PostgreSQL 9.0.4" SecPostgreSQL Banner::show /NOUNLOAD /set 76 "Installing..." "PostgreSQL 9.0.4" "" !insertmacro GetServerName $SERVERNAME !insertmacro DeleteUser $SERVERNAME "greater-db" SetOutPath "$TEMP" File "postgresql-9.0.4-1-windows.exe" ; Should be more generalized DetailPrint "Installing PostgreSQL..." ExecWait '"$TEMP\postgresql-9.0.4-1-windows.exe" --mode unattended --prefix "$INSTDIR\postgres9" \ --superpassword $DB_PASSWORD --superaccount greater \ --serviceaccount greater-db --servicepassword $DB_PASSWORD \ --datadir "$INSTDIR\GREAT-ER-DB\database" --create_shortcuts 0 \ --servicename greater_postgres_server --unattendedmodeui minimal \ --debugtrace "$INSTDIR\postgres_installation.txt" --debuglevel 2 \ --install_runtimes 0' $0 Delete "$TEMP\postgresql-9.0.4-1-windows.exe" IntCmp $0 0 pgInstallOK MessageBox MB_OK|MB_ICONEXCLAMATION "Your PostgreSQL database installation failed! $\r$\n \ Please report this issue to http://wald.intevation.org/tracker/?group_id=55 $\r$\n \ with the attached installation log that you can find at:$\r$\n $TEMP\install-postgresql.log" pgInstallOK: banner::destroy ;-------------------------------- ; Install default database ; Set the temporary PGPASSWORD variable for this process and it's children System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PGPASSWORD", "$DB_PASSWORD").r0' SetOutPath "$TEMP" File "defaultdata\defaultdb.backup" File "defaultdata\10_create_users.sql" File "defaultdata\90_grant_access.sql" File "defaultdata\91_greater_compat.sql" File "defaultdata\92_sediment_compat.sql" DetailPrint "Creating default GREAT-ER datasets" ExecDos::exec '"$INSTDIR\postgres9\bin\pg_restore.exe" -C -O -d postgres -U greater \ "$TEMP\defaultdb.backup"' "" "$TEMP\greater_insert.log" ExecDos::exec '"$INSTDIR\postgres9\bin\psql" -d greater -U greater -f \ "$TEMP\10_create_users.sql"' "" "$TEMP\greater_insert.log" ExecDos::exec '"$INSTDIR\postgres9\bin\psql" -d greater -U greater -f \ "$TEMP\90_grant_access.sql"' "" "$TEMP\greater_insert.log" ExecDos::exec '"$INSTDIR\postgres9\bin\psql" -d greater -U greater -f \ "$TEMP\91_greater_compat.sql"' "" "$TEMP\greater_compat.log" ; Also the sediment database? File "defaultdata\sedimentdb.backup" ExecDos::exec '"$INSTDIR\postgres9\bin\pg_restore.exe" -C -O -d postgres -U greater \ "$TEMP\sedimentdb.backup"' "" "$TEMP\greater_sediment_insert.log" ExecDos::exec '"$INSTDIR\postgres9\bin\psql" -d greater-sediment -U greater -f \ "$TEMP\10_create_users.sql"' "" "$TEMP\greater_sediment_insert.log" ExecDos::exec '"$INSTDIR\postgres9\bin\psql" -d greater-sediment -U greater -f \ "$TEMP\90_grant_access.sql"' "" "$TEMP\greater_sediment_insert.log" ExecDos::exec '"$INSTDIR\postgres9\bin\psql" -d greater-sediment -U greater -f \ "$TEMP\92_sediment_compat.sql"' "" "$TEMP\sediment_compat.log" Delete "$TEMP\sedimentdb.backup" Delete "$TEMP\defaultdb.backup" Delete "$TEMP\10_create_users.sql" Delete "$TEMP\90_grant_access.sql" Delete "$TEMP\91_greater_compat.sql" Delete "$TEMP\92_sediment_compat.sql" ; Database should now be ready SectionEnd ;--------------------------- ; Admintool Section Section "Administration Tool" admin_section_id SetOutPath "$INSTDIR" !include ${admin-in} ; Set Path to $PROFILE SetOutPath "%HOMEDRIVE%%HOMEPATH%" # 'all users' shell folder is used (for $DESKTOP, $SMPROGRAMS, $QUICKLAUNCH,...) !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \ "Field 4" "State" SetShellVarContext all IntCmp $R0 0 just_current_user all_users all_users just_current_user: SetShellVarContext current all_users: # ** Start menu ** # Delete old Start menu entries. RMDir /R "$SMPROGRAMS\${productname_short} ${version_number}" # Check if the start menu entries where requested. !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \ "Field 2" "State" IntCmp $R0 0 no_start_menu # Create new Start menu entries CreateDirectory "$SMPROGRAMS\${productname}" CreateShortCut "$SMPROGRAMS\${productname}\GREAT-ER Administration.lnk" '"$INSTDIR\Administration\Administration.exe"' CreateDirectory "$SMPROGRAMS\${productname}\Documentation" CreateShortCut "$SMPROGRAMS\${productname}\Documentation\GREAT-ER Administration.lnk" '"$INSTDIR\Administration\administration.pdf"' no_start_menu: Return SectionEnd ;-------------------------- ; Greater pre processing Section Section "Greater Preprocessing" gpp_section_id SetOutPath "$INSTDIR" !include ${gpp-in} ; Set Path to $PROFILE SetOutPath "%HOMEDRIVE%%HOMEPATH%" # 'all users' shell folder is used (for $DESKTOP, $SMPROGRAMS, $QUICKLAUNCH,...) !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \ "Field 4" "State" SetShellVarContext all IntCmp $R0 0 just_current_user all_users all_users just_current_user: SetShellVarContext current all_users: # ** Start menu ** # Delete old Start menu entries. RMDir /R "$SMPROGRAMS\${productname_short} ${version_number}" # Check if the start menu entries where requested. !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \ "Field 2" "State" IntCmp $R0 0 no_start_menu # Create new Start menu entries CreateDirectory "$SMPROGRAMS\${productname}" CreateShortCut "$SMPROGRAMS\${productname}\Upload Catchment.lnk" \ "$INSTDIR\python\python.exe" '"$INSTDIR\greater-pre-processing\upload-catchment.py"' \ "$INSTDIR\greater-pre-processing\greater.ico" CreateShortCut "$SMPROGRAMS\${productname}\Catchment Preprocessing.lnk" \ "$INSTDIR\python\python.exe" '"$INSTDIR\greater-pre-processing\greater-pre-processing.py"' \ "$INSTDIR\greater-pre-processing\greater.ico" CreateDirectory "$SMPROGRAMS\${productname}\Documentation" CreateShortCut "$SMPROGRAMS\${productname}\Documentation\GREAT-ER Preprocessing.lnk" '"$INSTDIR\greater-pre-processing\doc\greater-preprocessing-manual.pdf"' no_start_menu: Return SectionEnd ;----------------------------- ; Client sections Section "GREAT-ER Common Files" common_section_id !include ${common-in} SectionEnd Section "GREAT-ER Sediment Ext." sediment_section_id !include ${sediment-in} ; Set Path to $PROFILE SetOutPath "%HOMEDRIVE%%HOMEPATH%" # 'all users' shell folder is used (for $DESKTOP, $SMPROGRAMS, $QUICKLAUNCH,...) !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \ "Field 4" "State" SetShellVarContext all IntCmp $R0 0 just_current_user all_users all_users just_current_user: SetShellVarContext current all_users: # ** Start menu ** # Delete old Start menu entries. RMDir /R "$SMPROGRAMS\${productname_short} ${version_number}" # Check if the start menu entries where requested. !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \ "Field 2" "State" IntCmp $R0 0 no_start_menu # Create new Start menu entries CreateDirectory "$SMPROGRAMS\${productname}" IntCmp $SHOULD_AUTOLOGIN 0 no_autologin CreateShortCut "$SMPROGRAMS\${productname}\${productname_short} Sediment.lnk" \ "$INSTDIR\python\pythonw.exe" '"$INSTDIR\GREAT-ER-Sediment\${executable}" \ "greater/$DB_PASSWORD@greater-sediment"' \ "$INSTDIR\GREAT-ER-Sediment\Resources\greater2.ico" goto no_start_menu no_autologin: CreateShortCut "$SMPROGRAMS\${productname}\${productname_short} Sediment.lnk" \ "$INSTDIR\python\pythonw.exe" '"$INSTDIR\GREAT-ER-Sediment\${executable}"' \ "$INSTDIR\GREAT-ER-Sediment\Resources\greater2.ico" no_start_menu: # ** Desktop Icon ** # Delete old Desktop link Delete "$DESKTOP\${productname_short}.lnk" # Check if the desktop entries where requested. !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \ "Field 3" "State" IntCmp $R0 0 no_desktop # Create new Desktop link IntCmp $SHOULD_AUTOLOGIN 0 desktop_no_autologin CreateShortCut "$DESKTOP\${productname_short} Sediment.lnk" \ "$INSTDIR\python\pythonw.exe" '"$INSTDIR\GREAT-ER-Sediment\${executable}" \ "greater/$DB_PASSWORD@greater-sediment"' \ "$INSTDIR\GREAT-ER-Sediment\Resources\greater2.ico" goto no_desktop desktop_no_autologin: CreateShortCut "$DESKTOP\${productname_short} Sediment.lnk" \ "$INSTDIR\python\pythonw.exe" '"$INSTDIR\GREAT-ER-Sediment\${executable}"' \ "$INSTDIR\GREAT-ER-Sediment\Resources\greater2.ico" no_desktop: Return SectionEnd Section "GREAT-ER Standard" client_section_id ; Include the input files ; package all files, recursively, preserving attributes ; assume files are in the correct places !include ${client-in} ; Set Path to $PROFILE SetOutPath "%HOMEDRIVE%%HOMEPATH%" # 'all users' shell folder is used (for $DESKTOP, $SMPROGRAMS, $QUICKLAUNCH,...) !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \ "Field 4" "State" SetShellVarContext all IntCmp $R0 0 just_current_user all_users all_users just_current_user: SetShellVarContext current all_users: # ** Start menu ** # Delete old Start menu entries. RMDir /R "$SMPROGRAMS\${productname_short} ${version_number}" # Check if the start menu entries where requested. !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \ "Field 2" "State" IntCmp $R0 0 no_start_menu # Create new Start menu entries CreateDirectory "$SMPROGRAMS\${productname}" IntCmp $SHOULD_AUTOLOGIN 0 no_autologin_2 CreateShortCut "$SMPROGRAMS\${productname}\${productname_short}.lnk" \ "$INSTDIR\python\pythonw.exe" '"$INSTDIR\GREAT-ER-CEFIC\${executable}" greater/$DB_PASSWORD@greater' \ "$INSTDIR\GREAT-ER-CEFIC\Resources\greater2.ico" goto manuals no_autologin_2: CreateShortCut "$SMPROGRAMS\${productname}\${productname_short}.lnk" \ "$INSTDIR\python\pythonw.exe" '"$INSTDIR\GREAT-ER-CEFIC\${executable}"' \ "$INSTDIR\GREAT-ER-CEFIC\Resources\greater2.ico" manuals: CreateDirectory "$SMPROGRAMS\${productname}\Documentation" CreateShortCut "$SMPROGRAMS\${productname}\Documentation\GREAT-ER Manual.lnk" '"$INSTDIR\GREAT-ER-CEFIC\doc\greater-manual.pdf"' CreateShortCut "$SMPROGRAMS\${productname}\Documentation\GREAT-ER Installation.lnk" '"$INSTDIR\GREAT-ER-CEFIC\doc\greater-installation.pdf"' CreateShortCut "$SMPROGRAMS\${productname}\Documentation\GREAT-ER Model.lnk" '"$INSTDIR\GREAT-ER-CEFIC\doc\great-er_model.pdf"' CreateShortCut "$SMPROGRAMS\${productname}\Documentation\GREAT-ER Model Specification.lnk" '"$INSTDIR\GREAT-ER-CEFIC\doc\great-er_model_specification.pdf"' no_start_menu: # ** Desktop Icon ** # Delete old Desktop link Delete "$DESKTOP\${productname_short}.lnk" # Check if the desktop entries where requested. !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \ "Field 3" "State" IntCmp $R0 0 no_desktop2 # Create new Desktop link IntCmp $SHOULD_AUTOLOGIN 0 no_autologin3 CreateShortCut "$DESKTOP\${productname_short}.lnk" \ "$INSTDIR\python\pythonw.exe" '"$INSTDIR\GREAT-ER-CEFIC\${executable}" greater/$DB_PASSWORD@greater' \ "$INSTDIR\GREAT-ER-CEFIC\Resources\greater2.ico" goto no_desktop2 no_autologin3: CreateShortCut "$DESKTOP\${productname_short}.lnk" \ "$INSTDIR\python\pythonw.exe" '"$INSTDIR\GREAT-ER-CEFIC\${executable}"' \ "$INSTDIR\GREAT-ER-CEFIC\Resources\greater2.ico" no_desktop2: Return SectionEnd ;-------------------------------- ;Install Functions Function ".onInit" newadvsplash::show /NOUNLOAD 2000 1000 500 -2 /BANNER "banner.png" InstTypeSetText 0 "Standard" SectionSetInstTypes ${sediment_section_id} 0 SectionSetInstTypes ${client_section_id} 1 SectionSetInstTypes ${common_section_id} 1 SectionSetInstTypes ${SecPostgreSQL} 1 SectionSetInstTypes ${admin_section_id} 1 SectionSetInstTypes ${gpp_section_id} 1 SectionSetFlags ${client_section_id} 1 SectionSetFlags ${SecPostgreSQL} 1 SectionSetFlags ${admin_section_id} 1 SectionSetFlags ${sediment_section_id} 0 SectionSetFlags ${gpp_section_id} 1 SectionSetFlags ${common_section_id} 17 SectionSetSize ${SecPostgreSQL} "207330" !insertmacro MUI_INSTALLOPTIONS_EXTRACT "installer-options.ini" !insertmacro MUI_INSTALLOPTIONS_EXTRACT "password-options.ini" call CheckExistingVersion CALL DetectPostgreSQL FunctionEnd Function DetectPostgreSQL ClearErrors readregstr $1 HKLM "SOFTWARE\PostgreSQL\Installations\postgresql-9.0" "Version" IfErrors done !insertmacro UnSelectSection ${SecPostgreSQL} StrCpy $POSTGRESQL_INSTALLED "yes" done: FunctionEnd ;Check whether application has already been installed. Function CheckExistingVersion ClearErrors Push $0 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" "UninstallString" IfErrors overwrite 0 MessageBox MB_YESNO|MB_ICONEXCLAMATION "${productname_short} \ $(T_AlreadyInstalled)" IDYES leave IDNO overwrite leave: ExecWait '$0 _?=$INSTDIR' overwrite: FunctionEnd # PrintNonAdminWarning # Check whether the current user is in the Administrator group or an # OS version without the need for an Administrator is in use. Print a # diagnostic if this is not the case and abort installation. Function PrintNonAdminWarning ClearErrors UserInfo::GetName IfErrors leave Pop $0 UserInfo::GetAccountType Pop $1 StrCmp $1 "Admin" leave +1 MessageBox MB_OK|MB_ICONEXCLAMATION "$(T_AdminNeeded)" Quit leave: FunctionEnd ; Custom Page for add Desktop, Startmenu and Quick Launch links Function CustomPageOptions !insertmacro MUI_HEADER_TEXT "Configuration" "$(T_InstallOptLinks)" # Note that the default selection is done in the ini file. !insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \ "Field 1" "Text" "Please select where ${productname_short} shortcuts should be placed:" !insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \ "Field 2" "Text" "Start Menu" !insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \ "Field 3" "Text" "Desktop" !insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \ "Field 4" "Text" "Install Shortcuts for all users" !insertmacro MUI_INSTALLOPTIONS_DISPLAY "installer-options.ini" FunctionEnd Function PasswordPageLeave !insertmacro MUI_INSTALLOPTIONS_READ $0 "password-options.ini" "Field 3" "State" !insertmacro MUI_INSTALLOPTIONS_READ $1 "password-options.ini" "Field 5" "State" StrCmp $0 $1 0 no_match StrLen $2 $0 IntCmp $2 0 empty Push $0 Call CheckForSpaces Pop $2 IntCmp $2 0 continue spaces spaces empty: MessageBox MB_OK|MB_ICONSTOP "An empty password is not allowed" Abort no_match: MessageBox MB_OK|MB_ICONSTOP "The passwords do not match" Abort spaces: MessageBox MB_OK|MB_ICONSTOP "The password may not contain spaces" Abort continue: StrCpy $DB_PASSWORD $0 !insertmacro MUI_INSTALLOPTIONS_READ $SHOULD_AUTOLOGIN "password-options.ini" \ "Field 6" "State" Return FunctionEnd ; Custom Page for Password input Function PasswordPage ${IfNot} ${SectionIsSelected} ${SecPostgreSQL} Abort ${EndIf} !insertmacro MUI_HEADER_TEXT "Configuration" "Database Password" !insertmacro MUI_INSTALLOPTIONS_DISPLAY "password-options.ini" FunctionEnd ;--------------------- ; Disable the next button on the components page as long as there ; are no sections selected ; Also make sure that the greater desktop is enabled as soon as ; at least sediment or usf is enabled Function .onSelChange Push $0 Push $1 SectionGetFlags ${sediment_section_id} $1 IntOp $1 ${SF_SELECTED} & $1 IntOp $0 $1 | $0 SectionGetFlags ${gpp_section_id} $1 IntOp $0 $1 | $0 SectionGetFlags ${client_section_id} $1 IntOp $0 $1 | $0 IntOp $0 16 | $0 SectionSetFlags ${common_section_id} $0 Pop $1 Pop $0 Push $0 Push $1 SectionGetFlags ${SecPostgreSQL} $0 IntOp $0 ${SF_SELECTED} & $0 SectionGetFlags ${sediment_section_id} $1 IntOp $1 ${SF_SELECTED} & $1 IntOp $0 $1 | $0 SectionGetFlags ${client_section_id} $1 IntOp $1 ${SF_SELECTED} & $1 IntOp $0 $1 | $0 SectionGetFlags ${admin_section_id} $1 IntOp $1 ${SF_SELECTED} & $1 IntOp $0 $1 | $0 GetDlgItem $1 $HWNDPARENT 1 EnableWindow $1 $0 Pop $1 Pop $0 FunctionEnd ;-------------------------------- ;Uninstaller Section "un.PostgreSQL" UnSecPostgreSQL Banner::show /NOUNLOAD /set 76 "Uninstalling..." "PostgreSQL..." "" ; TODO find path from registry and uninstall ExecDos::exec '"$INSTDIR\postgres9\bin\pg_ctl.exe" stop -D "$INSTDIR\GREAT-ER-DB\database"' ExecWait '"$INSTDIR\postgres9\uninstall-postgresql.exe" --mode unattended' Banner::destroy RMDIR "$INSTDIR\postgres9\bin" RMDIR "$INSTDIR\postgres9" RMDIR "$INSTDIR" MessageBox MB_YESNO|MB_ICONQUESTION "Do you also want to delete contents of your \ GREAT-ER Database?" \ IDYES deletedb IDNO no deletedb: RMDIR /r "$INSTDIR\GREAT-ER-DB\database" no: SectionEnd Section "un." !include ${common-un} !include ${client-un} !include ${sediment-un} !include ${admin-un} !include ${gpp-un} ; Delete Registry keys DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" DeleteRegKey HKLM "Software\${productname_short}" ; Delete Shortcuts SetShellVarContext all RMDir /R "$SMPROGRAMS\${productname}" Delete "$DESKTOP\${productname_short}.lnk" Delete "$DESKTOP\${productname_short} Sediment.lnk" Delete "$QUICKLAUNCH\${productname_short}.lnk" SetShellVarContext current RMDir /R "$SMPROGRAMS\${productname}" Delete "$DESKTOP\${productname_short}.lnk" Delete "$QUICKLAUNCH\${productname_short}.lnk" Delete "$DESKTOP\${productname_short} Sediment.lnk" ; Cleanup RMDir /R "$INSTDIR\GREAT-ER-Cefic" RMDir /R "$INSTDIR\GREAT-ER-Sediment" RMDir /R "$INSTDIR\Thuban" RMDir /R "$INSTDIR\python" RMDir /R "$INSTDIR\greater-pre-processing" RMDir /R "$INSTDIR\Lib" RMDir "$INSTDIR\postgres9" RMDir "$INSTDIR\GREAT-ER-DB" RMDir "$INSTDIR\Administration" Delete "$INSTDIR\Uninstall.exe" RMDir "$INSTDIR" SectionEnd ;-------------------------------- ;Uninstall Functions Function un.onInit CALL un.DetectPostgreSQL FunctionEnd # PrintNonAdminWarning (uninstall) Function un.DetectPostgreSQL ClearErrors readregstr $1 HKLM "SOFTWARE\PostgreSQL\Installations\postgresql-9.0" "Version" IfErrors noexist done noexist: !insertmacro UnSelectSection ${UnSecPostgreSQL} !insertmacro SetSectionFlag ${UnSecPostgreSQL} ${SF_RO} done: FunctionEnd Function un.PrintNonAdminWarning ClearErrors UserInfo::GetName IfErrors leave Pop $0 UserInfo::GetAccountType Pop $1 StrCmp $1 "Admin" leave +1 MessageBox MB_OK|MB_ICONEXCLAMATION "$(T_AdminNeeded_uninstall)" Quit leave: FunctionEnd ;--------------------------- ; Language Strings ;--------------------------- !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecPostgreSQL} "Installs the PostgreSQL 9.0.4 Database with \ basic ${productname_short} datasets." !insertmacro MUI_DESCRIPTION_TEXT ${client_section_id} "Installs the ${productname_short} \ client. $\r$\n With the CEFIC approved simulation models.$\r$\n" !insertmacro MUI_DESCRIPTION_TEXT ${sediment_section_id} "Installs a client with the \ Sediment Model extension." !insertmacro MUI_DESCRIPTION_TEXT ${admin_section_id} "Installs the Administration tool for the \ GREAT-ER Database." !insertmacro MUI_DESCRIPTION_TEXT ${gpp_section_id} "Installs the catchment preprocessing and \ upload tools." !insertmacro MUI_DESCRIPTION_TEXT ${common_section_id} "Libraries necessary to run GREAT-ER$\r$\n" !insertmacro MUI_FUNCTION_DESCRIPTION_END # From Function CheckExistingVersion LangString T_AlreadyInstalled ${LANG_ENGLISH} \ "has already been installed.$\r$\n \ It is recommended that you uninstall \ it before continuing the installation of:$\r$\n\ ${productname_short} ${version_date} $\r$\n\ Do you want to uninstall the old Version of ${productname_short} ?" # From Custom Welcome Page # # Title LangString T_Aboutversion_date ${LANG_ENGLISH} \ "Release date: ${version_date}" # From Function CustomPageOptions # English LangString T_InstallOptions ${LANG_ENGLISH} "Install Options" LangString T_PasswordOptions ${LANG_ENGLISH} "Password" LangString T_InstallOptLinks ${LANG_ENGLISH} "Shortcut Options" LangString T_InstOptLabelA ${LANG_ENGLISH} "Please select where ${productname_short} shall install links:" LangString T_InstOptFieldA ${LANG_ENGLISH} "Start Menu" LangString T_InstOptFieldB ${LANG_ENGLISH} "Desktop" LangString T_InstOptFieldC ${LANG_ENGLISH} "Quick Launch Bar" # From Function (un.)PrintNonAdminWarning LangString T_AdminNeeded ${LANG_ENGLISH} \ "Warning: Administrator permissions required for the installation of ${productname_short}." LangString T_AdminNeeded_uninstall ${LANG_ENGLISH} \ "Warning: Administrator permissions required for the uninstallation of ${productname_short}."