; CPack install script designed for a nmake build !addplugindir '@CPACK_PLUGIN_PATH@/NSIS_Simple_Service_Plugin_1.30' !addplugindir '@CPACK_PLUGIN_PATH@/UAC-plug-in-NSIS/Ansi' !addplugindir '@CPACK_PLUGIN_PATH@/AccessControl/Plugins' !addincludedir '@CPACK_PLUGIN_PATH@/UAC-plug-in-NSIS' !addincludedir '@CPACK_PLUGIN_PATH@/' !include "exitcodes.nsh" ;-------------------------------- ; Include LogicLib for more readable code !include "LogicLib.nsh" !include "UAC.nsh" !include "nsDialogs.nsh" !include "WinMessages.nsh" !include "MUI2.nsh" !include "StripSlashes.nsh" !include "xcopy.nsh" !include "Utf8Converter.nsh" ; !include "GetTime.nsh" ;-------------------------------- ; get commandline parameters !include "FileFunc.nsh" !insertmacro GetParameters !insertmacro GetOptions ;-------------------------------- !define VERSION "@CPACK_PACKAGE_VERSION@" !define PATCH "@CPACK_PACKAGE_VERSION_PATCH@" !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@" !define ARANGO_INI "etc\arangodb3\arangod.conf" ;-------------------------------- ; custom defines for the DRY people of us. !define TRI_UNINSTALL_REG_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"; # Comes from WaitForService: !define TRI_SVC_NAME 'ArangoDB' ; Put some of the more custom ones in from the CMakeFile: @CPACK_ARANGODB_NSIS_DEFINES@ ;-------------------------------- ;Variables x -> from userinput !define EMPTY "" Var MUI_TEMP Var STARTMENU_FOLDER Var SV_ALLUSERS Var START_MENU Var ADD_DESKTOP_ICON ; x bool: add desktop icon Var IS_DEFAULT_INSTALLDIR Var STORAGE_ENGINE ; x string auto/mmfiles/rocksdb Var PASSWORD ; x string Var PASSWORD_AGAIN ; x string / only for comparison Var PURGE_DB ; x bool ; delete DB on uninstall Var ADD_TO_PATH ; x bool Var AUTOMATIC_UPDATE Var AUTOMATIC_BACKUP # determine_possible_install_scope sets: Var AllowGlobalInstall Var ChooseInstallPath Var BackupPath VAR TRI_INSTALL_SERVICE ; x bool VAR TRI_INSTALL_SCOPE_ALL ; x bool => All / ThisUser Var newCfgValues ; keep new config file values Var newCfgValuesUtf8 ; translated version of the content Var newCfgValuesFile ; write them to a temporary file... Var ServiceUp ; did the service start? !define TEMP1 $R0 ;Temp variable Var DATADIR Var APPDIR ; Var LOGFILE Var ini_DATADIR Var ini_APPDIR ; Var ini_LOGFILE Var UpgradeInstall Var LaunchAfterInstall Var LaunchLink ;---------------------------------------- ; The first dialog page Var Dlg1_Dialog Var Dlg1_RB_all_users Var Dlg1_RB_cur_user Var Dlg1_CB_custom_path ;Var Dlg1_CB_custom_logging Var Dlg1_CB_automatic_update Var Dlg1_CB_keep_backup Var Dlg1_CB_add_path Var Dlg1_CB_DesktopIcon ;---------------------------------------- ; The second dialog page Var Dlg2_Dialog Var Dlg2_PW_1 Var Dlg2_PW_2 Var DLG2_droplist ;-------------------------------- ;Default installation folder InstallDir "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" ;-------------------------------- ;General ;Name and file Name "@CPACK_NSIS_PACKAGE_NAME@" OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@" ;Set compression SetCompressor @CPACK_NSIS_COMPRESSOR@ ;Require administrator access ; RequestExecutionLevel admin RequestExecutionLevel highest !include "AddToPath.nsh" !include "AddToRegistry.nsh" !include "WaitForService.nsh" !include "ReadINIFileKeys.nsh" !macro determine_possible_install_scope UserInfo::GetAccountType pop $0 ${If} $0 == "admin" StrCpy $AllowGlobalInstall "1" ${Else} StrCpy $AllowGlobalInstall "0" ${EndIf} !macroend !macro determine_install_scope un Function ${un}determine_install_scope Pop $0 ; Now that we know the install scope, calculate directories: ${If} $TRI_INSTALL_SCOPE_ALL == 1 SetShellVarContext all ${If} $INSTDIR == "" ${OrIf} $0 == 1 StrCpy $INSTDIR "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" ${EndIf} StrCpy $DATADIR "$APPDATA\ArangoDB\" StrCpy $APPDIR "$APPDATA\ArangoDB-apps\" ${Else} SetShellVarContext current ${If} $INSTDIR == "" ${OrIf} $0 == 1 StrCpy $INSTDIR "$LOCALAPPDATA\@CPACK_PACKAGE_INSTALL_DIRECTORY@" ${EndIf} StrCpy $DATADIR "$LOCALAPPDATA\ArangoDB\" StrCpy $APPDIR "$LOCALAPPDATA\ArangoDB-apps\" ${EndIf} FunctionEnd !macroend !insertmacro determine_install_scope "" !insertmacro determine_install_scope "un." !macro determineInstallScope forceSet Push ${forceSet} call determine_install_scope !macroend !macro un.determineInstallScope forceSet Push ${forceSet} call un.determine_install_scope !macroend ;-------------------------------- Var CB_Launch Function edit_finish_page IfSilent 0 continueUI Return continueUI: ${NSD_CreateCheckbox} 120u -20u 50% 20u "Launch ArangoDB?" Pop $CB_Launch ${NSD_Check} $CB_Launch FunctionEnd Function check_launch_arangodb ${NSD_GetState} $CB_Launch $0 ${If} $0 <> 0 StrCpy $LaunchAfterInstall "1" ${Else} StrCpy $LaunchAfterInstall "0" ${EndIf} FunctionEnd Function un.ReadSettings SetRegView ${BITS} ; A single user isn''t in HKCC... StrCpy $TRI_INSTALL_SCOPE_ALL '0' ReadRegStr $TRI_INSTALL_SCOPE_ALL HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "scopeAll" ReadRegStr $TRI_INSTALL_SERVICE HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "service" !insertmacro un.determineInstallScope 0 ReadRegStr $START_MENU SHCTX "${TRI_UNINSTALL_REG_PATH}" "StartMenu" ;MessageBox MB_OK "Start menu is in: $START_MENU" ReadRegStr $ADD_TO_PATH SHCTX "${TRI_UNINSTALL_REG_PATH}" "AddToPath" ;MessageBox MB_OK "Add to path: $ADD_TO_PATH" ReadRegStr $ADD_DESKTOP_ICON SHCTX "${TRI_UNINSTALL_REG_PATH}" "InstallToDesktop" ReadINIStr $newCfgValuesUtf8 "$INSTDIR\${ARANGO_INI}" "database" "directory" ${Utf8ToAnsi} $newCfgValuesUtf8 $DATADIR ReadINIStr $newCfgValuesUtf8 "$INSTDIR\${ARANGO_INI}" "javascript" "app-path" ${Utf8ToAnsi} $newCfgValuesUtf8 $APPDIR FunctionEnd Function check_previous_install StrCpy $UpgradeInstall "0" IfFileExists "$DATADIR\@INC_CPACK_ARANGO_DATA_DIR@\SERVER" OldFound IfFileExists "$DATADIR\@INC_CPACK_ARANGO_DATA_DIR@\ENGINE" OldFound DetailPrint "This is a fresh install." return OldFound: DetailPrint "found old installation." StrCpy $UpgradeInstall "1" FunctionEnd Function stop_old_service ${If} $TRI_INSTALL_SERVICE == 1 SimpleSC::StopService '${TRI_SVC_NAME}' 0 30 Call WaitForServiceDown SimpleSC::RemoveService '${TRI_SVC_NAME}' ${EndIf} FunctionEnd !include Sections.nsh ;--- Component support macros: --- ; The code for the add/remove functionality is from: ; http://nsis.sourceforge.net/Add/Remove_Functionality ; It has been modified slightly and extended to provide ; inter-component dependencies. Var AR_SecFlags Var AR_RegFlags @CPACK_NSIS_SECTION_SELECTED_VARS@ ; Loads the "selected" flag for the section named SecName into the ; variable VarName. !macro LoadSectionSelectedIntoVar SecName VarName SectionGetFlags ${${SecName}} $${VarName} IntOp $${VarName} $${VarName} & ${SF_SELECTED} ;Turn off all other bits !macroend ; Loads the value of a variable... can we get around this? !macro LoadVar VarName IntOp $R0 0 + $${VarName} !macroend ; Sets the value of a variable !macro StoreVar VarName IntValue IntOp $${VarName} 0 + ${IntValue} !macroend !macro InitSection SecName ; This macro reads component installed flag from the registry and ;changes checked state of the section on the components page. ;Input: section index constant name specified in Section command. ClearErrors ;Reading component status from registry ReadRegDWORD $AR_RegFlags HKLM "${TRI_UNINSTALL_REG_PATH}\Components\${SecName}" "Installed" IfErrors "default_${SecName}" ;Status will stay default if registry value not found ;(component was never installed) IntOp $AR_RegFlags $AR_RegFlags & ${SF_SELECTED} ;Turn off all other bits SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading default section flags IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE ;Turn lowest (enabled) bit off IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags ;Change lowest bit ; Note whether this component was installed before !insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags IntOp $R0 $AR_RegFlags & $AR_RegFlags ;Writing modified flags SectionSetFlags ${${SecName}} $AR_SecFlags "default_${SecName}:" !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected !macroend !macro FinishSection SecName ; This macro reads section flag set by user and removes the section ;if it is not selected. ;Then it writes component installed flag to registry ;Input: section index constant name specified in Section command. SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags ;Checking lowest bit: IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED} IntCmp $AR_SecFlags 1 "leave_${SecName}" ;Section is not selected: ;Calling Section uninstall macro and writing zero installed flag !insertmacro "Remove_${${SecName}}" WriteRegDWORD HKLM "${TRI_UNINSTALL_REG_PATH}\Components\${SecName}" "Installed" 0 Goto "exit_${SecName}" "leave_${SecName}:" ;Section is selected: WriteRegDWORD HKLM "${TRI_UNINSTALL_REG_PATH}\Components\${SecName}" "Installed" 1 "exit_${SecName}:" !macroend !macro RemoveSection_CPack SecName ; This macro is used to call section''s Remove_... macro ;from the uninstaller. ;Input: section index constant name specified in Section command. !insertmacro "Remove_${${SecName}}" !macroend ; Determine whether the selection of SecName changed !macro MaybeSelectionChanged SecName !insertmacro LoadVar ${SecName}_selected SectionGetFlags ${${SecName}} $R1 IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits ; See if the status has changed: IntCmp $R0 $R1 "${SecName}_unchanged" !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected" !insertmacro "Deselect_required_by_${SecName}" goto "${SecName}_unchanged" "${SecName}_was_selected:" !insertmacro "Select_${SecName}_depends" "${SecName}_unchanged:" !macroend ;--- End of Add/Remove macros --- ;-------------------------------- ;Interface Settings !define MUI_HEADERIMAGE "@CPACK_NSIS_MUI_ICON@" !define MUI_ABORTWARNING !verbose 3 !include "WinMessages.NSH" !verbose 4 ;---------------------------------------- !verbose 3 !include "WinMessages.NSH" !verbose 4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Uninstall sutff ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;########################################### ;# Utility Functions # ;########################################### ;-------------------------------- ; Installation types @CPACK_NSIS_INSTALLATION_TYPES@ ;-------------------------------- ; Component sections @CPACK_NSIS_COMPONENT_SECTIONS@ ;-------------------------------- ; Define some macro setting for the gui @CPACK_NSIS_INSTALLER_MUI_ICON_CODE@ ;;;1 ;; @CPACK_NSIS_INSTALLER_ICON_CODE@ ;;;2 @CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@ ;;;3 @CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@ !define MUI_HEADERIMAGE_BITMAP "@CPACK_NSIS_HEADER_ICON@" !define MUI_HEADERIMAGE_BITMAP_STRETCH "AspectFitHeight" !define MUI_WELCOMEFINISHPAGE_BITMAP "@CPACK_NSIS_PAGE_ICON@" !define MUI_WELCOMEFINISHPAGE_BITMAP_NOSTRETCH 1 ;-------------------------------- ;Pages !define MUI_PAGE_CUSTOMFUNCTION_PRE skip_page !insertmacro MUI_PAGE_WELCOME !define MUI_PAGE_CUSTOMFUNCTION_PRE skip_page !insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@" Page custom InstallOptionsPage1 InstallOptionsPage1_results !define MUI_PAGE_CUSTOMFUNCTION_PRE hide_install_directory !define MUI_PAGE_CUSTOMFUNCTION_LEAVE check_installation_directory !insertmacro MUI_PAGE_DIRECTORY !define MUI_PAGE_HEADER_TEXT "Choose the database folder for @CPACK_PACKAGE_NAME@" !define MUI_PAGE_HEADER_SUBTEXT "" !define MUI_DIRECTORYPAGE_TEXT_TOP "choose the folder where @CPACK_PACKAGE_NAME@ will create its database files" !define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Database folder" !define MUI_PAGE_CUSTOMFUNCTION_PRE hide_install_directory !define MUI_PAGE_CUSTOMFUNCTION_LEAVE check_database_directory !define MUI_DIRECTORYPAGE_VARIABLE $DATADIR !insertmacro MUI_PAGE_DIRECTORY !define MUI_PAGE_HEADER_TEXT "Choose the services folder for @CPACK_PACKAGE_NAME@" !define MUI_PAGE_HEADER_SUBTEXT "" !define MUI_DIRECTORYPAGE_TEXT_TOP "choose the folder where @CPACK_PACKAGE_NAME@ will install Foxx services" !define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Foxx services folder" !define MUI_PAGE_CUSTOMFUNCTION_PRE hide_install_directory !define MUI_PAGE_CUSTOMFUNCTION_LEAVE check_foxx_directory !define MUI_DIRECTORYPAGE_VARIABLE $APPDIR !insertmacro MUI_PAGE_DIRECTORY Page custom InstallOptionsPage2 InstallOptionsPage2_results ;Start Menu Folder Page Configuration !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX" !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER @CPACK_NSIS_PAGE_COMPONENTS@ !define MUI_PAGE_CUSTOMFUNCTION_PRE stop_old_service !define MUI_PAGE_CUSTOMFUNCTION_LEAVE insert_registration_keys !insertmacro MUI_PAGE_INSTFILES !define MUI_PAGE_CUSTOMFUNCTION_SHOW edit_finish_page !define MUI_PAGE_CUSTOMFUNCTION_LEAVE check_launch_arangodb !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_WELCOME UninstPage custom un.unInstallOptionsPage1 un.unInstallOptionsPage1_results !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES ;-------------------------------- ;Languages !insertmacro MUI_LANGUAGE "English" ;first language is the default language !insertmacro MUI_LANGUAGE "Albanian" !insertmacro MUI_LANGUAGE "Arabic" !insertmacro MUI_LANGUAGE "Basque" !insertmacro MUI_LANGUAGE "Belarusian" !insertmacro MUI_LANGUAGE "Bosnian" !insertmacro MUI_LANGUAGE "Breton" !insertmacro MUI_LANGUAGE "Bulgarian" !insertmacro MUI_LANGUAGE "Croatian" !insertmacro MUI_LANGUAGE "Czech" !insertmacro MUI_LANGUAGE "Danish" !insertmacro MUI_LANGUAGE "Dutch" !insertmacro MUI_LANGUAGE "Estonian" !insertmacro MUI_LANGUAGE "Farsi" !insertmacro MUI_LANGUAGE "Finnish" !insertmacro MUI_LANGUAGE "French" !insertmacro MUI_LANGUAGE "German" !insertmacro MUI_LANGUAGE "Greek" !insertmacro MUI_LANGUAGE "Hebrew" !insertmacro MUI_LANGUAGE "Hungarian" !insertmacro MUI_LANGUAGE "Icelandic" !insertmacro MUI_LANGUAGE "Indonesian" !insertmacro MUI_LANGUAGE "Irish" !insertmacro MUI_LANGUAGE "Italian" !insertmacro MUI_LANGUAGE "Japanese" !insertmacro MUI_LANGUAGE "Korean" !insertmacro MUI_LANGUAGE "Kurdish" !insertmacro MUI_LANGUAGE "Latvian" !insertmacro MUI_LANGUAGE "Lithuanian" !insertmacro MUI_LANGUAGE "Luxembourgish" !insertmacro MUI_LANGUAGE "Macedonian" !insertmacro MUI_LANGUAGE "Malay" !insertmacro MUI_LANGUAGE "Mongolian" !insertmacro MUI_LANGUAGE "Norwegian" !insertmacro MUI_LANGUAGE "Polish" !insertmacro MUI_LANGUAGE "Portuguese" !insertmacro MUI_LANGUAGE "PortugueseBR" !insertmacro MUI_LANGUAGE "Romanian" !insertmacro MUI_LANGUAGE "Russian" !insertmacro MUI_LANGUAGE "Serbian" !insertmacro MUI_LANGUAGE "SerbianLatin" !insertmacro MUI_LANGUAGE "SimpChinese" !insertmacro MUI_LANGUAGE "Slovak" !insertmacro MUI_LANGUAGE "Slovenian" !insertmacro MUI_LANGUAGE "Spanish" !insertmacro MUI_LANGUAGE "Swedish" !insertmacro MUI_LANGUAGE "Thai" !insertmacro MUI_LANGUAGE "TradChinese" !insertmacro MUI_LANGUAGE "Turkish" !insertmacro MUI_LANGUAGE "Ukrainian" !insertmacro MUI_LANGUAGE "Welsh" !insertmacro Locate Var ForAllTxt ;-------------------------------- ; Create custom pages Function InstallOptionsPage1 IfSilent 0 continueUI Return continueUI: !insertmacro determineInstallScope 1 Push ${TEMP1} !insertmacro MUI_HEADER_TEXT "Install Options" "Choose options for installing @CPACK_NSIS_PACKAGE_NAME@" nsDialogs::Create 1018 Pop $Dlg1_Dialog ${If} $Dlg1_Dialog == error Abort ${EndIf} ${NSD_CreateLabel} 0 20 100% 6% "Choose to install @CPACK_PACKAGE_NAME@ for all users or the current user:" Pop $0 ; Don't care... StrCpy $ForAllTxt "for all users (and ArangoDB as a service)" ${If} $AllowGlobalInstall == "0" StrCpy $ForAllTxt "$ForAllTxt (only available for privileged users)" ${EndIf} ${NSD_CreateRadioButton} 5 45 100% 6% $ForAllTxt Pop $Dlg1_RB_all_users ${NSD_CreateRadioButton} 5 65 50% 6% "for the current user" Pop $Dlg1_RB_cur_user ; Checkboxes ${NSD_CreateCheckBox} 0 -100 100% 6% "Choose custom install paths for databases and installation" Pop $Dlg1_CB_custom_path ;${NSD_CreateCheckBox} 0 -120 100% 6% "Enable ArangoDBs own logfiles" ;Pop $Dlg1_CB_custom_logging ${NSD_CreateCheckBox} 0 -80 100% 6% "Automatically update existing ArangoDB database" Pop $Dlg1_CB_automatic_update ${NSD_SetState} $Dlg1_CB_automatic_update ${BST_CHECKED} ${NSD_CreateCheckBox} 0 -60 100% 6% "Keep a backup of databases" Pop $Dlg1_CB_keep_backup ${NSD_SetState} $Dlg1_CB_keep_backup ${BST_CHECKED} ${NSD_CreateCheckBox} 0 -40 100% 6% "Add @CPACK_PACKAGE_NAME@ to the Path environment variable" Pop $Dlg1_CB_add_path ${NSD_SetState} $Dlg1_CB_add_path ${BST_CHECKED} ${NSD_CreateCheckBox} 0 -20 100% 6% "Create @CPACK_PACKAGE_NAME@ Desktop Icon" Pop $Dlg1_CB_DesktopIcon ${NSD_SetState} $Dlg1_CB_DesktopIcon ${BST_CHECKED} ${If} $AllowGlobalInstall == "0" ${NSD_SetState} $Dlg1_RB_cur_user ${BST_CHECKED} EnableWindow $Dlg1_RB_all_users 0 ${Else} ${NSD_SetState} $Dlg1_RB_all_users ${BST_CHECKED} ${EndIf} nsDialogs::Show Return FunctionEnd ;-------------------------------- Function InstallOptionsPage1_results IfSilent 0 continueUI Return continueUI: Push $R0 Push $R1 Push $R2 ${NSD_GetState} $Dlg1_RB_all_users $R0 ${NSD_GetState} $Dlg1_RB_cur_user $R1 ${If} $R0 = ${BST_CHECKED} StrCpy $TRI_INSTALL_SCOPE_ALL "1" StrCpy $TRI_INSTALL_SERVICE "1" ${Else} StrCpy $TRI_INSTALL_SCOPE_ALL "0" StrCpy $TRI_INSTALL_SERVICE "0" ${EndIf} ${NSD_GetState} $Dlg1_CB_custom_path $R0 ${If} $R0 = ${BST_CHECKED} StrCpy $ChooseInstallPath "1" ${Else} StrCpy $ChooseInstallPath "0" ${EndIf} ;${NSD_GetState} $Dlg1_CB_custom_logging $R0 ;${If} $R0 = ${BST_CHECKED} ; StrCpy $LOGFILE "$APPDIR\LOG.txt" ;${EndIf} ${NSD_GetState} $Dlg1_CB_automatic_update $R0 ${If} $R0 = ${BST_CHECKED} StrCpy $AUTOMATIC_UPDATE "1" ${Else} StrCpy $AUTOMATIC_UPDATE "0" ${EndIf} ${NSD_GetState} $Dlg1_CB_keep_backup $R0 ${If} $R0 = ${BST_CHECKED} StrCpy $AUTOMATIC_BACKUP "1" ${Else} StrCpy $AUTOMATIC_BACKUP "0" ${EndIf} ${NSD_GetState} $Dlg1_CB_add_path $R0 ${If} $R0 = ${BST_CHECKED} StrCpy $ADD_TO_PATH '1' ${Else} StrCpy $ADD_TO_PATH '0' ${EndIf} ${NSD_GetState} $Dlg1_CB_DesktopIcon $R0 ${If} $R0 = ${BST_CHECKED} StrCpy $ADD_DESKTOP_ICON "1" ${Else} StrCpy $ADD_DESKTOP_ICON "0" ${EndIf} !insertmacro determineInstallScope 1 Call check_previous_install Pop $R2 Pop $R1 Pop $R0 FunctionEnd Function InstallOptionsPage2 IfSilent 0 continueUI Return continueUI: ${If} $UpgradeInstall == "0" IfFileExists "$DATADIR/databases" cleanupDBDirectory 0 IfFileExists "$DATADIR/journals" cleanupDBDirectory 0 IfFileExists "$DATADIR/rocksdb" cleanupDBDirectory 0 IfFileExists "$DATADIR/engine-rocksdb" cleanupDBDirectory 0 goto startDialog cleanupDBDirectory: MessageBox MB_ICONEXCLAMATION "Please clean up the previously existing incomplete database directory $\r$\n$DATADIR$\r$\n before continuing with the installation!" startDialog: ${Else} StrCpy $STORAGE_ENGINE "auto" Return ${EndIf} nsDialogs::Create 1018 Pop $Dlg2_Dialog ${If} $Dlg2_Dialog == error Abort ${EndIf} !insertmacro MUI_HEADER_TEXT "Configure @CPACK_PACKAGE_NAME@" "Choose configuration options for @CPACK_NSIS_PACKAGE_NAME@" ${NSD_CreateLabel} 0, 0, 100% 6% "Type password for the ArangoDB root user:" Pop $0 ; Don't care... ${NSD_CreatePassword} 5u 30 30% 6% "" Pop $Dlg2_PW_1 ${NSD_CreateLabel} 35% 30 40% 6% "Password" Pop $0 ; Don't care... ${NSD_CreatePassword} 5u 50 30% 6% "" Pop $Dlg2_PW_2 ${NSD_CreateLabel} 35% 50 40% 6% "Password (Again)" Pop $0 ; Don't care... ${NSD_CreateLabel} 0, 90, 100% 6% "Choose the storage engine to use for this ArangoDB installation" Pop $0 ; Don't care... ${NSD_CreateDropList} 5, 110, 30% 6% "" Pop $DLG2_droplist ${NSD_CB_AddString} $DLG2_droplist "auto" ${NSD_CB_AddString} $DLG2_droplist "mmfiles" ${NSD_CB_AddString} $DLG2_droplist "rocksdb" ${NSD_CB_SelectString} $DLG2_droplist "auto" nsDialogs::Show Return FunctionEnd ;-------------------------------- Function InstallOptionsPage2_results ${If} $UpgradeInstall == "1" Return ${EndIf} Push $R0 Push $R1 Push $R2 ${NSD_GetText} $DLG2_droplist $STORAGE_ENGINE ${NSD_GetText} $Dlg2_PW_2 $PASSWORD_AGAIN ${NSD_GetText} $Dlg2_PW_1 $PASSWORD StrCmp $PASSWORD $PASSWORD_AGAIN done 0 MessageBox MB_OK|MB_ICONSTOP "Passwords don't match, try again" Abort done: Pop $R2 Pop $R1 Pop $R0 return FunctionEnd ;-------------------------------- Function hide_install_directory ${If} $ChooseInstallPath == "0" Abort ${EndIf} FunctionEnd ;-------------------------------- Function skip_page FunctionEnd Function UpgradeExisting ; Check whether we acutally should upgrade: !insertmacro StripBackslash DATADIR !insertmacro StripSlash DATADIR DetailPrint "Checking whether an existing database needs upgrade: " push ${ARANGO_EXIT_ALREADY_RUNNING} pop $0 retryDetectUpgradeNeeded: ExecWait "$INSTDIR\${SBIN_DIR}\arangod.exe --server.rest-server false --log.foreground-tty false --database.check-version" $0 DetailPrint "done Checking whether an existing database needs upgrade: $0" ${If} $0 == ${ARANGO_EXIT_ALREADY_RUNNING} ${OrIf} $0 == ${ARANGO_EXIT_COULD_NOT_LOCK} MessageBox MB_RETRYCANCEL "Another ArangoDB is currently locking your database, please stop it, and then click retry." IDCANCEL abortUpgrade IDRETRY retryDetectUpgradeNeeded abortUpgrade: Abort ${EndIf} ${If} $0 != 0 ${AndIf} $0 != ${ARANGO_EXIT_UPGRADE_REQUIRED} !insertmacro printExitCode $0 "failed to detect whether we need to Upgrade" "" ${ElseIf} $0 == ${ARANGO_EXIT_UPGRADE_REQUIRED} ${AndIf} $AUTOMATIC_UPDATE == "1" DetailPrint "Update required." ${If} $AUTOMATIC_BACKUP == "1" ; We should and we should keep a backup: StrCpy $BackupPath "$DATADIR" ${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6 StrCpy $BackupPath "$BackupPath_$2-$1-$0_$4_$5_$6" CreateDirectory "$BackupPath" DetailPrint "Copying old database from $DATADIR" DetailPrint "to backup directory $BackupPath" !insertmacro xCopyDir "$DATADIR" "$BackupPath" ${EndIf} DetailPrint "Attempting to run database upgrade: " ; Now actually do the upgrade ExecWait "$INSTDIR\${SBIN_DIR}\arangod.exe --server.rest-server false --log.level error --database.auto-upgrade true" $0 DetailPrint "Done running database upgrade: $0" ${If} $0 != 0 !insertmacro printExitCode $0 "the Upgrade failed, please do a manual upgrade" "" Abort ${EndIf} ${EndIf} FunctionEnd Function SetDBPassword DetailPrint "preserving password for install process:" System::Call 'Kernel32::SetEnvironmentVariable(t, t)i ("ARANGODB_DEFAULT_ROOT_PASSWORD", "$PASSWORD").r0' DetailPrint "preserved password: $0" StrCmp $0 0 error DetailPrint "Attempting to initialize the database with a password: " ExecWait "$INSTDIR\${SBIN_DIR}\arangod.exe --database.init-database --server.rest-server false --server.statistics false --foxx.queues false" $0 DetailPrint "Done initializing password: $0" ${If} $0 == 0 return ${Else} !insertmacro printExitCode $0 "Failed to initialize database password$\r$\n" "Please check the Windows event log for more details$\r$\n" Abort ${EndIf} error: MessageBox MB_OK "Failed to initialize database password.$\r$\nPlease check the Windows event log for details." Abort FunctionEnd Function InstallService DetailPrint "Installing service ${TRI_SVC_NAME}: " SimpleSC::InstallService '${TRI_SVC_NAME}' '' '16' '2' '"$INSTDIR\${SBIN_DIR}\arangod.exe" --start-service' '' '' '' Pop $0 DetailPrint "Status: $0; Setting Description: ${TRI_FRIENDLY_SVC_NAME}" SimpleSC::SetServiceDescription '${TRI_SVC_NAME}' '${TRI_FRIENDLY_SVC_NAME}' Pop $0 DetailPrint "Status: $0; Starting Service" SimpleSC::StartService '${TRI_SVC_NAME}' '' 45 Pop $0 DetailPrint "Status: $0" ${If} $0 != "0" Call QueryServiceStatus Pop $2 Pop $1 Pop $0 !define SC_WAITED "Waited 40 seconds for the ArangoDB service to come up;" !define SC_SV "Please look at $\r$\n`sc query ${TRI_SVC_NAME}`" !define SC_EVLOG "and the Windows Eventlog for eventual errors!" ${If} $1 == "1066" ${If} $2 == "1" MessageBox MB_OK "${SC_WAITED}$\r$\nbut it exited with an error; $\r$\n${SC_SV}$\r$\n${SC_EVLOG}" Abort ${Else} !insertmacro printExitCode $2 "${SC_WAITED}$\r$\nbut it exited with a fatal error" "$\r$\n${SC_SV}$\r$\n${SC_EVLOG};$\r$\nExit status: $2" ; MessageBox MB_OK "${SC_WAITED}$\r$\nbut it exited with a fatal error; $\r$\n${SC_SV}$\r$\n${SC_EVLOG}" Abort ${EndIf} ${ElseIf} $1 != "0" MessageBox MB_OK "${SC_WAITED}$\r$\n${SC_SV}$\r$\n${SC_EVLOG} $0 $1 $2" Abort ${EndIf} Abort ${Else} StrCpy $ServiceUp "1" ${EndIf} FunctionEnd Function assignFileRightsCB StrCpy $0 "0" AccessControl::GrantOnFile \ "$R9" "(BU)" "GenericRead + GenericWrite + GenericExecute" Push $0 FunctionEnd Function assignFileRights ClearErrors ${Locate} "$INSTDIR" "/L=FD /M=*.*" "assignFileRightsCB" ${Locate} "$DATADIR" "/L=FD /M=*.*" "assignFileRightsCB" ${Locate} "$APPDIR" "/L=FD /M=*.*" "assignFileRightsCB" FunctionEnd Var mycheckbox ; You could just store the HWND in $1 etc if you don't want this extra variable ;-------------------------------- ; Create custom pages Function un.unInstallOptionsPage1 IfSilent 0 continueUI Return continueUI: call un.ReadSettings !insertmacro MUI_HEADER_TEXT "Unnstall Options" "Choose options for uninstalling @CPACK_NSIS_PACKAGE_NAME@" nsDialogs::Create 1018 Pop $Dlg1_Dialog ${If} $Dlg1_Dialog == error Abort ${EndIf} ${NSD_CreateLabel} 0 0 100% 60u "Your databases are stored in $\r$\n'$DATADIR'$\r$\n, and your Foxx services in$\r$\n'$APPDIR'$\r$\nShould we remove it during the uninstallation?" Pop $0 ; Don't care... ${NSD_CreateCheckbox} 5u -20u 50% 20u "Delete databases with uninstallation?" Pop $mycheckbox nsDialogs::Show Return FunctionEnd ;-------------------------------- Function un.unInstallOptionsPage1_results ${NSD_GetState} $mycheckbox $0 ${If} $0 <> 0 StrCpy $PURGE_DB "1" ${EndIf} FunctionEnd ;-------------------------------- ;Installer Sections Section "-Core installation" ;Use the entire tree produced by the INSTALL target. Keep the ;list of directories here in sync with the RMDir commands below. SetOutPath "$INSTDIR" ; SetRegView controlls where die regkeys are written to ; SetRegView 32 writes the keys into Wow6432 SetRegView ${BITS} @CPACK_NSIS_FULL_INSTALL@ ;Store installation folder WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR ;Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" !insertmacro AddToRegistry "DisplayName" "@CPACK_NSIS_DISPLAY_NAME@" !insertmacro AddToRegistry "DisplayVersion" "@CPACK_PACKAGE_VERSION@" !insertmacro AddToRegistry "Publisher" "@CPACK_PACKAGE_VENDOR@" !insertmacro AddToRegistry "UninstallString" "$INSTDIR\Uninstall.exe" !insertmacro AddToRegistry "NoRepair" "1" ; Optional registration !insertmacro AddToRegistry "DisplayIcon" "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@" !insertmacro AddToRegistry "HelpLink" "@CPACK_NSIS_HELP_LINK@" !insertmacro AddToRegistry "URLInfoAbout" "@CPACK_NSIS_URL_INFO_ABOUT@" !insertmacro AddToRegistry "Contact" "@CPACK_NSIS_CONTACT@" !insertmacro MUI_STARTMENU_WRITE_BEGIN Application ;Create shortcuts CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Arango Shell.lnk" "$INSTDIR\${BIN_DIR}\arangosh.exe" '' '$INSTDIR\resources\arangodb.ico' '0' SW_SHOWMAXIMIZED StrCpy $LaunchLink "$SMPROGRAMS\$STARTMENU_FOLDER\Arango Server.lnk" CreateShortCut "$LaunchLink" "$INSTDIR\${SBIN_DIR}\arangod.exe" '' '$INSTDIR\resources\arangodb.ico' '0' SW_SHOWMINIMIZED CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe" StrCmp "0" "$ADD_DESKTOP_ICON" noDesktopIcon CreateShortCut "$DESKTOP\Arango Shell.lnk" "$INSTDIR\${BIN_DIR}\arangosh.exe" '' '$INSTDIR\resources\arangodb.ico' '0' SW_SHOWMAXIMIZED CreateShortCut "$DESKTOP\Arango Management Interface.lnk" "http://127.0.0.1:8529" '' '$INSTDIR\resources\arangodb.ico' '0' SW_SHOWMAXIMIZED ${If} $TRI_INSTALL_SERVICE == "0" ${AndIf} $ADD_DESKTOP_ICON == "1" ; if we don't install a service, add a desktop icon for the server. CreateShortCut "$DESKTOP\ArangoDB Server.lnk" "$INSTDIR\${SBIN_DIR}\arangod.exe" '' '$INSTDIR\resources\arangodb.ico' '0' SW_SHOWMINIMIZED ${EndIf} noDesktopIcon: ; Write special uninstall registry entries !insertmacro AddToRegistry "StartMenu" "$STARTMENU_FOLDER" !insertmacro AddToRegistry "AddToPath" "$ADD_TO_PATH" !insertmacro AddToRegistry "InstallToDesktop" "$ADD_DESKTOP_ICON" !insertmacro MUI_STARTMENU_WRITE_END !insertmacro AddToRegistry "DATADIR" "$DATADIR" !insertmacro AddToRegistry "APPDIR" "$APPDIR" !insertmacro StripBackslash APPDIR !insertmacro StripSlash APPDIR ; Create a file containing the settings we want to be overwritten: ${If} $DATADIR != "" StrCpy $ini_DATADIR "[database]$\r$\ndirectory = $DATADIR$\r$\n" ${EndIf} ${If} $APPDIR != "" StrCpy $ini_APPDIR "[javascript]$\r$\napp-path = $APPDIR$\r$\n" ${EndIf} ;${If} $LOGFILE != "" ; StrCpy $ini_LOGFILE "[log]$\r$\nfile = $LOGFILE$\r$\n" ;${EndIf} StrCpy $newCfgValues "$ini_APPDIR$ini_DATADIR[server]$\r$\nstorage-engine = $STORAGE_ENGINE$\r$\n" ${AnsiToUtf8} $newCfgValues $newCfgValuesUtf8 StrCpy $newCfgValuesFile "$INSTDIR\etc\arangodb3\newValues.ini" FileOpen $4 "$newCfgValuesFile" w FileWrite $4 "$newCfgValuesUtf8" FileClose $4 ; Alter the shipped file and insert the values from above: push "$newCfgValuesFile" push "$INSTDIR\${ARANGO_INI}" call ReadINIFileKeys Delete "$newCfgValuesFile" CreateDirectory $APPDIR Call assignFileRights ${If} $UpgradeInstall == "1" Call UpgradeExisting ${Else} Call SetDBPassword ${EndIf} Call assignFileRights ${If} $TRI_INSTALL_SERVICE == "1" Call InstallService ${EndIf} SectionEnd Function .onInstSuccess Call insert_registration_keys ${If} $ADD_TO_PATH == "1" !insertmacro AddToPath "$INSTDIR/${BIN_DIR}" $TRI_INSTALL_SCOPE_ALL ${EndIf} IfSilent 0 continueUI Return continueUI: ${If} $LaunchAfterInstall == '1' ${If} $TRI_INSTALL_SERVICE == "0" ExecShell "" "$LaunchLink" sleep 5000 StrCpy $ServiceUp "1" ${EndIf} ${If} $ServiceUp == 1 ; open web ui in default browser ExecShell "" "${TRI_AARDVARK_URL}" ${EndIf} ${EndIf} FunctionEnd Function is_writable ; is does not matter if we do some errors here ${If} $TRI_INSTALL_SCOPE_ALL == '1' CreateDirectory $INSTDIR Call assignFileRights ${EndIf} FunctionEnd Function check_database_directory call check_previous_install FunctionEnd Function check_foxx_directory FunctionEnd Function check_installation_directory ClearErrors Call is_writable StrCmp $1 "0" handle_error return handle_error: MessageBox MB_YESNO "You aren't allowed to install ArangoDB in ${INSTDIR}$\r$\nDo you want try once more?" IDNO no Abort no: Quit FunctionEnd Function insert_registration_keys ClearErrors ${If} $AllowGlobalInstall == "1" WriteRegExpandStr HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "service" "$TRI_INSTALL_SERVICE" IfErrors there_are_erros WriteRegExpandStr HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "scopeAll" "$TRI_INSTALL_SCOPE_ALL" IfErrors there_are_erros ${EndIf} Return there_are_erros: ;nothing MessageBox MB_OK "There was an error adding the installation keys to the registry.$\r$\nArangoDB will work fine, but there may be trouble during the uninstallation.$\r$\nPlease contact @CPACK_NSIS_CONTACT@" FunctionEnd ;-------------------------------- ; determine admin versus local install Function un.onInit ; are we allowed to un.install admin in first place? !insertmacro determine_possible_install_scope ; ArangoDB may be installed in different places ; Determine if the ArangoDB was installed for a local user ${GetParameters} $R0 ${GetOptions} $R0 "/PURGE_DB=" $PURGE_DB IfErrors 0 +2 StrCpy $PURGE_DB "0" Pop $0 SetShellVarContext current StrCpy $TRI_INSTALL_SERVICE "0" StrCpy $TRI_INSTALL_SCOPE_ALL "0" ${If} $AllowGlobalInstall == "1" ReadRegStr $TRI_INSTALL_SERVICE HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "service" ReadRegStr $TRI_INSTALL_SCOPE_ALL HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "scopeAll" ${EndIf} ${If} $TRI_INSTALL_SCOPE_ALL == 1 SetShellVarContext all ${Else} SetShellVarContext current ${EndIf} FunctionEnd ;--- Add/Remove callback functions: --- !macro SectionList MacroName ;This macro used to perform operation on multiple sections. ;List all of your components in following manner here. @CPACK_NSIS_COMPONENT_SECTION_LIST@ !macroend Section -FinishComponents ;Removes unselected components and writes component status to registry !insertmacro SectionList "FinishSection" SectionEnd ;--- End of Add/Remove callback functions --- ;-------------------------------- ; Component dependencies Function .onSelChange !insertmacro SectionList MaybeSelectionChanged FunctionEnd ;-------------------------------- ;Uninstaller Section Section "Uninstall" call un.ReadSettings ; SetRegView controlls where die regkeys are written to ; SetRegView 32 writes the keys into Wow6432 ; this variable was defined by eld and included in NSIS.template.in ; we probably need this for the install/uninstall software list. ;MessageBox MB_OK "Install to desktop: $ADD_DESKTOP_ICON " StrCmp "0" "$ADD_DESKTOP_ICON" noDesktopIconRemove Delete "$DESKTOP\Arango Shell.lnk" Delete "$DESKTOP\Arango Management Interface.lnk" ${If} $TRI_INSTALL_SERVICE == "0" Delete "$DESKTOP\ArangoDB Server.lnk" ${EndIf} noDesktopIconRemove: ;MessageBox MB_OK "Deleting Directory: $SMPROGRAMS\$START_MENU\ $TRI_INSTALL_SERVICE " Delete "$SMPROGRAMS\$START_MENU" ${If} $TRI_INSTALL_SERVICE == "1" ;SimpleSC::GetServiceName '${TRI_SVC_NAME}' ;Pop $0 ; returns an errorcode (<>0) otherwise success (0) ;Pop $1 ; returns the binary path of the service ;MessageBox MB_OK "GetServiceName: : $0 $1 " ; First get the installed service command. SimpleSC::GetServiceBinaryPath '${TRI_SVC_NAME}' Pop $0 ; returns an errorcode (<>0) otherwise success (0) Pop $1 ; returns the binary path of the service ; $1 should contain '"$INSTDIR\${SBIN_DIR}\arangod.exe" --start-service' - if $INSTDIR is equal ; to our $INSTDIR uninstall the service - else its another installation and we jump to Done instead. ; MessageBox MB_OK ' current service: $1 ---- "$INSTDIR\${SBIN_DIR}\arangod.exe"' StrCmp $1 '"$INSTDIR\${SBIN_DIR}\arangod.exe" --start-service' '' Done DetailPrint 'Shutting down Service ${TRI_SVC_NAME}' SimpleSC::StopService '${TRI_SVC_NAME}' 0 30 Call un.WaitForServiceDown DetailPrint 'Removing ArangoDB Service' SimpleSC::RemoveService '${TRI_SVC_NAME}' Pop $0 ; returns an errorcode (<>0) otherwise success (0) IntCmp $0 0 Done Push $0 SimpleSC::GetErrorMessage Pop $0 DetailPrint 'Stopping ArangoDB fails - Reason: $0' MessageBox MB_OK 'Stopping ArangoDB fails - Reason: $0' ${Else} IfFileExists "$DATADIR/LOCK" 0 +2 MessageBox MB_ICONEXCLAMATION "Please shut down ArangoDB before continuing with the uninstallation!" ${EndIf} Done: DetailPrint 'Removing files' Delete "$INSTDIR\etc\arangodb3\arangod.conf.old" StrCmp $PURGE_DB "0" dontDeleteDatabases DetailPrint 'Removing database files from $DATADIR: ' RMDir /r "$DATADIR" DetailPrint 'Removing Foxx services files from $APPDIR: ' RMDir /r "$APPDIR" RMDir /r "$INSTDIR\var\lib\arangodb3-apps" RMDir "$INSTDIR\var\lib" RMDir /r "$INSTDIR\var\log\arangodb3" dontDeleteDatabases: DetailPrint 'Removing programm files:' DetailPrint " RMDir $INSTDIR\usr\share\arangodb3\js\node\node_modules\graphql-sync" ;Remove files we installed. ;Keep the list of directories here in sync with the File commands above. @CPACK_NSIS_DELETE_FILES@ @CPACK_NSIS_DELETE_DIRECTORIES@ ;Remove the uninstaller itself. Delete "$INSTDIR\Uninstall.exe" DeleteRegKey SHCTX "${TRI_UNINSTALL_REG_PATH}" DeleteRegKey HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" ;Remove the installation directory if it is empty. RMDir "$INSTDIR" ; Remove the registry entries. DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" ; Removes all optional components !insertmacro SectionList "RemoveSection_CPack" !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" ; Note, short cuts are created in $SMPROGRAMS\$STARTMENU_FOLDER but ; they are deleted from '$SMPROGRAMS\$MUI_TEMP' Delete '$SMPROGRAMS\$MUI_TEMP\Arango Server.lnk' Delete '$SMPROGRAMS\$MUI_TEMP\Arango Shell.lnk' ;Delete empty start menu parent diretories StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" startMenuDeleteLoop: ClearErrors RMDir $MUI_TEMP GetFullPathName $MUI_TEMP "$MUI_TEMP\.." IfErrors startMenuDeleteLoopDone StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop startMenuDeleteLoopDone: ; If the user changed the shortcut, then untinstall may not work. This should ; try to fix it. StrCpy $MUI_TEMP "$START_MENU" Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" ; Note, short cuts are created in $SMPROGRAMS\$STARTMENU_FOLDER but ; they are deleted from '$SMPROGRAMS\$MUI_TEMP' Delete '$SMPROGRAMS\$MUI_TEMP\Arango Server.lnk' Delete '$SMPROGRAMS\$MUI_TEMP\Arango Shell.lnk' ;Delete empty start menu parent diretories StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" secondStartMenuDeleteLoop: ClearErrors RMDir $MUI_TEMP GetFullPathName $MUI_TEMP "$MUI_TEMP\.." IfErrors secondStartMenuDeleteLoopDone StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop secondStartMenuDeleteLoopDone: DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" ; Delete flag which controls if ArangoDB is started as service or not ${If} ${UAC_IsInnerInstance} DeleteRegKey HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" ${Else} DeleteRegKey HKCU "Software\@CPACK_NSIS_PACKAGE_NAME@" ${EndIf} DeleteRegKey HKLM "${TRI_UNINSTALL_REG_PATH}" ${If} $ADD_TO_PATH == 1 !InsertMacro un.RemoveFromPath "$INSTDIR/${BIN_DIR}" ${EndIf} SectionEnd ;-------------------------------- ; determine admin versus local install ; Is install for "AllUsers" or "JustMe"? ; Default to "JustMe" - set to "AllUsers" if admin ; This function is used for the very first "custom page" of the installer. ; This custom page does not show up visibly, but it executes prior to the ; first visible page and sets up $INSTDIR properly... ; Choose different default installation folder based on SV_ALLUSERS... ; "Program Files" for AllUsers, "My Documents" for JustMe... var CMDINSTDIR Function .onInit ; are we allowed to install admin in first place? !insertmacro determine_possible_install_scope ${GetParameters} $R0 ClearErrors ${GetOptions} $R0 "/INSTALL_SCOPE_ALL=" $0 ${If} $0 == "1" StrCpy $TRI_INSTALL_SCOPE_ALL "1" StrCpy $TRI_INSTALL_SERVICE "1" ${Else} StrCpy $TRI_INSTALL_SCOPE_ALL "0" StrCpy $TRI_INSTALL_SERVICE "0" ${EndIf} !insertmacro determineInstallScope 1 ${GetParameters} $R0 ClearErrors ${GetOptions} $R0 "/PASSWORD=" $PASSWORD IfErrors 0 +2 ReadEnvStr $PASSWORD PASSWORD # we only want to manipulate INSTDIR here if /INSTDIR is really set! ${GetParameters} $R0 ClearErrors ${GetOptions} $R0 "/INSTDIR=" $CMDINSTDIR IfErrors noInstDir 0 IfSilent 0 noInstDir # If not silent, empty inst dir isn't important here. StrCpy $INSTDIR "$CMDINSTDIR" StrLen $0 "$INSTDIR" ${If} $0 < 3 MessageBox MB_OK 'Refusing to install flat on drive "$INSTDIR"' Abort ${EndIf} noInstDir: # we only want to manipulate APPDIR here if /APPDIR is really set! ${GetParameters} $R0 ClearErrors ${GetOptions} $R0 "/APPDIR=" $CMDINSTDIR IfErrors +2 0 StrCpy $APPDIR "$CMDINSTDIR" # we only want to manipulate DATABASEDIR here if /DATABASEDIR is really set! ${GetParameters} $R0 ClearErrors ${GetOptions} $R0 "/DATABASEDIR=" $CMDINSTDIR IfErrors +2 0 StrCpy $DATADIR "$CMDINSTDIR" ${GetParameters} $R0 ClearErrors ${GetOptions} $R0 "/STORAGE_ENGINE=" $STORAGE_ENGINE IfErrors 0 +2 StrCpy $STORAGE_ENGINE "auto" ${GetParameters} $R0 ${GetOptions} $R0 "/DESKTOPICON=" $ADD_DESKTOP_ICON IfErrors 0 +2 StrCpy $ADD_DESKTOP_ICON "1" ${GetParameters} $R0 ClearErrors ${GetOptions} $R0 "/PATH=" $ADD_TO_PATH IfErrors 0 +2 StrCpy $ADD_TO_PATH "0" StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst ReadRegStr $0 HKLM "${TRI_UNINSTALL_REG_PATH}" "UninstallString" StrCmp $0 "" inst MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \ "@CPACK_NSIS_PACKAGE_NAME@ is already installed.$\r$\n$\r$\nDo you want to uninstall the old version before installing the new one?" \ IDYES uninst IDNO inst Abort ;Run the uninstaller uninst: ClearErrors StrLen $2 "\Uninstall.exe" StrCpy $3 $0 -$2 ; remove "\Uninstall.exe" from UninstallString to get path ExecWait '$0 _?=$3' ;Do not copy the uninstaller to a temp file IfErrors uninst_failed inst uninst_failed: MessageBox MB_OK|MB_ICONSTOP "Uninstall failed." Abort inst: ; Reads components status for registry !insertmacro SectionList "InitSection" ; check to see if /D has been used to change ; the install directory by comparing it to the ; install directory that is expected to be the ; default StrCpy $IS_DEFAULT_INSTALLDIR 0 StrCmp "$INSTDIR" "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2 StrCpy $IS_DEFAULT_INSTALLDIR 1 StrCpy $SV_ALLUSERS "JustMe" ; if default install dir then change the default ; if it is installed for JustMe StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2 StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@" ClearErrors UserInfo::GetName IfErrors noLM Pop $0 UserInfo::GetAccountType Pop $1 StrCmp $1 "Admin" 0 +4 SetShellVarContext all ;MessageBox MB_OK 'User "$0" is in the Admin group' StrCpy $SV_ALLUSERS "AllUsers" Goto done StrCmp $1 "Power" 0 +4 SetShellVarContext all ;MessageBox MB_OK 'User "$0" is in the Power Users group' StrCpy $SV_ALLUSERS "AllUsers" Goto done noLM: StrCpy $SV_ALLUSERS "AllUsers" ;MessageBox MB_OK 'noLM' ;Get installation folder from registry if available done: StrCmp $SV_ALLUSERS "AllUsers" 0 +3 StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2 StrCpy $INSTDIR "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage ; !insertmacro INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini" noOptionsPage: FunctionEnd