From c1c5154f25c4f5597c3fb8e1a3895793dc14a068 Mon Sep 17 00:00:00 2001 From: Rod Widdowson Date: Sat, 20 Oct 2012 14:04:40 +0000 Subject: [PATCH] Re-add accidently removed script --- msi/scripts/shib_edit_catalog.vbs | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 msi/scripts/shib_edit_catalog.vbs diff --git a/msi/scripts/shib_edit_catalog.vbs b/msi/scripts/shib_edit_catalog.vbs new file mode 100644 index 0000000..b30dff6 --- /dev/null +++ b/msi/scripts/shib_edit_catalog.vbs @@ -0,0 +1,54 @@ +Function ReadFile( filePath ) + Dim theFile + + 'OpenTextFile args: , 1 = ForReading + 'If you read an empty file, VBScript throws an error for some reason + if (FileSystemObj.FileExists(filePath)) then + Set theFile = FileSystemObj.GetFile(filePath) + if (theFile.size > 0) then + Set theFile = FileSystemObj.OpenTextFile(filePath, 1) + ReadFile = theFile.ReadAll + else + ReadFile = "" + end if + else + ReadFile = "" + end if +End Function + +Sub WriteFile( filePath, contents ) + Dim theFile + + 'OpenTextFile args: , 2 = ForWriting, True = create if not exist + Set theFile = FileSystemObj.OpenTextFile(filePath, 2, True) + theFile.Write contents +End Sub + +Sub ReplaceInFile( filePath, lookForStr, replaceWithStr ) + Dim buffer + + buffer = ReadFile(filePath) + if (buffer <> "") then + buffer = Replace(buffer, lookForStr, replaceWithStr) + WriteFile filePath, buffer + end if +End Sub + + +Dim FileSystemObj, ConfigFile, ConfigFileName, XMLDir, WshShell + +on error resume next +Set FileSystemObj = CreateObject("Scripting.FileSystemObject") +if (Err = 0) then + + 'Get the parameters via CustomActionData + customData = Session.Property("CustomActionData") + msiProperties = split(customData,";@;") + XMLDir = msiProperties(0) ' \programdata\shibboleth\sp\xml\opensaml\ + ConfigFileName = msiProperties(1) 'catalog + + ConfigFile = XMLDir & ConfigFileName + ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir + +'Last End If +End If \ No newline at end of file -- 2.1.4