Use shibboleth-sp as package name for compatibility.
[shibboleth/cpp-sp.git] / msi / scripts / shib_edit_catalog.vbs
1 Function ReadFile( filePath )\r
2    Dim theFile\r
3 \r
4    'OpenTextFile args: <path>, 1 = ForReading\r
5    'If you read an empty file, VBScript throws an error for some reason\r
6    if (FileSystemObj.FileExists(filePath)) then\r
7      Set theFile = FileSystemObj.GetFile(filePath)\r
8      if (theFile.size > 0) then\r
9        Set theFile = FileSystemObj.OpenTextFile(filePath, 1)\r
10        ReadFile = theFile.ReadAll\r
11      else\r
12        ReadFile = ""\r
13      end if\r
14    else\r
15      ReadFile = ""\r
16    end if\r
17 End Function\r
18 \r
19 Sub WriteFile( filePath, contents )\r
20    Dim theFile\r
21 \r
22    'OpenTextFile args: <path>, 2 = ForWriting, True = create if not exist\r
23    Set theFile = FileSystemObj.OpenTextFile(filePath, 2, True)\r
24    theFile.Write contents\r
25 End Sub\r
26 \r
27 Sub ReplaceInFile( filePath, lookForStr, replaceWithStr )\r
28   Dim buffer\r
29 \r
30   buffer = ReadFile(filePath)\r
31   if (buffer <> "") then\r
32     buffer = Replace(buffer, lookForStr, replaceWithStr)\r
33     WriteFile filePath, buffer\r
34   end if\r
35 End Sub\r
36 \r
37 \r
38 Dim FileSystemObj, ConfigFile, ConfigFileName, XMLDir, WshShell\r
39 \r
40 on error resume next\r
41 Set FileSystemObj = CreateObject("Scripting.FileSystemObject")\r
42 if (Err = 0) then\r
43 \r
44   'Get the parameters via CustomActionData\r
45   customData = Session.Property("CustomActionData")\r
46   msiProperties = split(customData,";@;")\r
47   XMLDir = msiProperties(0) ' \programdata\shibboleth\sp\xml\opensaml\\r
48   ConfigFile = msiProperties(1) 'catalog\r
49 \r
50   ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir\r
51 \r
52 'Last End If\r
53 End If