Re-add accidently removed script
authorRod Widdowson <rdw@steadingsoftware.com>
Sat, 20 Oct 2012 14:04:40 +0000 (14:04 +0000)
committerRod Widdowson <rdw@steadingsoftware.com>
Sat, 20 Oct 2012 14:04:40 +0000 (14:04 +0000)
msi/scripts/shib_edit_catalog.vbs [new file with mode: 0644]

diff --git a/msi/scripts/shib_edit_catalog.vbs b/msi/scripts/shib_edit_catalog.vbs
new file mode 100644 (file)
index 0000000..b30dff6
--- /dev/null
@@ -0,0 +1,54 @@
+Function ReadFile( filePath )\r
+   Dim theFile\r
+\r
+   'OpenTextFile args: <path>, 1 = ForReading\r
+   'If you read an empty file, VBScript throws an error for some reason\r
+   if (FileSystemObj.FileExists(filePath)) then\r
+     Set theFile = FileSystemObj.GetFile(filePath)\r
+     if (theFile.size > 0) then\r
+       Set theFile = FileSystemObj.OpenTextFile(filePath, 1)\r
+       ReadFile = theFile.ReadAll\r
+     else\r
+       ReadFile = ""\r
+     end if\r
+   else\r
+     ReadFile = ""\r
+   end if\r
+End Function\r
+\r
+Sub WriteFile( filePath, contents )\r
+   Dim theFile\r
+\r
+   'OpenTextFile args: <path>, 2 = ForWriting, True = create if not exist\r
+   Set theFile = FileSystemObj.OpenTextFile(filePath, 2, True)\r
+   theFile.Write contents\r
+End Sub\r
+\r
+Sub ReplaceInFile( filePath, lookForStr, replaceWithStr )\r
+  Dim buffer\r
+\r
+  buffer = ReadFile(filePath)\r
+  if (buffer <> "") then\r
+    buffer = Replace(buffer, lookForStr, replaceWithStr)\r
+    WriteFile filePath, buffer\r
+  end if\r
+End Sub\r
+\r
+\r
+Dim FileSystemObj, ConfigFile, ConfigFileName, XMLDir, WshShell\r
+\r
+on error resume next\r
+Set FileSystemObj = CreateObject("Scripting.FileSystemObject")\r
+if (Err = 0) then\r
+\r
+  'Get the parameters via CustomActionData\r
+  customData = Session.Property("CustomActionData")\r
+  msiProperties = split(customData,";@;")\r
+  XMLDir = msiProperties(0) ' \programdata\shibboleth\sp\xml\opensaml\\r
+  ConfigFileName = msiProperties(1) 'catalog\r
+\r
+  ConfigFile = XMLDir & ConfigFileName\r
+  ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir\r
+\r
+'Last End If\r
+End If
\ No newline at end of file