From c7ecb3cb648f913fe0086a44b56589bf4adf3293 Mon Sep 17 00:00:00 2001 From: stansmith Date: Thu, 28 Jun 2007 22:58:49 +0000 Subject: [PATCH] [WinOF] DAPLsetup CA, create %SystemDrive%\DAT if needed. git-svn-id: svn://openib.tc.cornell.edu/gen1@730 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- branches/WinOF/WIX/CustomActions.vbs | 144 ++++++++++++++++----------- 1 file changed, 88 insertions(+), 56 deletions(-) diff --git a/branches/WinOF/WIX/CustomActions.vbs b/branches/WinOF/WIX/CustomActions.vbs index cc296562..f7fa5d75 100644 --- a/branches/WinOF/WIX/CustomActions.vbs +++ b/branches/WinOF/WIX/CustomActions.vbs @@ -1,4 +1,4 @@ -' WIX CustomActions used in the WinOF (Windows OpenFabrics) Release +' WIX CustomActions used in the WinOF (Windows OpenFabrics) Release. ' File is based on the file contributed by Mellanox Technologies. Function Architecture() @@ -909,62 +909,94 @@ End Function ' Create OpenSM (Subnet Management) windows service disabled. Sub OpensmServiceEvent() - Dim sInstalldir,opensmPath,opensmService,WshShell,fso - Dim sc, StartMeUp + Dim sInstalldir,opensmPath,opensmService,WshShell,fso + Dim sc, StartMeUp - sInstalldir = Session.Property("INSTALLDIR") - opensmService = sInstalldir & "opensm.service.txt" - opensmPath = sInstalldir & "opensm.exe" + sInstalldir = Session.Property("INSTALLDIR") + opensmService = sInstalldir & "opensm.service.txt" + opensmPath = sInstalldir & "opensm.exe" Set fso = CreateObject("Scripting.FileSystemObject") Set WshShell = CreateObject("WScript.Shell") - ' opensm.exe is required - If Not fso.FileExists(opensmPath) Then - Exit Sub + ' opensm.exe is required + If Not fso.FileExists(opensmPath) Then + Exit Sub End if - sc = "sc.exe create opensm binPath= """ &opensmPath _ - & " -e --service"" DisplayName= ""InfiniBand Subnet Manager"" " + sc = "sc.exe create opensm binPath= """ &opensmPath _ + & " -e --service"" DisplayName= ""InfiniBand Subnet Manager"" " - ' start opesm as a Service? - If fso.FileExists(opensmService) Then - StartMeUp = True - sc = sc & "start= auto" - Else - StartMeUp = False - sc = sc & "start= disabled" + ' start opesm as a Service? + If fso.FileExists(opensmService) Then + StartMeUp = True + sc = sc & "start= auto" + Else + StartMeUp = False + sc = sc & "start= disabled" End if Return = WshShell.Run ("cmd.exe /c " & sc, 0, true) sc = "sc.exe description opensm ""Configures and manage the InfiniBand Subnet"" " Return = WshShell.Run ("cmd.exe /c " & sc, 0, true) ' Is opensm to be run as a service? - If StartMeUp Then + If StartMeUp Then Return = WshShell.Run ("cmd.exe /c sc.exe start opensm", 0, true) - End if - err.clear + End if + err.clear End Sub +' If not present, then create %SystemDrive%\DAT\dat.conf + +Function DAPL_setup() + Dim sSysDrive, DatFolder, SrcFile, WshShell, fso + + Set WshShell = CreateObject("WScript.Shell") + Set fso = CreateObject("Scripting.FileSystemObject") + + DAPL_setup = 0 + Err.clear + + SrcFile = Session.Property("INSTALLDIR") & "dat.conf" + + If fso.FileExists(SrcFile) Then + On Error Resume Next + sSysDrive = Session.Property("WindowsVolume") + ' sSysDrive = WshShell.ExpandEnvironmentStrings("%SystemDrive%") + DatFolder = sSysDrive & "DAT" + If fso.FolderExists(DatFolder) Then + ' Preserve existing %SystemDrive%\DAT + Exit Function + End if + ' create %SystemDrive%\DAT & install dat.conf + fso.CreateFolder DatFolder + If Err Then + ErrMsg "Unable to create folder %SystemDrive%\DAT" + Exit Function + End if + fso.CopyFile SrcFile, DatFolder & "\dat.conf" + End if +End Function + Sub ScheduleReboot - Set objWMILocator = CreateObject ("WbemScripting.SWbemLocator") - objWMILocator.Security_.Privileges.AddAsString "SeShutdownPrivilege",True - Set objWMIServices = objWMILocator.ConnectServer(strComputerName, _ - cWMINameSpace, strUserID, strPassword) - Set objSystemSet = GetObject(_ - "winmgmts:{impersonationLevel=impersonate,(Shutdown)}")._ + Set objWMILocator = CreateObject ("WbemScripting.SWbemLocator") + objWMILocator.Security_.Privileges.AddAsString "SeShutdownPrivilege",True + Set objWMIServices = objWMILocator.ConnectServer(strComputerName, _ + cWMINameSpace, strUserID, strPassword) + Set objSystemSet = GetObject(_ + "winmgmts:{impersonationLevel=impersonate,(Shutdown)}")._ InstancesOf("Win32_OperatingSystem") ' Forced restart - For Each objSystem In objSystemSet - objSystem.Win32Shutdown 2+4 - objSystem.Win32Shutdown 2+4 - objSystem.Win32Shutdown 2+4 - Next + For Each objSystem In objSystemSet + objSystem.Win32Shutdown 2+4 + objSystem.Win32Shutdown 2+4 + objSystem.Win32Shutdown 2+4 + Next - 'msgbox "Please wait while computer restart ...",0,"MellanoxWinIB32" + 'msgbox "Please wait while computer restarts ...",0,"WinOF" End Sub @@ -980,8 +1012,8 @@ Function ChkInstallAndReboot() Const wshYesNoDialog = 4 Const wshQuestionMark = 32 - Dim status ' check if ibbus.sys exists, if not the reboot won't happen - Dim fso, originalReboot + Dim status ' check if ibbus.sys exists, if not the reboot won't happen + Dim fso, originalReboot Set fso = CreateObject("Scripting.FileSystemObject") status = 0 @@ -1003,23 +1035,23 @@ Function ChkInstallAndReboot() Exit Function End if - Dim sys_folder, drv_folder - ' Idea here is to rename driver files to force a driver - ' load failure upon next reboot so ensuing install will - ' succeed. - sys_folder = Session.Property("WindowsFolder") & "system32" - drv_folder = sys_folder & "\drivers" - - If fso.FileExists(drv_folder & "\ibbus.sys") Then - FileMove drv_folder & "\ibbus.sys",drv_folder & "\ibbus.sy1" - End if - If fso.FileExists(drv_folder & "\mthca.sys") Then - FileMove drv_folder & "\mthca.sys",drv_folder & "\mthca.sy1" - End if - If fso.FileExists(sys_folder & "\ibinstaller.dll") Then - FileMove sys_folder & "\ibinstaller.dll",sys_folder & "\ibinstaller1.dll" - End if + Dim sys_folder, drv_folder + ' Idea here is to rename driver files to force a driver + ' load failure upon next reboot so ensuing install will + ' succeed. + sys_folder = Session.Property("WindowsFolder") & "system32" + drv_folder = sys_folder & "\drivers" + If fso.FileExists(drv_folder & "\ibbus.sys") Then + FileMove drv_folder & "\ibbus.sys",drv_folder & "\ibbus.sy1" + End if + If fso.FileExists(drv_folder & "\mthca.sys") Then + FileMove drv_folder & "\mthca.sys",drv_folder & "\mthca.sy1" + End if + If fso.FileExists(sys_folder & "\ibinstaller.dll") Then + FileMove sys_folder & "\ibinstaller.dll",sys_folder & "\ibinstaller1.dll" + End if + ' Notify the user an existing non WinOF IB installation was detected and ' the system will be rebooted. dim res @@ -1027,13 +1059,13 @@ Function ChkInstallAndReboot() res = WshShell.Popup("Existing InfiniBand installation has been removed." _ & vbCRLF & vbCRLF & "Automatic REBOOT in 10 seconds."_ & vbCRLF & "Please re-install WinOF."_ - ,15,"WinOF - Existing InfiniBand installation Detected") + ,13,"WinOF - Existing InfiniBand installation Detected") 'run_once_cmd = Session.Property("SETUPEXEDIR") & "\setup.exe" 'RunAtReboot(run_once_cmd) - ' the _Driver Uninstall call sets reboot=force. The ForceReboot action - ' following this CustomAction will fire when reboot is set =force. + ' the _Driver Uninstall call sets reboot=force. The ForceReboot action + ' following this CustomAction will fire when reboot is set =force. ' The problem is we need to fail the installation so it cleans up, not ' a partial install, and still reboots - So far IS-12 doesn;t support ' this behavior. @@ -1041,8 +1073,8 @@ Function ChkInstallAndReboot() ScheduleReboot ' Fail the install so cleanup occurs. - ' Upon system restart, WinOF installation needs to be restarted - ' consider a run-once invocation. + ' Upon system restart, WinOF installation needs to be restarted + ' consider a run-once invocation. ChkInstallAndReboot = 2 ' will force install cleanup. -- 2.41.0