X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=msi%2Fscripts%2Fshib_edit_catalog.vbs;fp=msi%2Fscripts%2Fshib_edit_catalog.vbs;h=b30dff61207b2037c902ee6fe94af476b314daf3;hb=3c1e801d6539b92d6d3d7fb40d661a7ce630ec44;hp=0000000000000000000000000000000000000000;hpb=f2621219507344852f967e4099e9c341499eb802;p=shibboleth%2Fsp.git 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