From 1d9f15ed8a3dd732867383c826de283ddbde7684 Mon Sep 17 00:00:00 2001 From: = Date: Thu, 10 Apr 2014 17:28:10 +0200 Subject: [PATCH] code refactoring --- .../Templates/NSIS.InstallOptions.ini.in | 2 +- .../Windows/Templates/NSIS.template.in | 56 ++++++++++++------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/Installation/Windows/Templates/NSIS.InstallOptions.ini.in b/Installation/Windows/Templates/NSIS.InstallOptions.ini.in index d07fc53574..f333895c73 100755 --- a/Installation/Windows/Templates/NSIS.InstallOptions.ini.in +++ b/Installation/Windows/Templates/NSIS.InstallOptions.ini.in @@ -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 diff --git a/Installation/Windows/Templates/NSIS.template.in b/Installation/Windows/Templates/NSIS.template.in index f08f443aa2..7edb8c4185 100755 --- a/Installation/Windows/Templates/NSIS.template.in +++ b/Installation/Windows/Templates/NSIS.template.in @@ -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)