1 Function ReadFile( filePath )
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
19 Sub WriteFile( filePath, contents )
22 'OpenTextFile args: <path>, 2 = ForWriting, True = create if not exist
23 Set theFile = FileSystemObj.OpenTextFile(filePath, 2, True)
24 theFile.Write contents
27 Sub ReplaceInFile( filePath, lookForStr, replaceWithStr )
30 buffer = ReadFile(filePath)
31 if (buffer <> "") then
32 buffer = Replace(buffer, lookForStr, replaceWithStr)
33 WriteFile filePath, buffer
38 Dim FileSystemObj, ConvertedDir, ConfigFile, XMLDir, WshShell
39 Dim customData, msiProperties, InstallDir, ShibdPort
42 Set FileSystemObj = CreateObject("Scripting.FileSystemObject")
45 'Get the INSTALLDIR and SHIBD_PORT values via CustomActionData
46 customData = Session.Property("CustomActionData")
47 msiProperties = split(customData,";@;")
48 InstallDir = msiProperties(0)
49 ShibdPort = msiProperties(1)
51 'Remove all trailing backslashes to normalize
52 do while (mid(InstallDir,Len(InstallDir),1) = "\")
53 InstallDir = mid(InstallDir,1,Len(InstallDir)-1)
55 ConvertedDir = Replace(InstallDir, "\", "/")
56 ConfigDir = InstallDir & "\etc\shibboleth\"
57 DistDir = ConfigDir & "dist\"
59 'Set ConvertedDir as the SHIBSP_PREFIX system variable.
60 Set WshShell = CreateObject("WScript.Shell")
61 WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SHIBSP_PREFIX", ConvertedDir, "REG_SZ"
63 'Perform actual Substitutions
64 'Afterwards, if the config file doesn't already exist, copy up to etc/shibboleth
65 'Also strip *.in for files in dist
67 ConfigFile = DistDir & "shibd.logger.in"
68 ReplaceInFile ConfigFile, "@-PKGLOGDIR-@", ConvertedDir & "/var/log/shibboleth"
69 If (NOT FileSystemObj.FileExists(ConfigDir & "shibd.logger")) then
70 FileSystemObj.CopyFile ConfigFile, ConfigDir & "shibd.logger", false
72 If (FileSystemObj.FileExists(DistDir & "shibd.logger")) then
73 FileSystemObj.DeleteFile DistDir & "shibd.logger", true
75 FileSystemObj.MoveFile ConfigFile, DistDir & "shibd.logger"
77 ConfigFile = DistDir & "native.logger.in"
78 ReplaceInFile ConfigFile, "@-SHIRELOGDIR-@", ConvertedDir & "/var/log/shibboleth"
79 If (NOT FileSystemObj.FileExists(ConfigDir & "native.logger")) then
80 FileSystemObj.CopyFile ConfigFile, ConfigDir & "native.logger", false
82 If (FileSystemObj.FileExists(DistDir & "native.logger")) then
83 FileSystemObj.DeleteFile DistDir & "native.logger", true
85 FileSystemObj.MoveFile ConfigFile, DistDir & "native.logger"
87 ConfigFile = DistDir & "apache.config.in"
88 ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth"
89 ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
90 If (NOT FileSystemObj.FileExists(ConfigDir & "apache.config")) then
91 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache.config", false
93 If (FileSystemObj.FileExists(DistDir & "apache.config")) then
94 FileSystemObj.DeleteFile DistDir & "apache.config", true
96 FileSystemObj.MoveFile ConfigFile, DistDir & "apache.config"
98 ConfigFile = DistDir & "apache2.config.in"
99 ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth"
100 ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
101 If (NOT FileSystemObj.FileExists(ConfigDir & "apache2.config")) then
102 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache2.config", false
104 If (FileSystemObj.FileExists(DistDir & "apache2.config")) then
105 FileSystemObj.DeleteFile DistDir & "apache2.config", true
107 FileSystemObj.MoveFile ConfigFile, DistDir & "apache2.config"
109 ConfigFile = DistDir & "apache22.config.in"
110 ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth"
111 ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
112 If (NOT FileSystemObj.FileExists(ConfigDir & "apache22.config")) then
113 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache22.config", false
115 If (FileSystemObj.FileExists(DistDir & "apache22.config")) then
116 FileSystemObj.DeleteFile DistDir & "apache22.config", true
118 FileSystemObj.MoveFile ConfigFile, DistDir & "apache22.config"
120 ConfigFile = DistDir & "shibboleth2.xml"
121 ReplaceInFile ConfigFile, " <UnixListener address=""shibd.sock""/>", "<!-- <UnixListener address=""shibd.sock""/> -->"
122 ReplaceInFile ConfigFile, "<!-- <TCPListener address=""127.0.0.1"" port=""12345"" acl=""127.0.0.1""/> -->", "<TCPListener address=""127.0.0.1"" port=""" & ShibdPort & """ acl=""127.0.0.1""/>"
123 If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth2.xml")) then
124 FileSystemObj.CopyFile ConfigFile, ConfigDir & "shibboleth2.xml", false
127 'Now just copy the other non-edited files over as well (if possible)
129 If (NOT FileSystemObj.FileExists(ConfigDir & "accessError.html")) then
130 FileSystemObj.CopyFile DistDir & "accessError.html", ConfigDir, false
133 If (NOT FileSystemObj.FileExists(ConfigDir & "metadataError.html")) then
134 FileSystemObj.CopyFile DistDir & "metadataError.html", ConfigDir, false
137 If (NOT FileSystemObj.FileExists(ConfigDir & "sessionError.html")) then
138 FileSystemObj.CopyFile DistDir & "sessionError.html", ConfigDir, false
141 If (NOT FileSystemObj.FileExists(ConfigDir & "sslError.html")) then
142 FileSystemObj.CopyFile DistDir & "sslError.html", ConfigDir, false
145 If (NOT FileSystemObj.FileExists(ConfigDir & "bindingTemplate.html")) then
146 FileSystemObj.CopyFile DistDir & "bindingTemplate.html", ConfigDir, false
149 If (NOT FileSystemObj.FileExists(ConfigDir & "localLogout.html")) then
150 FileSystemObj.CopyFile DistDir & "localLogout.html", ConfigDir, false
153 If (NOT FileSystemObj.FileExists(ConfigDir & "globalLogout.html")) then
154 FileSystemObj.CopyFile DistDir & "globalLogout.html", ConfigDir, false
157 If (NOT FileSystemObj.FileExists(ConfigDir & "console.logger")) then
158 FileSystemObj.CopyFile DistDir & "console.logger", ConfigDir, false
161 If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth.logger")) then
162 FileSystemObj.CopyFile DistDir & "shibboleth.logger", ConfigDir, false
165 If (NOT FileSystemObj.FileExists(ConfigDir & "example-metadata.xml")) then
166 FileSystemObj.CopyFile DistDir & "example-metadata.xml", ConfigDir, false
169 If (NOT FileSystemObj.FileExists(ConfigDir & "attribute-map.xml")) then
170 FileSystemObj.CopyFile DistDir & "attribute-map.xml", ConfigDir, false
173 If (NOT FileSystemObj.FileExists(ConfigDir & "attribute-policy.xml")) then
174 FileSystemObj.CopyFile DistDir & "attribute-policy.xml", ConfigDir, false
177 ' Finally, fix up schema catalogs.
179 XMLDir = InstallDir & "\share\xml\xmltooling\"
180 ConfigFile = XMLDir & "catalog.xml"
181 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir
183 XMLDir = InstallDir & "\share\xml\opensaml\"
184 ConfigFile = XMLDir & "saml20-catalog.xml"
185 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir
186 ConfigFile = XMLDir & "saml11-catalog.xml"
187 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir
188 ConfigFile = XMLDir & "saml10-catalog.xml"
189 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir
191 XMLDir = InstallDir & "\share\xml\shibboleth\"
192 ConfigFile = XMLDir & "catalog.xml"
193 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir