source: raptor-distribution/MSIs/raptor-web/trunk/source/installer/raptor_vb_webconf.vbs @ 1778

Revision 1747, 2.6 KB checked in by rhyssmith, 6 years ago (diff)

Adding raptor-web v1.2.1 MSI sources

Line 
1Function ReadFile( filePath )
2   Dim theFile
3
4   'OpenTextFile args: <path>, 1 = ForReading
5   'If you read an empty file, VBScript throws an error for some reason
6   if (FileSystemObj.FileExists(filePath)) then
7     Set theFile = FileSystemObj.GetFile(filePath)
8     if (theFile.size > 0) then
9       Set theFile = FileSystemObj.OpenTextFile(filePath, 1)
10       ReadFile = theFile.ReadAll
11     else
12       ReadFile = ""
13     end if
14   else
15     ReadFile = ""
16   end if
17End Function
18
19Sub WriteFile( filePath, contents )
20   Dim theFile
21
22   'OpenTextFile args: <path>, 2 = ForWriting, True = create if not exist
23   Set theFile = FileSystemObj.OpenTextFile(filePath, 2, True)
24   theFile.Write contents
25End Sub
26
27Sub ReplaceInFile( filePath, lookForStr, replaceWithStr )
28  Dim buffer
29
30  buffer = ReadFile(filePath)
31  if (buffer <> "") then
32    buffer = Replace(buffer, lookForStr, replaceWithStr)
33    WriteFile filePath, buffer
34  end if
35End Sub
36
37
38Dim FileSystemObj, ConvertedDir, ConfigFile, XMLDir, WshShell
39Dim customData, msiProperties, InstallDir, LogFile
40
41on error resume next
42Set FileSystemObj = CreateObject("Scripting.FileSystemObject")
43if (Err = 0) then
44
45  'Get the INSTALLDIR
46  customData = Session.Property("CustomActionData")
47  msiProperties = split(customData,";@;")
48  InstallDir = msiProperties(0)
49
50  'Set LogFile = FileSystemObj.OpenTextFile(InstallDir & "logs\InstallerScript.log", 8, true)
51
52  'Remove all trailing backslashes to normalize
53  do while (mid(InstallDir,Len(InstallDir),1) = "\")
54    InstallDir = mid(InstallDir,1,Len(InstallDir)-1)
55  loop
56  ConvertedDir = Replace(InstallDir, "\", "/")
57  ConfigDir = InstallDir & "\conf\"
58  DistDir = ConfigDir & "dist\"
59
60  If (LogFile) then
61     LogFile.WriteLine "Backing up Config Files from " & ConfigDir
62  End If
63
64
65
66  'Back up the dashboard-statistics.xml file
67  If (FileSystemObj.FileExists(ConfigDir & "dashboard-statistics.xml")) then
68    If (LogFile) then
69      LogFile.WriteLine ConfigDir & "dashboard-statistics.xml file exists, copying it"
70    End If
71    FileSystemObj.CopyFile ConfigDir & "dashboard-statistics.xml", ConfigDir & "dashboard-statistics.xml.backup", true
72    FileSystemObj.DeleteFile ConfigDir & "dashboard-statistics.xml"
73  End If 
74
75  'Back up the web-core.xml file
76  If (FileSystemObj.FileExists(ConfigDir & "web-core.xml")) then
77    If (LogFile) then
78      LogFile.WriteLine ConfigDir & "web-core.xml file exists, copying it"
79    End If
80    FileSystemObj.CopyFile ConfigDir & "web-core.xml", ConfigDir & "web-core.xml.backup", true
81    FileSystemObj.DeleteFile ConfigDir & "web-core.xml"
82  End If 
83
84  If (LogFile) then
85     LogFile.WriteLine "Finished backing up Config Files."
86     LogFile.WriteLine " "
87  End If
88
89End If
Note: See TracBrowser for help on using the repository browser.