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
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 'Perform actual Substitutions
60 'Afterwards, if the config file doesn't already exist, copy up to etc/shibboleth
61 'Also strip *.in for files in dist
63 ConfigFile = DistDir & "shibd.logger.in"
64 ReplaceInFile ConfigFile, "@-PKGLOGDIR-@", ConvertedDir & "/var/log/shibboleth"
65 If (NOT FileSystemObj.FileExists(ConfigDir & "shibd.logger")) then
66 FileSystemObj.CopyFile ConfigFile, ConfigDir & "shibd.logger", false
68 If (FileSystemObj.FileExists(DistDir & "shibd.logger")) then
69 FileSystemObj.DeleteFile DistDir & "shibd.logger", true
71 FileSystemObj.MoveFile ConfigFile, DistDir & "shibd.logger"
73 ConfigFile = DistDir & "native.logger.in"
74 ReplaceInFile ConfigFile, "@-SHIRELOGDIR-@", ConvertedDir & "/var/log/shibboleth"
75 If (NOT FileSystemObj.FileExists(ConfigDir & "native.logger")) then
76 FileSystemObj.CopyFile ConfigFile, ConfigDir & "native.logger", false
78 If (FileSystemObj.FileExists(DistDir & "native.logger")) then
79 FileSystemObj.DeleteFile DistDir & "native.logger", true
81 FileSystemObj.MoveFile ConfigFile, DistDir & "native.logger"
83 ConfigFile = DistDir & "apache.config.in"
84 ReplaceInFile ConfigFile, "@-XMLTOOLINGXMLDIR-@", ConvertedDir & "/share/xml/xmltooling"
85 ReplaceInFile ConfigFile, "@-OPENSAMLXMLDIR-@", ConvertedDir & "/share/xml/opensaml"
86 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
87 ReplaceInFile ConfigFile, "catalog.xml:", "catalog.xml;"
88 ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
89 ReplaceInFile ConfigFile, "@-PKGSYSCONFDIR-@", ConvertedDir & "/etc/shibboleth"
90 ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth"
91 If (NOT FileSystemObj.FileExists(ConfigDir & "apache.config")) then
92 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache.config", false
94 If (FileSystemObj.FileExists(DistDir & "apache.config")) then
95 FileSystemObj.DeleteFile DistDir & "apache.config", true
97 FileSystemObj.MoveFile ConfigFile, DistDir & "apache.config"
99 ConfigFile = DistDir & "apache2.config.in"
100 ReplaceInFile ConfigFile, "@-XMLTOOLINGXMLDIR-@", ConvertedDir & "/share/xml/xmltooling"
101 ReplaceInFile ConfigFile, "@-OPENSAMLXMLDIR-@", ConvertedDir & "/share/xml/opensaml"
102 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
103 ReplaceInFile ConfigFile, "catalog.xml:", "catalog.xml;"
104 ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
105 ReplaceInFile ConfigFile, "@-PKGSYSCONFDIR-@", ConvertedDir & "/etc/shibboleth"
106 ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth"
107 If (NOT FileSystemObj.FileExists(ConfigDir & "apache2.config")) then
108 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache2.config", false
110 If (FileSystemObj.FileExists(DistDir & "apache2.config")) then
111 FileSystemObj.DeleteFile DistDir & "apache2.config", true
113 FileSystemObj.MoveFile ConfigFile, DistDir & "apache2.config"
115 ConfigFile = DistDir & "apache22.config.in"
116 ReplaceInFile ConfigFile, "@-XMLTOOLINGXMLDIR-@", ConvertedDir & "/share/xml/xmltooling"
117 ReplaceInFile ConfigFile, "@-OPENSAMLXMLDIR-@", ConvertedDir & "/share/xml/opensaml"
118 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
119 ReplaceInFile ConfigFile, "catalog.xml:", "catalog.xml;"
120 ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
121 ReplaceInFile ConfigFile, "@-PKGSYSCONFDIR-@", ConvertedDir & "/etc/shibboleth"
122 ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth"
123 If (NOT FileSystemObj.FileExists(ConfigDir & "apache22.config")) then
124 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache22.config", false
126 If (FileSystemObj.FileExists(DistDir & "apache22.config")) then
127 FileSystemObj.DeleteFile DistDir & "apache22.config", true
129 FileSystemObj.MoveFile ConfigFile, DistDir & "apache22.config"
131 ConfigFile = DistDir & "shibboleth2.xml"
132 ReplaceInFile ConfigFile, " <UnixListener address=""shibd.sock""/>", "<!-- <UnixListener address=""shibd.sock""/> -->"
133 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""/>"
134 If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth2.xml")) then
135 FileSystemObj.CopyFile ConfigFile, ConfigDir & "shibboleth2.xml", false
138 'Now just copy the other non-edited files over as well (if possible)
140 If (NOT FileSystemObj.FileExists(ConfigDir & "accessError.html")) then
141 FileSystemObj.CopyFile DistDir & "accessError.html", ConfigDir, false
144 If (NOT FileSystemObj.FileExists(ConfigDir & "metadataError.html")) then
145 FileSystemObj.CopyFile DistDir & "metadataError.html", ConfigDir, false
148 If (NOT FileSystemObj.FileExists(ConfigDir & "sessionError.html")) then
149 FileSystemObj.CopyFile DistDir & "sessionError.html", ConfigDir, false
152 If (NOT FileSystemObj.FileExists(ConfigDir & "sslError.html")) then
153 FileSystemObj.CopyFile DistDir & "sslError.html", ConfigDir, false
156 If (NOT FileSystemObj.FileExists(ConfigDir & "bindingTemplate.html")) then
157 FileSystemObj.CopyFile DistDir & "bindingTemplate.html", ConfigDir, false
160 If (NOT FileSystemObj.FileExists(ConfigDir & "localLogout.html")) then
161 FileSystemObj.CopyFile DistDir & "localLogout.html", ConfigDir, false
164 If (NOT FileSystemObj.FileExists(ConfigDir & "globalLogout.html")) then
165 FileSystemObj.CopyFile DistDir & "globalLogout.html", ConfigDir, false
168 If (NOT FileSystemObj.FileExists(ConfigDir & "openssl.cnf")) then
169 FileSystemObj.CopyFile DistDir & "openssl.cnf", ConfigDir, false
172 If (NOT FileSystemObj.FileExists(ConfigDir & "console.logger")) then
173 FileSystemObj.CopyFile DistDir & "console.logger", ConfigDir, false
176 If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth.logger")) then
177 FileSystemObj.CopyFile DistDir & "shibboleth.logger", ConfigDir, false
180 If (NOT FileSystemObj.FileExists(ConfigDir & "sp-example.crt")) then
181 FileSystemObj.CopyFile DistDir & "sp-example.crt", ConfigDir, false
184 If (NOT FileSystemObj.FileExists(ConfigDir & "sp-example.key")) then
185 FileSystemObj.CopyFile DistDir & "sp-example.key", ConfigDir, false
188 If (NOT FileSystemObj.FileExists(ConfigDir & "example-metadata.xml")) then
189 FileSystemObj.CopyFile DistDir & "example-metadata.xml", ConfigDir, false
192 If (NOT FileSystemObj.FileExists(ConfigDir & "attribute-map.xml")) then
193 FileSystemObj.CopyFile DistDir & "attribute-map.xml", ConfigDir, false
196 If (NOT FileSystemObj.FileExists(ConfigDir & "attribute-policy.xml")) then
197 FileSystemObj.CopyFile DistDir & "attribute-policy.xml", ConfigDir, false
200 ' Finally, fix up schema catalogs.
202 XMLDir = InstallDir & "\share\xml\xmltooling\"
203 ConfigFile = XMLDir & "catalog.xml"
204 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir
206 XMLDir = InstallDir & "\share\xml\opensaml\"
207 ConfigFile = XMLDir & "saml20-catalog.xml"
208 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir
209 ConfigFile = XMLDir & "saml11-catalog.xml"
210 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir
211 ConfigFile = XMLDir & "saml10-catalog.xml"
212 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir
214 XMLDir = InstallDir & "\share\xml\shibboleth\"
215 ConfigFile = XMLDir & "catalog.xml"
216 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir