1 // AdvancedCopy Manager for Windows
2 // All Rights Reserved, Copyright FUJITSU LIMITED, 2005-2006
3 //
4 // TapeCopyPost.js: Post-Processing Script for tape copy
5 //
6 // [Parameters]
7 // 1st argument: device name of backup volume
8 //
9 // [Return Values]
10 // 0: The script ended normally.
11 // 2: The number of the arguments is incorrect.
12 // 4: An error other than the above occurred.
13
14 try {
15 // create global objects
16 var WshShell = WScript.CreateObject("WScript.Shell"); // create Shell object
17 var WshEnv = WshShell.Environment("PROCESS"); // create Environment object
18 var fsObj = WScript.CreateObject("Scripting.FileSystemObject"); // create FileSystemObject object
19
20 // create SwstTapeCopyPostProc object
21 var proc = new SwstTapeCopyPostProc();
22
23 // do nothing if postprocessing file exists
24 if (fsObj.FileExists(proc.postFileName) == false) {
25 SwstQuit(0);
26 }
27
28 // get postprocessing type
29 var postProcType = proc.getPostProcData(proc.postFileName);
30 switch(postProcType) {
31 case "none":
32 proc.doNothing();
33 break;
34 }
35
36 // clear temporary files
37 proc.deletePostFile(proc.postFileName);
38 SwstQuit(0);
39 } catch (e) {
40 SwstQuit(6);
41 }
42
43 function SwstTapeCopyPostProc()
44 {
45 // member variables
46 this.bvName = WScript.Arguments.length!=1?SwstQuit(1):WScript.Arguments.Item(0); // device name of transaction volume
47 this.postFileName = getDataPathName() + "\\" + getPutFileName(this.bvName) + ".pre"; // name of postprocessing file
48
49 // member functions
50 this.getPostProcData = getPostProcData; // self-explanatory
51 this.doNothing = doNothing; // self-explanatory
52 this.deletePostFile = deletePostFile; // self-explanatory
53 }
54
55 function getPostProcData(postfile)
56 {
57 var iomode = 1; // means read-only mode
58 var create = false; // means not to create a file
59 var postFileStream = fsObj.OpenTextFile(postfile, iomode, create);
60 var postData = postFileStream.ReadAll();
61 postFileStream.Close();
62 return postData;
63 }
64
65 function doNothing()
66 {
67 // do nothing
68 }
69
70 function deletePostFile(postfile)
71 {
72 if (fsObj.FileExists(postfile) == true) {
73 fsObj.DeleteFile(postfile);
74 }
75 }
76
77 function SwstQuit(exitStatus)
78 {
79 switch(exitStatus) {
80 case 0:
81 WScript.Quit(0);
82 case 1:
83 WScript.Echo("[Tape copy Postprocessing] The number of the arguments is incorrect.");
84 WScript.Quit(2);
85 default:
86 WScript.Echo("[Tape copy Postprocessing] The script exited abnormally.");
87 WScript.Quit(4);
88 }
89 }
90
91 function getDataPathName()
92 {
93 return WshShell.RegRead(getSetupInfoKey() + "\\etcPathName") + "\\etc\\backup\\data\\DEFAULT";
94 }
95
96 function getSetupInfoKey()
97 {
98 var nodeName = WshEnv.Item("SWSTGNODE");
99 if( nodeName != "" ){
100 return "HKEY_LOCAL_MACHINE\\SOFTWARE\\Fujitsu\\AdvancedCopy Manager\\CurrentVersion\\" + nodeName;
101 }
102 return "HKEY_LOCAL_MACHINE\\SOFTWARE\\Fujitsu\\AdvancedCopy Manager\\CurrentVersion";
103 }
104
105 function getPutFileName(deviceName){
106 var fileName;
107 fileName = deviceName;
108 return(fileName);
109 } |