mirror of https://gitee.com/bigwinds/arangodb
code refactoring
This commit is contained in:
parent
2099344317
commit
1d9f15ed8a
|
@ -20,7 +20,7 @@ State=1
|
|||
|
||||
[Field 3]
|
||||
Type=radiobutton
|
||||
Text=Install @@CPACK_PACKAGE_NAME@ as service into a configurable directory
|
||||
Text=Install @@CPACK_PACKAGE_NAME@ for all users
|
||||
Left=0
|
||||
Right=-1
|
||||
Top=40
|
||||
|
|
|
@ -31,9 +31,8 @@
|
|||
Var INSTALL_DESKTOP
|
||||
Var IS_DEFAULT_INSTALLDIR
|
||||
; Variables for definition of instdir
|
||||
VAR TRI_INSTALL_AS_SERVICE
|
||||
VAR TRI_INSTALL_ALL_USERS
|
||||
VAR TRI_INSTALL_SINGLE_USER
|
||||
; posible values: SingleUser | AllUsers | Service
|
||||
VAR TRI_INSTALL_TYPE
|
||||
;--------------------------------
|
||||
;Include Modern UI
|
||||
|
||||
|
@ -64,11 +63,11 @@ ${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 "This ${thing} requires admin privileges, try again" /SD IDNO IDYES uac_tryagain IDNO 0
|
||||
MessageBox mb_YesNo|mb_IconExclamation|mb_TopMost|mb_SetForeground "You need privileges, try again" /SD IDNO IDYES uac_tryagain IDNO 0
|
||||
${EndIf}
|
||||
;fall-through and die
|
||||
${Case} 1223
|
||||
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "This ${thing} requires admin privileges, aborting!"
|
||||
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "You need requires admin privileges, aborting!"
|
||||
Quit
|
||||
${Case} 1062
|
||||
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!"
|
||||
|
@ -769,7 +768,7 @@ Section "-Core installation"
|
|||
|
||||
|
||||
@CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
|
||||
StrCmp $TRI_INSTALL_AS_SERVICE '1' 0 nothing
|
||||
StrCmp $TRI_INSTALL_TYPE 'Service' 0 nothing
|
||||
SimpleSC::StopService 'ArangoDB' 0 30
|
||||
SimpleSC::RemoveService 'ArangoDB'
|
||||
SimpleSC::InstallService 'ArangoDB' 'ArangoDB' '16' '2' '"$INSTDIR\bin\arangod.exe" --start-service' '' '' ''
|
||||
|
@ -810,34 +809,49 @@ FunctionEnd
|
|||
;--------------------------------
|
||||
Function default_installation_directory
|
||||
; Read variables which defines if arango should be installed as Service
|
||||
!insertmacro MUI_INSTALLOPTIONS_READ $TRI_INSTALL_AS_SERVICE "NSIS.InstallOptions.ini" "Field 2" "State"
|
||||
!insertmacro MUI_INSTALLOPTIONS_READ $TRI_INSTALL_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State"
|
||||
!insertmacro MUI_INSTALLOPTIONS_READ $TRI_INSTALL_SINGLE_USER "NSIS.InstallOptions.ini" "Field 4" "State"
|
||||
Pop $R2
|
||||
Pop $R3
|
||||
Pop $R4
|
||||
!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}
|
||||
|
||||
StrCmp $TRI_INSTALL_AS_SERVICE '1' 0 checkSingleUser
|
||||
${If} $R3 == '1'
|
||||
StrCpy $TRI_INSTALL_TYPE 'AllUsers'
|
||||
${EndIf}
|
||||
|
||||
${If} $R4 == '1'
|
||||
StrCpy $TRI_INSTALL_TYPE 'SingleUser'
|
||||
${EndIf}
|
||||
${If} $TRI_INSTALL_TYPE == 'Service'
|
||||
Call Tri_ChangePrivileges
|
||||
WriteRegExpandStr HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "type" "Service"
|
||||
WriteRegExpandStr HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "type" 'Service'
|
||||
SetShellVarContext all
|
||||
Call skip_page
|
||||
Abort
|
||||
checkSingleUser:
|
||||
StrCmp $TRI_INSTALL_SINGLE_USER '1' 0 all_users
|
||||
${EndIf}
|
||||
${If} $TRI_INSTALL_TYPE == 'SingleUser'
|
||||
SetShellVarContext current
|
||||
${If} ${UAC_IsAdmin}
|
||||
WriteRegExpandStr HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "type" "SingleUser"
|
||||
WriteRegExpandStr HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "type" 'SingleUser'
|
||||
${Else}
|
||||
; normal user has not write rights to HKCC
|
||||
WriteRegExpandStr HKCU "Software\@CPACK_NSIS_PACKAGE_NAME@" "type" "SingleUser"
|
||||
WriteRegExpandStr HKCU "Software\@CPACK_NSIS_PACKAGE_NAME@" "type" 'SingleUser'
|
||||
${EndIf}
|
||||
|
||||
StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
|
||||
Return
|
||||
all_users:
|
||||
${EndIf}
|
||||
${If} $TRI_INSTALL_TYPE == 'AllUsers'
|
||||
Call Tri_ChangePrivileges
|
||||
WriteRegExpandStr HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "type" "Service"
|
||||
WriteRegExpandStr HKCC "Software\@CPACK_NSIS_PACKAGE_NAME@" "type" 'Service'
|
||||
SetShellVarContext all
|
||||
StrCpy $TRI_INSTALL_AS_SERVICE '1'
|
||||
StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Function assign_propertly_access_rigths
|
||||
|
@ -882,11 +896,11 @@ ${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 "This ${thing} requires admin privileges, try again" /SD IDNO IDYES uac_tryagain IDNO 0
|
||||
MessageBox mb_YesNo|mb_IconExclamation|mb_TopMost|mb_SetForeground "You need requires admin privileges, try again" /SD IDNO IDYES uac_tryagain IDNO 0
|
||||
${EndIf}
|
||||
;fall-through and die
|
||||
${Case} 1223
|
||||
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "This ${thing} requires admin privileges, aborting!"
|
||||
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "You need requires admin privileges, aborting!"
|
||||
Quit
|
||||
${Case} 1062
|
||||
MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!"
|
||||
|
@ -1009,7 +1023,7 @@ Section "Uninstall"
|
|||
;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP "
|
||||
|
||||
@CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@
|
||||
StrCmp $TRI_INSTALL_AS_SERVICE '1' 0 nothing
|
||||
StrCmp $TRI_INSTALL_TYPE 'Service' 0 nothing
|
||||
SimpleSC::StopService 'ArangoDB' 0 30
|
||||
SimpleSC::RemoveService 'ArangoDB'
|
||||
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
|
||||
|
|
Loading…
Reference in New Issue