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
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 & "AAP.xml.in"
64 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
65 If (NOT FileSystemObj.FileExists(ConfigDir & "AAP.xml")) then
66 FileSystemObj.CopyFile ConfigFile, ConfigDir & "AAP.xml", false
68 If (FileSystemObj.FileExists(DistDir & "AAP.xml")) then
69 FileSystemObj.DeleteFile DistDir & "AAP.xml", true
71 FileSystemObj.MoveFile ConfigFile, DistDir & "AAP.xml"
73 ConfigFile = DistDir & "example-metadata.xml.in"
74 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
75 If (NOT FileSystemObj.FileExists(ConfigDir & "example-metadata.xml")) then
76 FileSystemObj.CopyFile ConfigFile, ConfigDir & "example-metadata.xml", false
78 If (FileSystemObj.FileExists(DistDir & "example-metadata.xml")) then
79 FileSystemObj.DeleteFile DistDir & "example-metadata.xml", true
81 FileSystemObj.MoveFile ConfigFile, DistDir & "example-metadata.xml"
83 ConfigFile = DistDir & "IQ-metadata.xml.in"
84 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
85 If (NOT FileSystemObj.FileExists(ConfigDir & "IQ-metadata.xml")) then
86 FileSystemObj.CopyFile ConfigFile, ConfigDir & "IQ-metadata.xml", false
88 If (FileSystemObj.FileExists(DistDir & "IQ-metadata.xml")) then
89 FileSystemObj.DeleteFile DistDir & "IQ-metadata.xml", true
91 FileSystemObj.MoveFile ConfigFile, DistDir & "IQ-metadata.xml"
93 ConfigFile = DistDir & "shibboleth.xml.in"
94 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
95 ReplaceInFile ConfigFile, "@-PKGSYSCONFDIR-@", ConvertedDir & "/etc/shibboleth"
96 ReplaceInFile ConfigFile, "@-LIBEXECDIR-@", ConvertedDir & "/libexec"
97 ReplaceInFile ConfigFile, "@-LOGDIR-@", ConvertedDir & "/var/log/shibboleth"
98 ReplaceInFile ConfigFile, "@-PREFIX-@", ConvertedDir
99 ReplaceInFile ConfigFile, " <UnixListener address=""@-VARRUNDIR-@/shib-shar.sock""/>", "<!-- <UnixListener address=""@-VARRUNDIR-@/shib-shar.sock""/> -->"
100 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""/>"
101 If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth.xml")) then
102 FileSystemObj.CopyFile ConfigFile, ConfigDir & "shibboleth.xml", false
104 If (FileSystemObj.FileExists(DistDir & "shibboleth.xml")) then
105 FileSystemObj.DeleteFile DistDir & "shibboleth.xml", true
107 FileSystemObj.MoveFile ConfigFile, DistDir & "shibboleth.xml"
109 ConfigFile = DistDir & "shibd.logger.in"
110 ReplaceInFile ConfigFile, "@-PKGLOGDIR-@", ConvertedDir & "/var/log/shibboleth"
111 If (NOT FileSystemObj.FileExists(ConfigDir & "shibd.logger")) then
112 FileSystemObj.CopyFile ConfigFile, ConfigDir & "shibd.logger", false
114 If (FileSystemObj.FileExists(DistDir & "shibd.logger")) then
115 FileSystemObj.DeleteFile DistDir & "shibd.logger", true
117 FileSystemObj.MoveFile ConfigFile, DistDir & "shibd.logger"
119 ConfigFile = DistDir & "native.logger.in"
120 ReplaceInFile ConfigFile, "@-SHIRELOGDIR-@", ConvertedDir & "/var/log/shibboleth"
121 If (NOT FileSystemObj.FileExists(ConfigDir & "native.logger")) then
122 FileSystemObj.CopyFile ConfigFile, ConfigDir & "native.logger", false
124 If (FileSystemObj.FileExists(DistDir & "native.logger")) then
125 FileSystemObj.DeleteFile DistDir & "native.logger", true
127 FileSystemObj.MoveFile ConfigFile, DistDir & "native.logger"
129 ConfigFile = DistDir & "apache.config.in"
130 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
131 ReplaceInFile ConfigFile, "@-PKGSYSCONFDIR-@", ConvertedDir & "/etc/shibboleth"
132 ReplaceInFile ConfigFile, "@-LIBEXECDIR-@", ConvertedDir & "/libexec"
133 ReplaceInFile ConfigFile, "@-PREFIX-@", ConvertedDir
134 If (NOT FileSystemObj.FileExists(ConfigDir & "apache.config")) then
135 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache.config", false
137 If (FileSystemObj.FileExists(DistDir & "apache.config")) then
138 FileSystemObj.DeleteFile DistDir & "apache.config", true
140 FileSystemObj.MoveFile ConfigFile, DistDir & "apache.config"
142 ConfigFile = DistDir & "apache2.config.in"
143 ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
144 ReplaceInFile ConfigFile, "@-PKGSYSCONFDIR-@", ConvertedDir & "/etc/shibboleth"
145 ReplaceInFile ConfigFile, "@-LIBEXECDIR-@", ConvertedDir & "/libexec"
146 ReplaceInFile ConfigFile, "@-PREFIX-@", ConvertedDir
147 If (NOT FileSystemObj.FileExists(ConfigDir & "apache2.config")) then
148 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache2.config", false
150 If (FileSystemObj.FileExists(DistDir & "apache2.config")) then
151 FileSystemObj.DeleteFile DistDir & "apache2.config", true
153 FileSystemObj.MoveFile ConfigFile, DistDir & "apache2.config"
156 'Now just copy the other non-edited files over as well (if possible)
158 If (NOT FileSystemObj.FileExists(ConfigDir & "accessError.html")) then
159 FileSystemObj.CopyFile DistDir & "accessError.html", ConfigDir, false
162 If (NOT FileSystemObj.FileExists(ConfigDir & "inqueue.pem")) then
163 FileSystemObj.CopyFile DistDir & "inqueue.pem", ConfigDir, false
166 If (NOT FileSystemObj.FileExists(ConfigDir & "metadataError.html")) then
167 FileSystemObj.CopyFile DistDir & "metadataError.html", ConfigDir, false
170 If (NOT FileSystemObj.FileExists(ConfigDir & "openssl.cnf")) then
171 FileSystemObj.CopyFile DistDir & "openssl.cnf", ConfigDir, false
174 If (NOT FileSystemObj.FileExists(ConfigDir & "rmError.html")) then
175 FileSystemObj.CopyFile DistDir & "rmError.html", ConfigDir, false
178 If (NOT FileSystemObj.FileExists(ConfigDir & "sessionError.html")) then
179 FileSystemObj.CopyFile DistDir & "sessionError.html", ConfigDir, false
182 If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth.logger")) then
183 FileSystemObj.CopyFile DistDir & "shibboleth.logger", ConfigDir, false
186 If (NOT FileSystemObj.FileExists(ConfigDir & "sp-example.crt")) then
187 FileSystemObj.CopyFile DistDir & "sp-example.crt", ConfigDir, false
190 If (NOT FileSystemObj.FileExists(ConfigDir & "sp-example.key")) then
191 FileSystemObj.CopyFile DistDir & "sp-example.key", ConfigDir, false
194 If (NOT FileSystemObj.FileExists(ConfigDir & "sslError.html")) then
195 FileSystemObj.CopyFile DistDir & "sslError.html", ConfigDir, false