1
0
Fork 0
arangodb/Installation/Windows/Templates/NSIS.template.in

1416 lines
44 KiB
Plaintext
Executable File

; 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'
!addplugindir '@CPACK_PLUGIN_PATH@/SharedMemory/Plugins'
!addincludedir '@CPACK_PLUGIN_PATH@/UAC-plug-in-NSIS'
;--------------------------------
; Include LogicLib for more readable code
!include "LogicLib.nsh"
!include "UAC.nsh"
!include nsDialogs.nsh
!include WinMessages.nsh
;--------------------------------
; You must define these values
!define VERSION "@CPACK_PACKAGE_VERSION@"
!define PATCH "@CPACK_PACKAGE_VERSION_PATCH@"
!define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
;--------------------------------
; custom defines for the DRY people of us.
!define TRI_UNINSTALL_REG_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@";
!define TRI_SVC_NAME 'ArangoDB'
; Put some of the more custom ones in from the CMakeFile:
@CPACK_ARANGODB_NSIS_DEFINES@
;--------------------------------
;Variables
!define EMPTY ""
var retryCount
Var MUI_TEMP
Var STARTMENU_FOLDER
Var SV_ALLUSERS
Var START_MENU
Var DO_NOT_ADD_TO_PATH
Var ADD_TO_PATH_ALL_USERS
Var ADD_TO_PATH_CURRENT_USER
Var INSTALL_DESKTOP
Var IS_DEFAULT_INSTALLDIR
Var PASSWORD
Var PASSWORD_AGAIN
; Variables for definition of instdir
; posible values: SingleUser | AllUsers | Service
VAR TRI_INSTALL_TYPE
!define TEMP1 $R0 ;Temp variable
;--------------------------------
;Include Modern UI
!include "MUI.nsh"
;Default installation folder
InstallDir "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
;--------------------------------
; Open a URL in a browser.
; http://nsis.sourceforge.net/Open_link_in_new_browser_window
Function openLinkNewWindow
Push $3
Exch
Push $2
Exch
Push $1
Exch
Push $0
Exch
ReadRegStr $0 HKCR "http\shell\open\command" ""
# Get browser path
DetailPrint $0
StrCpy $2 '"'
StrCpy $1 $0 1
StrCmp $1 $2 +2 # if path is not enclosed in " look for space as final char
StrCpy $2 ' '
StrCpy $3 1
loop:
StrCpy $1 $0 1 $3
DetailPrint $1
StrCmp $1 $2 found
StrCmp $1 "" found
IntOp $3 $3 + 1
Goto loop
found:
StrCpy $1 $0 $3
StrCmp $2 " " +2
StrCpy $1 '$1"'
Pop $0
Exec '$1 $0'
Pop $0
Pop $1
Pop $2
Pop $3
FunctionEnd
!macro _OpenURL URL
Push "${URL}"
Call openLinkNewWindow
!macroend
!define OpenURL '!insertmacro "_OpenURL"'
;--------------------------------
;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
Function disableBackButton
GetDlgItem $0 $HWNDParent 3
EnableWindow $0 0
FunctionEnd
Function Tri_ChangePrivileges
${IfNot} ${UAC_IsInnerInstance}
Call disableBackButton
GetDlgItem $0 $HWNDParent 2
EnableWindow $0 0
GetDlgItem $0 $HWNDParent 1
EnableWindow $0 0
${EndIf}
uac_tryagain:
!insertmacro UAC_RunElevated
${Switch} $0
${Case} 0
${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done
${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on
${If} $1 = 3 ;RunAs completed successfully, but with a non-admin user
MessageBox mb_YesNo|mb_IconExclamation|mb_TopMost|mb_SetForeground "Administrator privileges required, plesae try again" /SD IDNO IDYES uac_tryagain IDNO 0
${EndIf}
;fall-through and die
${Case} 1223
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Administrator privileges required, aborting!"
Quit
${Case} 1062
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!"
Quit
${Default}
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate, error $0"
Quit
${EndSwitch}
SetShellVarContext all
FunctionEnd
; same aagin for uninstall - NSIS requires the function name have to have 'un.' - prefix
Function un.Tri_ChangePrivileges
uac_tryagain:
!insertmacro UAC_RunElevated
${Switch} $0
${Case} 0
${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done
${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on
${If} $1 = 3 ;RunAs completed successfully, but with a non-admin user
MessageBox mb_YesNo|mb_IconExclamation|mb_TopMost|mb_SetForeground "Administrator privileges required, plesae try again" /SD IDNO IDYES uac_tryagain IDNO 0
${EndIf}
;fall-through and die
${Case} 1223
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Administrator privileges required, aborting!"
Quit
${Case} 1062
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!"
Quit
${Default}
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate, error $0"
Quit
${EndSwitch}
SetShellVarContext all
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
!define MUI_ABORTWARNING
;--------------------------------
; path functions
!verbose 3
!include "WinMessages.NSH"
!verbose 4
;----------------------------------------
; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02"
;----------------------------------------
!verbose 3
!include "WinMessages.NSH"
!verbose 4
;====================================================
; get_NT_environment
; Returns: the selected environment
; Output : head of the stack
;====================================================
!macro select_NT_profile UN
Function ${UN}select_NT_profile
StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 environment_single
DetailPrint "Selected environment for all users"
Push "all"
Return
environment_single:
DetailPrint "Selected environment for current user only."
Push "current"
Return
FunctionEnd
!macroend
!insertmacro select_NT_profile ""
!insertmacro select_NT_profile "un."
;----------------------------------------------------
!define NT_current_env 'HKCU "Environment"'
!define NT_all_env 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
!ifndef WriteEnvStr_RegKey
!ifdef ALL_USERS
!define WriteEnvStr_RegKey \
'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
!else
!define WriteEnvStr_RegKey 'HKCU "Environment"'
!endif
!endif
; AddToPath - Adds the given dir to the search path.
; Input - head of the stack
; Note - Win9x systems requires reboot
Function AddToPath
Exch $0
Push $1
Push $2
Push $3
# don't add if the path doesn't exist
IfFileExists "$0\*.*" "" AddToPath_done
ReadEnvStr $1 PATH
; if the path is too long for a NSIS variable NSIS will return a 0
; length string. If we find that, then warn and skip any path
; modification as it will trash the existing path.
StrLen $2 $1
IntCmp $2 0 CheckPathLength_ShowPathWarning CheckPathLength_Done CheckPathLength_Done
CheckPathLength_ShowPathWarning:
Messagebox MB_OK|MB_ICONEXCLAMATION "Warning! Your PATH environment is already to long; the installer unable to add ArangoDB to it."
Goto AddToPath_done
CheckPathLength_Done:
Push "$1;"
Push "$0;"
Call StrStr
Pop $2
StrCmp $2 "" "" AddToPath_done
Push "$1;"
Push "$0\;"
Call StrStr
Pop $2
StrCmp $2 "" "" AddToPath_done
GetFullPathName /SHORT $3 $0
Push "$1;"
Push "$3;"
Call StrStr
Pop $2
StrCmp $2 "" "" AddToPath_done
Push "$1;"
Push "$3\;"
Call StrStr
Pop $2
StrCmp $2 "" "" AddToPath_done
StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey
ReadRegStr $1 ${NT_current_env} "PATH"
Goto DoTrim
ReadAllKey:
ReadRegStr $1 ${NT_all_env} "PATH"
DoTrim:
StrCmp $1 "" AddToPath_NTdoIt
Push $1
Call Trim
Pop $1
StrCpy $0 "$1;$0"
AddToPath_NTdoIt:
StrCmp $ADD_TO_PATH_ALL_USERS "1" WriteAllKey
WriteRegExpandStr ${NT_current_env} "PATH" $0
Goto DoSend
WriteAllKey:
WriteRegExpandStr ${NT_all_env} "PATH" $0
DoSend:
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
AddToPath_done:
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd
; RemoveFromPath - Remove a given dir from the path
; Input: head of the stack
Function un.RemoveFromPath
Exch $0
Push $1
Push $2
Push $3
Push $4
Push $5
Push $6
IntFmt $6 "%c" 26 # DOS EOF
StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey
ReadRegStr $1 ${NT_current_env} "PATH"
Goto unDoTrim
unReadAllKey:
ReadRegStr $1 ${NT_all_env} "PATH"
unDoTrim:
StrCpy $5 $1 1 -1 # copy last char
StrCmp $5 ";" +2 # if last char != ;
StrCpy $1 "$1;" # append ;
Push $1
Push "$0;"
Call un.StrStr ; Find `$0;` in $1
Pop $2 ; pos of our dir
StrCmp $2 "" unRemoveFromPath_done
; else, it is in path
# $0 - path to add
# $1 - path var
StrLen $3 "$0;"
StrLen $4 $2
StrCpy $5 $1 -$4 # $5 is now the part before the path to remove
StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove
StrCpy $3 $5$6
StrCpy $5 $3 1 -1 # copy last char
StrCmp $5 ";" 0 +2 # if last char == ;
StrCpy $3 $3 -1 # remove last char
StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey
WriteRegExpandStr ${NT_current_env} "PATH" $3
Goto unDoSend
unWriteAllKey:
WriteRegExpandStr ${NT_all_env} "PATH" $3
unDoSend:
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
unRemoveFromPath_done:
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Uninstall sutff
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
###########################################
# Utility Functions #
###########################################
; StrStr
; input, top of stack = string to search for
; top of stack-1 = string to search in
; output, top of stack (replaces with the portion of the string remaining)
; modifies no other variables.
;
; Usage:
; Push "this is a long ass string"
; Push "ass"
; Call StrStr
; Pop $R0
; ($R0 at this point is "ass string")
!macro StrStr un
Function ${un}StrStr
Exch $R1 ; st=haystack,old$R1, $R1=needle
Exch ; st=old$R1,haystack
Exch $R2 ; st=old$R1,old$R2, $R2=haystack
Push $R3
Push $R4
Push $R5
StrLen $R3 $R1
StrCpy $R4 0
; $R1=needle
; $R2=haystack
; $R3=len(needle)
; $R4=cnt
; $R5=tmp
loop:
StrCpy $R5 $R2 $R3 $R4
StrCmp $R5 $R1 done
StrCmp $R5 "" done
IntOp $R4 $R4 + 1
Goto loop
done:
StrCpy $R1 $R2 "" $R4
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Exch $R1
FunctionEnd
!macroend
!insertmacro StrStr ""
!insertmacro StrStr "un."
Function Trim ; Added by Pelaca
Exch $R1
Push $R2
Loop:
StrCpy $R2 "$R1" 1 -1
StrCmp "$R2" " " RTrim
StrCmp "$R2" "$\n" RTrim
StrCmp "$R2" "$\r" RTrim
StrCmp "$R2" ";" RTrim
GoTo Done
RTrim:
StrCpy $R1 "$R1" -1
Goto Loop
Done:
Pop $R2
Exch $R1
FunctionEnd
Function ConditionalAddToRegistry
Pop $0
Pop $1
StrCmp "$0" "" ConditionalAddToRegistry_EmptyString
WriteRegStr SHCTX "${TRI_UNINSTALL_REG_PATH}" "$1" "$0"
;MessageBox MB_OK "Set Registry: '$1' to '$0'"
DetailPrint "Set install registry entry: '$1' to '$0'"
ConditionalAddToRegistry_EmptyString:
FunctionEnd
;--------------------------------
Function WaitForServiceUp
Push 0
Pop $retryCount
try_again:
SimpleSC::ServiceIsRunning '${TRI_SVC_NAME}'
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
Pop $1 ; returns 1 (service is running) - returns 0 (service is not running)
${If} $1 == 1
;MessageBox MB_OK "Service running : $retryCount "
; ok, running now.
Return
${EndIf}
Sleep 1000
${If} $retryCount == 40
MessageBox MB_OK "Service waiting retry count reached"
Return
${EndIf}
IntOp $retryCount $retryCount + 1
Goto try_again
FunctionEnd
;--------------------------------
Function WaitForServiceDown
Push 0
Pop $retryCount
try_again:
SimpleSC::ServiceIsRunning '${TRI_SVC_NAME}'
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
Pop $1 ; returns 1 (service is running) - returns 0 (service is not running)
${If} $1 == 0
;MessageBox MB_OK "Service running : $retryCount "
; ok, running now.
Return
${EndIf}
Sleep 1000
${If} $retryCount == 40
MessageBox MB_OK "Service shutdown waiting retry count reached; you may need to remove files by hand"
Return
${EndIf}
IntOp $retryCount $retryCount + 1
Goto try_again
FunctionEnd
Function un.WaitForServiceDown
Push 0
Pop $retryCount
try_again:
SimpleSC::ServiceIsRunning '${TRI_SVC_NAME}'
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
Pop $1 ; returns 1 (service is running) - returns 0 (service is not running)
${If} $1 == 0
;MessageBox MB_OK "Service running : $retryCount "
; ok, running now.
Return
${EndIf}
Sleep 1000
${If} $retryCount == 40
MessageBox MB_OK "Service shutdown waiting retry count reached; you may need to remove files by hand"
Return
${EndIf}
IntOp $retryCount $retryCount + 1
Goto try_again
FunctionEnd
;--------------------------------
!ifdef CPACK_USES_DOWNLOAD
Function DownloadFile
IfFileExists $INSTDIR\* +2
CreateDirectory $INSTDIR
Pop $0
; Skip if already downloaded
IfFileExists $INSTDIR\$0 0 +2
Return
StrCpy $1 "@CPACK_DOWNLOAD_SITE@"
try_again:
NSISdl::download "$1/$0" "$INSTDIR\$0"
Pop $1
StrCmp $1 "success" success
StrCmp $1 "Cancelled" cancel
MessageBox MB_OK "Download failed: $1"
cancel:
Return
success:
FunctionEnd
!endif
;--------------------------------
; 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@
@CPACK_NSIS_INSTALLER_ICON_CODE@
@CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@
@CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@
;--------------------------------
;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 InstallOptionsPage skip_page
!define MUI_PAGE_CUSTOMFUNCTION_PRE default_installation_directory
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE check_installation_directory
!insertmacro MUI_PAGE_DIRECTORY
;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_LEAVE insert_registration_keys
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!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"
;--------------------------------
;Reserve Files
;These files should be inserted before other files in the data block
;Keep these lines before any File command
;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
ReserveFile "NSIS.InstallOptions.ini"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
;--------------------------------
;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
; this variable was defined by eld and included in NSIS.template.in
; we probably need this for the install/uninstall software list.
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"
Push "DisplayName"
Push "@CPACK_NSIS_DISPLAY_NAME@"
Call ConditionalAddToRegistry
Push "DisplayVersion"
Push "@CPACK_PACKAGE_VERSION@"
Call ConditionalAddToRegistry
Push "Publisher"
Push "@CPACK_PACKAGE_VENDOR@"
Call ConditionalAddToRegistry
Push "UninstallString"
Push "$INSTDIR\Uninstall.exe"
Call ConditionalAddToRegistry
Push "NoRepair"
Push "1"
Call ConditionalAddToRegistry
!ifdef CPACK_NSIS_ADD_REMOVE
;Create add/remove functionality
Push "ModifyPath"
Push "$INSTDIR\AddRemove.exe"
Call ConditionalAddToRegistry
!else
Push "NoModify"
Push "1"
Call ConditionalAddToRegistry
!endif
; Optional registration
Push "DisplayIcon"
Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@"
Call ConditionalAddToRegistry
Push "HelpLink"
Push "@CPACK_NSIS_HELP_LINK@"
Call ConditionalAddToRegistry
Push "URLInfoAbout"
Push "@CPACK_NSIS_URL_INFO_ABOUT@"
Call ConditionalAddToRegistry
Push "Contact"
Push "@CPACK_NSIS_CONTACT@"
Call ConditionalAddToRegistry
!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
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Arango Server.lnk" "$INSTDIR\${SBIN_DIR}\arangod.exe" '' '$INSTDIR\resources\arangodb.ico' '0' SW_SHOWMAXIMIZED
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
;Read a value from an InstallOptions INI file
StrCmp "0" "$INSTALL_DESKTOP" 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
noDesktopIcon:
; Write special uninstall registry entries
Push "StartMenu"
Push "$STARTMENU_FOLDER"
Call ConditionalAddToRegistry
Push "DoNotAddToPath"
Push "$DO_NOT_ADD_TO_PATH"
Call ConditionalAddToRegistry
Push "AddToPathAllUsers"
Push "$ADD_TO_PATH_ALL_USERS"
Call ConditionalAddToRegistry
Push "AddToPathCurrentUser"
Push "$ADD_TO_PATH_CURRENT_USER"
Call ConditionalAddToRegistry
Push "InstallToDesktop"
Push "$INSTALL_DESKTOP"
Call ConditionalAddToRegistry
!insertmacro MUI_STARTMENU_WRITE_END
System::Call 'Kernel32::SetEnvironmentVariable(t, t)i ("ARANGODB_DEFAULT_ROOT_PASSWORD", "$PASSWORD").r0'
StrCmp $0 0 error
ExecWait "$INSTDIR\${SBIN_DIR}\arangod.exe --database.init-database"
Goto done
error:
MessageBox MB_OK "Failed to initialize database password."
done:
@CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
StrCmp $TRI_INSTALL_TYPE 'Service' 0 nothing
SimpleSC::StopService '${TRI_SVC_NAME}' 0 30
Call WaitForServiceDown
SimpleSC::RemoveService '${TRI_SVC_NAME}'
SimpleSC::InstallService '${TRI_SVC_NAME}' '${TRI_SVC_NAME}' '16' '2' '"$INSTDIR\${SBIN_DIR}\arangod.exe" --start-service' '' '' ''
SimpleSC::SetServiceDescription '${TRI_SVC_NAME}' '${TRI_FRIENDLY_SVC_NAME}'
SimpleSC::StartService '${TRI_SVC_NAME}' '' 30
Call WaitForServiceUp
nothing:
SectionEnd
Function .onInstSuccess
${If} $TRI_INSTALL_TYPE == 'Service'
${OpenURL} ${TRI_AARDVARK_URL}
${EndIf}
FunctionEnd
Section "-Add to path"
Push "$INSTDIR/${BIN_DIR}"
StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath
StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0
Call AddToPath
doNotAddToPath:
SectionEnd
;--------------------------------
; Create custom pages
Function InstallOptionsPage
Push ${TEMP1}
displayAgain:
!insertmacro MUI_HEADER_TEXT "Install Options" "Choose options for installing @CPACK_NSIS_PACKAGE_NAME@"
!insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
!insertmacro MUI_INSTALLOPTIONS_READ $PASSWORD "NSIS.InstallOptions.ini" "Field 6" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $PASSWORD_AGAIN "NSIS.InstallOptions.ini" "Field 7" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State"
StrCmp $PASSWORD $PASSWORD_AGAIN +3 0
MessageBox MB_OK|MB_ICONSTOP "Passwords don't match, try again"
Goto displayAgain
done:
Pop ${TEMP1}
Return
FunctionEnd
;------------------------
; Create
Function ArangoPreInstallationOptionsPage
!insertmacro MUI_HEADER_TEXT "@CPACK_NSIS_PACKAGE_NAME@ als Service?" "Install @CPACK_NSIS_PACKAGE_NAME@ as a service?"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.ArangoDB.ini"
FunctionEnd
;--------------------------------
Function skip_page
${If} ${UAC_IsInnerInstance}
Abort
${EndIf}
FunctionEnd
; when I am a child proces
; I read the state (from shared memory) of the install options page
; these informations has to be written by the father process
Function read_options
${If} ${UAC_IsInnerInstance}
sharedmem::ReadIntoSharedMem
pop $0
pop $1
${If} $0 == 0
StrCpy $TRI_INSTALL_TYPE $1
${Else}
; when something is wrong arango is installed as Service
StrCpy $TRI_INSTALL_TYPE 'Service'
${EndIf}
${EndIf}
FunctionEnd
;--------------------------------
Function default_installation_directory
; Read variables which defines if arango should be installed as Service
${If} ${UAC_IsInnerInstance}
Call disableBackButton
${EndIf}
${IfNot} ${UAC_IsInnerInstance}
!insertmacro MUI_INSTALLOPTIONS_READ $R2 "NSIS.InstallOptions.ini" "Field 2" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R3 "NSIS.InstallOptions.ini" "Field 3" "State"
!insertmacro MUI_INSTALLOPTIONS_READ $R4 "NSIS.InstallOptions.ini" "Field 4" "State"
${If} $R2 == '1'
StrCpy $TRI_INSTALL_TYPE 'Service'
${EndIf}
${If} $R3 == '1'
StrCpy $TRI_INSTALL_TYPE 'AllUsers'
${EndIf}
${If} $R4 == '1'
StrCpy $TRI_INSTALL_TYPE 'SingleUser'
${EndIf}
sharedmem::WriteIntoSharedMem $TRI_INSTALL_TYPE
pop $0
; $0 should be '0'
; this value is read by child process
${Else}
Call read_options
${EndIf}
${Switch} $TRI_INSTALL_TYPE
${Case} 'Service'
Call Tri_ChangePrivileges
SetShellVarContext all
;MessageBox MB_OK "Service : $INSTDIR"
${Break}
${Case} 'SingleUser'
SetShellVarContext current
StrCpy $INSTDIR "$LOCALAPPDATA\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
;MessageBox MB_OK "SingleUser : $INSTDIR"
${Break}
${Case} 'AllUsers'
Call Tri_ChangePrivileges
SetShellVarContext all
StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
;MessageBox MB_OK "AllUsers : $INSTDIR"
${Break}
${EndSwitch}
Return
FunctionEnd
Function assign_proper_access_rights
StrCpy $0 "0"
AccessControl::GrantOnFile \
"$INSTDIR" "(BU)" "GenericRead + GenericWrite + GenericExecute"
Pop $R0
${If} $R0 == error
Pop $R0
StrCpy $0 "1"
DetailPrint `AccessControl error: $R0`
; MessageBox MB_OK "target directory $INSTDIR can not get cannot get correct access rigths"
${EndIf}
FunctionEnd
Function is_writable
; is does not matter if we do some errors here
${If} $TRI_INSTALL_ALL_USERS == '1'
CreateDirectory $INSTDIR
Call assign_proper_access_rights
${EndIf}
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 arango in $INSTDIR do you want try once more?" IDNO no
Abort
no: Quit
FunctionEnd
Function insert_registration_keys
ClearErrors
; MessageBox MB_OK "XXXX insert_registration_keys in HKCC ${BITS}"
${Switch} $TRI_INSTALL_TYPE
${Case} 'Service'
WriteRegExpandStr HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "type" 'Service'
; MessageBox MB_OK "Sevice in HKCC"
IfErrors there_are_erros
${Break}
${Case} 'SingleUser'
${If} ${UAC_IsAdmin}
WriteRegExpandStr HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "type" 'SingleUser'
; MessageBox MB_OK "SingleUser in HKCC"
${Else}
; normal user has not write rights to HKCC
WriteRegExpandStr HKCU "Software\@CPACK_NSIS_PACKAGE_NAME@" "type" 'SingleUser'
; MessageBox MB_OK "SingleUser in HKCU"
IfErrors there_are_erros
${EndIf}
${Break}
${Case} 'AllUsers'
WriteRegExpandStr HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "type" 'Service'
StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
; MessageBox MB_OK "AllUsers in HKCC"
IfErrors there_are_erros
${Break}
${EndSwitch}
Return
there_are_erros: ;nothing
MessageBox MB_OK "There was an error during adding the installation keys to the registry$\nArango will work fine but there may be trouble during the deinstallation$\nplease contact @CPACK_NSIS_CONTACT@"
FunctionEnd
!macro triagens_init
${If} ${UAC_IsInnerInstance}
; memory segment is created by father process
; nothing to do
SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:Hallo"
return
${EndIf}
sharedmem::ExistsSharedMem
pop $0
${If} $0 == '1'
MessageBox MB_OK "Installer is already running"
Quit
${EndIf}
sharedmem::CreateSharedMemory
pop $0
${Switch} $0
${Case} 0
; shared memory was created
; return
${Case} 5
; what is to do, memory segment could no be created ?
${EndSwitch}
; SetShellVarContext all
!macroend
;--------------------------------
; determine admin versus local install
Function un.onInit
; ClearErrors
; UserInfo::GetName
; IfErrors noLM
; Pop $0
; UserInfo::GetAccountType
; Pop $1
; StrCmp $1 "Admin" 0 +3
; SetShellVarContext all
; MessageBox MB_OK 'User "$0" is in the Admin group'
; Goto done
; StrCmp $1 "Power" 0 +3
; SetShellVarContext all
; MessageBox MB_OK 'User "$0" is in the Power Users group'
; Goto done
;
; noLM:
; ;Get installation folder from registry if available
;
; done:
; determine admin versus local install
; arango may be installed on diferent places
; determine if the arango was installed for a local user
Pop $0
; temporary variable used as flag for decide the change to administration rights
StrCpy $R0 "admin"
${If} ${UAC_IsAdmin}
ReadRegStr $0 HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "type"
${Else}
; see function default_installation_directory
ReadRegStr $0 HKCU "Software\@CPACK_NSIS_PACKAGE_NAME@" "type"
${If} $0 == "SingleUser"
StrCpy $R0 "user"
${EndIf}
${EndIf}
${If} $R0 == "admin"
Call un.Tri_ChangePrivileges
${EndIf}
; are we a child process?
; when yes, we have administrator privileges
${If} ${UAC_IsInnerInstance}
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"
!ifdef CPACK_NSIS_ADD_REMOVE
; Get the name of the installer executable
System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
StrCpy $R3 $R0
; Strip off the last 13 characters, to see if we have AddRemove.exe
StrLen $R1 $R0
IntOp $R1 $R0 - 13
StrCpy $R2 $R0 13 $R1
StrCmp $R2 "AddRemove.exe" addremove_installed
; We''re not running AddRemove.exe, so install it
CopyFiles $R3 $INSTDIR\AddRemove.exe
addremove_installed:
!endif
SectionEnd
;--- End of Add/Remove callback functions ---
;--------------------------------
; Component dependencies
Function .onSelChange
!insertmacro SectionList MaybeSelectionChanged
FunctionEnd
;--------------------------------
;Uninstaller Section
Section "Uninstall"
; 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.
SetRegView ${BITS}
; A single user isn''t in HKCC...
StrCpy $TRI_INSTALL_TYPE 'SingleUser'
ReadRegStr $TRI_INSTALL_TYPE HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "type"
;MessageBox MB_OK "Type: $TRI_INSTALL_TYPE"
${If} $TRI_INSTALL_TYPE == 'Service'
Call un.Tri_ChangePrivileges
SetShellVarContext all
;MessageBox MB_OK "Service : $INSTDIR"
${EndIf}
${If} $TRI_INSTALL_TYPE == 'AllUsers'
Call un.Tri_ChangePrivileges
SetShellVarContext all
StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
;MessageBox MB_OK "AllUsers : $INSTDIR"
${EndIf}
ReadRegStr $START_MENU SHCTX "${TRI_UNINSTALL_REG_PATH}" "StartMenu"
;MessageBox MB_OK "Start menu is in: $START_MENU"
ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX "${TRI_UNINSTALL_REG_PATH}" "DoNotAddToPath"
ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX "${TRI_UNINSTALL_REG_PATH}" "AddToPathAllUsers"
ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX "${TRI_UNINSTALL_REG_PATH}" "AddToPathCurrentUser"
;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS"
ReadRegStr $INSTALL_DESKTOP SHCTX "${TRI_UNINSTALL_REG_PATH}" "InstallToDesktop"
;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP "
StrCmp "0" "$INSTALL_DESKTOP" noDesktopIconRemove
Delete "$DESKTOP\Arango Shell.lnk"
Delete "$DESKTOP\Arango Management Interface.lnk"
noDesktopIconRemove:
;MessageBox MB_OK "Deleting Directory: $SMPROGRAMS\$START_MENU\ $TRI_INSTALL_TYPE "
Delete "$SMPROGRAMS\$START_MENU"
StrCmp $TRI_INSTALL_TYPE 'Service' 0 nothing
;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.
StrCmp $1 '"$INSTDIR/${SBIN_DIR}/arangod.exe" --start-service' '' Done
DetailPrint 'Shutting down Service'
SimpleSC::StopService '${TRI_SVC_NAME}' 0 30
Call un.WaitForServiceDown
SimpleSC::RemoveService '${TRI_SVC_NAME}'
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
IntCmp $0 0 Done +1 +1
Push $0
SimpleSC::GetErrorMessage
Pop $0
MessageBox MB_OK 'Stopping ArangoDB fails - Reason: $0'
Done:
nothing:
DetailPrint 'Removing files'
;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@
!ifdef CPACK_NSIS_ADD_REMOVE
;Remove the add/remove program
Delete "$INSTDIR\AddRemove.exe"
!endif
;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 arango is started as service or no
${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}"
Push "$INSTDIR/${BIN_DIR}"
StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0
Call un.RemoveFromPath
doNotRemoveFromPath:
SectionEnd
;--------------------------------
; determine admin versus local install
; Is install for "AllUsers" or "JustMe"?
; Default to "JustMe" - set to "AllUsers" if admin or on Win9x
; 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...
Function .onInit
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. $\n$\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:
!insertmacro triagens_init
; 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 MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"
noOptionsPage:
FunctionEnd