home *** CD-ROM | disk | FTP | other *** search
/ gimli.bioss.sari.ac.uk / gimli.bioss.sari.ac.uk.zip / gimli.bioss.sari.ac.uk / pub / misc / McAfee8.7.Zip / ePOPolicyMigration.exe / CABFILE / 1 / 85To87_Task_Upgrade_Script_For_ePO4.0.sql < prev    next >
Text File  |  2009-09-30  |  17KB  |  521 lines

  1. -------------------------------------------------------------------------------
  2.  
  3. -------------  V S E  8 . 5  T O  8 . 7  T A S K  U P G R A D E  --------------
  4.  
  5. -------------------------------------------------------------------------------
  6.  
  7. if exists (select * from tempdb..sysobjects where name like '#VseTmpUpgradeTask%')
  8. drop table #VseTmpUpgradeTask
  9. go
  10.  
  11. CREATE TABLE [dbo].[#VseTmpUpgradeTask] (
  12.     [AutoID] [int] IDENTITY (1, 1) NOT NULL ,
  13.     [ParentID] [int] NOT NULL ,
  14.     [ParentType] [tinyint] NOT NULL ,
  15.     [GlobalTaskID] [int] NOT NULL ,
  16.     [ProductCode] [nvarchar] (50) NULL ,
  17.     [TaskType] [nvarchar] (50) NULL ,
  18.     [TaskName] [nvarchar] (256) NULL ,
  19.     [TaskDesc] [nvarchar] (250) NULL ,
  20.     [PlatformsSupported] [nvarchar] (250) NULL ,
  21.     [EditURL] [nvarchar] (250) NULL ,
  22.     [SaveURL] [nvarchar] (250) NULL ,
  23.     [TaskFlags] [tinyint] NULL ,
  24.     [TheTimestamp] [binary] (8) NULL ,
  25.     [DeleteTimestamp] [binary] (8) NULL ,
  26.     [JustPlaceHolder] [bit] NULL ,
  27.     [Priority] [int] NULL,
  28.     [VSE87AutoID] [int],        -- must link VSE 8.7 autoid
  29.     [VSE85AutoID] [int]            -- with VSE 8.5 autoid
  30. )
  31. go
  32.  
  33. -- Don't copy any tasks if 8.7 tasks already exist
  34. if not exists (select * from EPOTask where ProductCode = 'VIRUSCAN8700' and ParentType = 7 and GlobalTaskID > 0)
  35. begin
  36.  
  37. -- Convert VSE8.5 tasks
  38. -- Copy over all task data and relink globaltaskid field
  39. -- Must copy over task and policies not just move them
  40. -- Copy all non global EPOTask table 8.5 policies to 8.7 policies
  41. -- Copy over global root tasks, but only those with GlobalTaskID > 0
  42.  
  43. -- copy all VSE 8.5 tasks
  44. insert #VseTmpUpgradeTask
  45. (ParentID, ParentType, GlobalTaskID,  ProductCode, TaskType, TaskName, TaskDesc,
  46.   PlatformsSupported, EditURL, SaveURL, TaskFlags, TheTimestamp, DeleteTimestamp, JustPlaceHolder, Priority, VSE87AutoID, VSE85AutoID)
  47. select 
  48. ParentID, ParentType, GlobalTaskID, 'VIRUSCAN8700' as ProductCode, TaskType, TaskName, TaskDesc,
  49.   PlatformsSupported, EditURL, SaveURL, TaskFlags, TheTimestamp, DeleteTimestamp, JustPlaceHolder, Priority, 0 as VSE87AutoID, autoid as VSE85AutoID
  50. from EPOTask
  51. where
  52. EPOTask.ProductCode = 'VIRUSCAN8600'
  53. and 
  54. (
  55. ParentType in (6,5,4,3,1)
  56. or
  57. (ParentType = 7 and GlobalTaskID > 0 )
  58. )
  59. and EPOTask.TaskType = 'VSC700_Scan_Task'
  60. order by autoid
  61.  
  62. -- Find next task autoid value
  63. Declare @NextTaskid int
  64. Select @NextTaskid = IDENT_CURRENT('EPOTask')
  65.  
  66. -- populate VSE87AutoID field in #VseTmpUpgradeTask
  67. Update #VseTmpUpgradeTask
  68. set VSE87AutoID = @NextTaskid + autoid
  69.  
  70. -- create VSE 8.7 tasks
  71. insert EPOTask
  72. (ParentID, ParentType, GlobalTaskID,  ProductCode, TaskType, TaskName, TaskDesc,
  73.   PlatformsSupported, EditURL, SaveURL, TaskFlags, TheTimestamp, DeleteTimestamp, JustPlaceHolder, Priority)
  74.  
  75. select 
  76. ParentID, ParentType, GlobalTaskID,   'VIRUSCAN8700' as ProductCode, 
  77.     TaskType, TaskName + ' (VSE 8.7i)', TaskDesc, PlatformsSupported, 
  78.     EditURL, SaveURL, TaskFlags, TheTimestamp, DeleteTimestamp, JustPlaceHolder, Priority
  79. from #VseTmpUpgradeTask
  80. order by autoid
  81.  
  82. -- Delete the old "(VSE 8.5i)" if it is an old upgraded 7.1 task
  83. update EPOTask
  84. Set EPOTask.TaskName = replace(EPOTask.TaskName, ' (VSE 8.5i)', '')
  85. where
  86. patindex('% (VSE 8.5i)%', EPOTask.TaskName) > 0
  87. and EPOTask.ProductCode = 'VIRUSCAN8700'
  88. and 
  89. (
  90. EPOTask.ParentType in (6,5,4,3,1)
  91. or
  92. (EPOTask.ParentType = 7 and EPOTask.GlobalTaskID > 0 )
  93. )
  94. and EPOTask.TaskType = 'VSC700_Scan_Task'
  95.  
  96. -- Update GlobalTaskID field, link it to VSE 8.7 task instead of VSE 8.5 task
  97. update EPOTask
  98. Set GlobalTaskID = VSE87AutoID
  99. From #VseTmpUpgradeTask
  100. where
  101. EPOTask.GlobalTaskID = #VseTmpUpgradeTask.VSE85AutoID
  102. and EPOTask.ProductCode = 'VIRUSCAN8700'
  103. and 
  104. (
  105. EPOTask.ParentType in (6,5,4,3,1)
  106. or
  107. (EPOTask.ParentType = 7 and EPOTask.GlobalTaskID > 0 )
  108. )
  109. and EPOTask.TaskType = 'VSC700_Scan_Task'
  110.  
  111. -- Update the GlobalTaskID for global root tasks, 
  112. -- (but only for those with with GlobalTaskID > 0)
  113. Declare @Root85Taskid int
  114. Select @Root85Taskid = AutoId
  115. From EPOTask
  116. where ParentType = 7
  117. and GlobalTaskID = 0
  118. and ProductCode = 'VIRUSCAN8600'
  119. and TaskType = 'VSC700_Scan_Task'
  120.  
  121. Declare @Root87Taskid int
  122. Select @Root87Taskid = AutoId
  123. From EPOTask
  124. where ParentType = 7
  125. and GlobalTaskID = 0
  126. and ProductCode = 'VIRUSCAN8700'
  127. and TaskType = 'VSC700_Scan_Task'
  128.  
  129. update EPOTask
  130. Set GlobalTaskID = @Root87Taskid
  131. where
  132. EPOTask.ProductCode = 'VIRUSCAN8700'
  133. and GlobalTaskID = @Root85Taskid
  134. and 
  135. (
  136. ParentType in (6,5,4,3,1)
  137. or
  138. (ParentType = 7 and GlobalTaskID > 0 )
  139. )
  140. and TaskType = 'VSC700_Scan_Task'
  141.  
  142. -- copy VSE 8.5 task settings to VSE 8.7 task settings
  143. -- Copy all non global task settings from 8.5 task settings to 8.7 task settings
  144. -- copy only settings where GlobalTaskID > 0
  145. -- Change parentid to point to the VSE 8.7 task
  146. insert EPOTaskSettings
  147. (ParentID, SectionName, SettingName, Value, TheTimestamp)
  148. select VSE87AutoID, SectionName, SettingName, Value, EPOTaskSettings.TheTimestamp
  149. from EPOTaskSettings, #VseTmpUpgradeTask
  150. where
  151. EPOTaskSettings.ParentID = #VseTmpUpgradeTask.VSE85AutoID
  152.  
  153. /* ----------------------------------------------------------------------------
  154.  Change the SectionName and/or the SettingName of the policies that have moved.
  155.  A "-" sign indicates that the value is no longer used and is to be deleted only.
  156.  
  157. OLD VALUE:                                                        NEW VALUE:
  158. [Actions]                                                        [Actions]
  159. uAction                                        = 3    (Move)        =>  = 4 (Delete)
  160. uSecAction                                                    =>  = 1 (Continue)
  161.  
  162. [Actions]                                                        [Actions]
  163. uAction                                        = 5    (Clean)
  164. uSecAction                                    = 3    (Move)        =>  = 4 (Delete)
  165.  
  166. [Actions]                                                        [Actions]
  167. uAction                                        = 4    (Delete)
  168. uSecAction                                    = 3    (Move)        =>  = 1 (Continue)
  169.  
  170. [Spyware]                                                        [Spyware]
  171. uAction_Program                                = 3    (Move)        =>  = 4 (Delete)
  172. uSecAction_Program                                            =>  = 1 (Continue)
  173.  
  174. [Spyware]                                                        [Spyware]
  175. uAction_Program                                = 5    (Clean)
  176. uSecAction_Program                            = 3    (Move)        =>  = 4 (Delete)
  177.  
  178. [Spyware]                                                        [Spyware]
  179. uAction_Program                                = 4    (Delete)
  180. uSecAction_Program                            = 3    (Move)        =>  = 1 (Continue)
  181.  
  182. [Actions]                                                        
  183. -szMoveToFolder
  184. -szSecMoveToFolder
  185.  
  186. [Reports]                                                
  187. -bLogUsername
  188.  
  189. [Advanced]                                                
  190. bDeferScanOnBattery=0
  191.  
  192. [Advanced]                                                
  193. bDeferScanInFullScreen=0
  194.  
  195. [Advanced]                                                
  196. uDeferTime=1
  197. ----------------------------------------------------------------------------- */
  198.  
  199. /* ----------------------------------------------------------------------------
  200. [Actions]                                                        [Actions]
  201. uAction                                        = 3    (Move)        =>  = 4 (Delete)
  202. uSecAction                                                    =>  = 1 (Continue)
  203. ---------------------------------------------------------------------------- */
  204. update EPOTaskSettings
  205. set Value = '1'
  206. where
  207. SectionName = 'Actions'
  208. and SettingName = 'uSecAction'
  209. and EPOTaskSettings.parentid in 
  210.     (select b.parentid
  211.     from #VseTmpUpgradeTask, EPOTaskSettings b
  212.     where
  213.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  214.     and b.SectionName = 'Actions'
  215.     and b.SettingName = 'uAction'
  216.     and b.Value = '3'
  217.     )
  218.  
  219. update EPOTaskSettings
  220. set Value = '4'
  221. where
  222. SectionName = 'Actions'
  223. and SettingName = 'uAction'
  224. and EPOTaskSettings.parentid in 
  225.     (select b.parentid
  226.     from #VseTmpUpgradeTask, EPOTaskSettings b
  227.     where
  228.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  229.     and b.SectionName = 'Actions'
  230.     and b.SettingName = 'uAction'
  231.     and b.Value = '3'
  232.     )
  233.  
  234. /* ----------------------------------------------------------------------------
  235. [Actions]                                                        [Actions]
  236. uAction                                        = 5 (Clean)
  237. uSecAction                                    = 3    (Move)        =>  = 4 (Delete)
  238. ---------------------------------------------------------------------------- */
  239. update EPOTaskSettings
  240. set Value = '4'
  241. where
  242. SectionName = 'Actions'
  243. and SettingName = 'uSecAction'
  244. and EPOTaskSettings.parentid in 
  245.     (select b.parentid
  246.     from #VseTmpUpgradeTask, EPOTaskSettings b, EPOTaskSettings c
  247.     where
  248.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  249.     and b.SectionName = 'Actions'
  250.     and b.SettingName = 'uAction'
  251.     and b.Value = '5'
  252.     and b.ParentID = c.ParentID
  253.     and c.SectionName = 'Actions'
  254.     and c.SettingName = 'uSecAction'
  255.     and c.Value = '3'
  256.     )
  257.  
  258. /* ----------------------------------------------------------------------------
  259. [Actions]                                                        [Actions]
  260. uAction                                        = 4    (Delete)
  261. uSecAction                                    = 3    (Move)        =>  = 1 (Continue)
  262. ---------------------------------------------------------------------------- */
  263. update EPOTaskSettings
  264. set Value = '1'
  265. where
  266. SectionName = 'Actions'
  267. and SettingName = 'uSecAction'
  268. and EPOTaskSettings.parentid in 
  269.     (select b.parentid
  270.     from #VseTmpUpgradeTask, EPOTaskSettings b, EPOTaskSettings c
  271.     where
  272.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  273.     and b.SectionName = 'Actions'
  274.     and b.SettingName = 'uAction'
  275.     and b.Value = '4'
  276.     and b.ParentID = c.ParentID
  277.     and c.SectionName = 'Actions'
  278.     and c.SettingName = 'uSecAction'
  279.     and c.Value = '3'
  280.     )
  281.  
  282. /* ----------------------------------------------------------------------------
  283. [Spyware]                                                        [Spyware]
  284. uAction_Program                                = 3    (Move)        =>  = 4 (Delete)
  285. uSecAction_Program                                            =>  = 1 (Continue)
  286. ---------------------------------------------------------------------------- */
  287. update EPOTaskSettings
  288. set Value = '1'
  289. where
  290. SectionName = 'Spyware'
  291. and SettingName = 'uSecAction_Program'
  292. and EPOTaskSettings.parentid in 
  293.     (select b.parentid
  294.     from #VseTmpUpgradeTask, EPOTaskSettings b
  295.     where
  296.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  297.     and b.SectionName = 'Spyware'
  298.     and b.SettingName = 'uAction_Program'
  299.     and b.Value = '3'
  300.     )
  301.  
  302. update EPOTaskSettings
  303. set Value = '4'
  304. where
  305. SectionName = 'Spyware'
  306. and SettingName = 'uAction_Program'
  307. and EPOTaskSettings.parentid in 
  308.     (select b.parentid
  309.     from #VseTmpUpgradeTask, EPOTaskSettings b
  310.     where
  311.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  312.     and b.SectionName = 'Spyware'
  313.     and b.SettingName = 'uAction_Program'
  314.     and b.Value = '3'
  315.     )
  316.  
  317. /* ----------------------------------------------------------------------------
  318. [Spyware]                                                        [Spyware]
  319. uAction_Program                                = 5    (Clean)
  320. uSecAction_Program                            = 3    (Move)        =>  = 4 (Delete)
  321. ---------------------------------------------------------------------------- */
  322. update EPOTaskSettings
  323. set Value = '4'
  324. where
  325. SectionName = 'Spyware'
  326. and SettingName = 'uSecAction_Program'
  327. and EPOTaskSettings.parentid in 
  328.     (select b.parentid
  329.     from #VseTmpUpgradeTask, EPOTaskSettings b, EPOTaskSettings c
  330.     where
  331.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  332.     and b.SectionName = 'Spyware'
  333.     and b.SettingName = 'uAction_Program'
  334.     and b.Value = '5'
  335.     and b.ParentID = c.ParentID
  336.     and c.SectionName = 'Spyware'
  337.     and c.SettingName = 'uSecAction_Program'
  338.     and c.Value = '3'
  339.     )
  340.  
  341. /* ----------------------------------------------------------------------------
  342. [Spyware]                                                        [Spyware]
  343. uAction_Program                                = 4    (Delete)
  344. uSecAction_Program                            = 3    (Move)        =>  = 1 (Continue)
  345. ---------------------------------------------------------------------------- */
  346. update EPOTaskSettings
  347. set Value = '1'
  348. where
  349. SectionName = 'Spyware'
  350. and SettingName = 'uSecAction_Program'
  351. and EPOTaskSettings.parentid in 
  352.     (select b.parentid
  353.     from #VseTmpUpgradeTask, EPOTaskSettings b, EPOTaskSettings c
  354.     where
  355.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  356.     and b.SectionName = 'Spyware'
  357.     and b.SettingName = 'uAction_Program'
  358.     and b.Value = '4'
  359.     and b.ParentID = c.ParentID
  360.     and c.SectionName = 'Spyware'
  361.     and c.SettingName = 'uSecAction_Program'
  362.     and c.Value = '3'
  363.     )
  364.  
  365. /* ----------------------------------------------------------------------------
  366. [Actions]                                                        
  367. -szMoveToFolder
  368. -szSecMoveToFolder
  369. ---------------------------------------------------------------------------- */
  370. delete EPOTaskSettings 
  371. where 
  372. EPOTaskSettings.SectionName = 'Actions'
  373. and EPOTaskSettings.SettingName = 'szMoveToFolder'
  374. and EPOTaskSettings.parentid in 
  375.     (select b.parentid
  376.     from #VseTmpUpgradeTask, EPOTaskSettings b
  377.     where
  378.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  379.     )
  380.  
  381. delete EPOTaskSettings 
  382. where 
  383. EPOTaskSettings.SectionName = 'Actions'
  384. and EPOTaskSettings.SettingName = 'szSecMoveToFolder'
  385. and EPOTaskSettings.parentid in 
  386.     (select b.parentid
  387.     from #VseTmpUpgradeTask, EPOTaskSettings b
  388.     where
  389.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  390.     )
  391.  
  392. /* ----------------------------------------------------------------------------
  393. [Reports]                                                
  394. -bLogUsername
  395. ---------------------------------------------------------------------------- */
  396. delete EPOTaskSettings 
  397. where 
  398. EPOTaskSettings.SectionName = 'Reports'
  399. and EPOTaskSettings.SettingName = 'bLogUsername'
  400. and EPOTaskSettings.parentid in 
  401.     (select b.parentid
  402.     from #VseTmpUpgradeTask, EPOTaskSettings b
  403.     where
  404.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  405.     )
  406.     
  407. /* ----------------------------------------------------------------------------
  408. [Advanced]                                                
  409. bDeferScanOnBattery=0
  410. ---------------------------------------------------------------------------- */
  411. insert into EPOTaskSettings
  412. (ParentID, SectionName, SettingName, Value)
  413. select EPOTaskSettings.parentid, 'Advanced', 'bDeferScanOnBattery', 0
  414. from EPOTaskSettings, #VseTmpUpgradeTask
  415. where
  416. EPOTaskSettings.SectionName = 'Advanced'
  417. and EPOTaskSettings.SettingName = 'bDoHsm'
  418. and EPOTaskSettings.parentid = #VseTmpUpgradeTask.VSE87AutoID
  419.  
  420. /* ----------------------------------------------------------------------------
  421. [Advanced]                                                
  422. bDeferScanInFullScreen=0
  423. ---------------------------------------------------------------------------- */
  424. insert into EPOTaskSettings
  425. (ParentID, SectionName, SettingName, Value)
  426. select EPOTaskSettings.parentid, 'Advanced', 'bDeferScanInFullScreen', 0
  427. from EPOTaskSettings, #VseTmpUpgradeTask
  428. where
  429. EPOTaskSettings.SectionName = 'Advanced'
  430. and EPOTaskSettings.SettingName = 'bDoHsm'
  431. and EPOTaskSettings.parentid = #VseTmpUpgradeTask.VSE87AutoID
  432.  
  433. /* ----------------------------------------------------------------------------
  434. [Advanced]                                                
  435. uDeferTime=1
  436. ---------------------------------------------------------------------------- */
  437. insert into EPOTaskSettings
  438. (ParentID, SectionName, SettingName, Value)
  439. select EPOTaskSettings.parentid, 'Advanced', 'uDeferTime', 1
  440. from EPOTaskSettings, #VseTmpUpgradeTask
  441. where
  442. EPOTaskSettings.SectionName = 'Advanced'
  443. and EPOTaskSettings.SettingName = 'bDoHsm'
  444. and EPOTaskSettings.parentid = #VseTmpUpgradeTask.VSE87AutoID
  445.  
  446. /* ----------------------------------------------------------------------------
  447. [Reports]                                            
  448. Alert_ExcludeCookies=1
  449. ---------------------------------------------------------------------------- */
  450. insert into EPOTaskSettings
  451. (ParentID, SectionName, SettingName, Value)
  452. select EPOTaskSettings.parentid, 'Reports', 'Alert_ExcludeCookies', 1
  453. from EPOTaskSettings, #VseTmpUpgradeTask
  454. where
  455. EPOTaskSettings.SectionName = 'Reports'
  456. and EPOTaskSettings.SettingName = 'bLogToFile'
  457. and EPOTaskSettings.parentid = #VseTmpUpgradeTask.VSE87AutoID
  458.  
  459. /* ----------------------------------------------------------------------------
  460. [Advanced]
  461. dwHeuristicNetCheckSensitivity=0
  462. ---------------------------------------------------------------------------- */
  463. insert into EPOTaskSettings
  464. (ParentID, SectionName, SettingName, Value)
  465. select EPOTaskSettings.parentid, 'Advanced', 'dwHeuristicNetCheckSensitivity', 0
  466. from EPOTaskSettings, #VseTmpUpgradeTask
  467. where
  468. EPOTaskSettings.SectionName = 'Advanced'
  469. and EPOTaskSettings.SettingName = 'bDoHsm'
  470. and EPOTaskSettings.parentid = #VseTmpUpgradeTask.VSE87AutoID
  471. end
  472. go
  473.  
  474. if exists (select * from tempdb..sysobjects where name like '#VseTmpUpgradeTask%')
  475. drop table #VseTmpUpgradeTask
  476. go
  477.  
  478. /* ----------------------------------------------------------------------------
  479. Update the task timestamps
  480. ---------------------------------------------------------------------------- */
  481. if exists (select * from tempdb..sysobjects where name like '#vsetasktime%')
  482. drop table #vsetasktime
  483. go
  484.  
  485. begin
  486. -- Update the timestamps so that the agents know there are new tasks
  487. declare @Currenttime int
  488. select @Currenttime = @@dbts
  489.  
  490. update EPOTask set TheTimestamp = @Currenttime
  491. where ProductCode = 'VIRUSCAN8700'
  492.  
  493. select parentid as autoid, parenttype, max(thetimestamp)as maxtime
  494. into #vsetasktime
  495. from EPOTask
  496. where ProductCode = 'VIRUSCAN8700'
  497. group by parentid, parenttype
  498.  
  499. update EPOLeafNode
  500. set tasktimestamp = #vsetasktime.maxtime + 1
  501. from #vsetasktime
  502. where EPOLeafNode.autoid = #vsetasktime.autoid
  503. and #vsetasktime.parenttype = EPOLeafNode.type
  504.  
  505. update EPOBranchNode
  506. set tasktimestamp = #vsetasktime.maxtime + 1
  507. from #vsetasktime
  508. where EPOBranchNode.autoid = #vsetasktime.autoid
  509. and #vsetasktime.parenttype = EPOBranchNode.type
  510.  
  511. update EPOTaskSettings set TheTimestamp = @Currenttime
  512. from EPOTask
  513. where EPOTaskSettings.parentid = EPOTask.autoid
  514. and EPOTask.ProductCode = 'VIRUSCAN8700'
  515.  
  516. end
  517. go
  518.  
  519. if exists (select * from tempdb..sysobjects where name like '#vsetasktime%')
  520. drop table #vsetasktime
  521. go