1 Function ReadFile( filePath )
\r
4 'OpenTextFile args: <path>, 1 = ForReading
\r
5 'If you read an empty file, VBScript throws an error for some reason
\r
6 if (FileSystemObj.FileExists(filePath)) then
\r
7 Set theFile = FileSystemObj.GetFile(filePath)
\r
8 if (theFile.size > 0) then
\r
9 Set theFile = FileSystemObj.OpenTextFile(filePath, 1)
\r
10 ReadFile = theFile.ReadAll
\r
19 Sub WriteFile( filePath, contents )
\r
22 'OpenTextFile args: <path>, 2 = ForWriting, True = create if not exist
\r
23 Set theFile = FileSystemObj.OpenTextFile(filePath, 2, True)
\r
24 theFile.Write contents
\r
27 Sub ReplaceInFile( filePath, lookForStr, replaceWithStr )
\r
30 buffer = ReadFile(filePath)
\r
31 if (buffer <> "") then
\r
32 buffer = Replace(buffer, lookForStr, replaceWithStr)
\r
33 WriteFile filePath, buffer
\r
38 Dim FileSystemObj, ConvertedDir, ConfigFile, XMLDir, WshShell
\r
39 Dim customData, msiProperties, InstallDir, LibDir, Is64Bit, Install32, LogFile
\r
41 on error resume next
\r
42 Set FileSystemObj = CreateObject("Scripting.FileSystemObject")
\r
45 'Get the INSTALLDIR and 64/32 values via CustomActionData
\r
46 customData = Session.Property("CustomActionData")
\r
47 msiProperties = split(customData,";@;")
\r
48 InstallDir = msiProperties(0)
\r
49 Is64Bit = msiProperties(1)
\r
50 Install32 = msiProperties(2)
\r
53 If (Is64Bit = "TRUE") then
\r
54 If (Install32 <> "TRUE") then
\r
59 Set LogFile = FileSystemObj.OpenTextFile(InstallDir & "\var\log\shibboleth\Installer.log", 8, true)
\r
62 LogFile.WriteLine "Edit Config Files to " & InstallDir & ", 64Bit = " & Is64Bit & ", 32Bit = " & Install32
\r
65 'Remove all trailing backslashes to normalize
\r
66 do while (mid(InstallDir,Len(InstallDir),1) = "\")
\r
67 InstallDir = mid(InstallDir,1,Len(InstallDir)-1)
\r
69 ConvertedDir = Replace(InstallDir, "\", "/")
\r
70 ConfigDir = InstallDir & "\etc\shibboleth\"
\r
71 DistDir = ConfigDir & "dist\"
\r
73 'Set ConvertedDir as the SHIBSP_PREFIX system variable.
\r
74 Set WshShell = CreateObject("WScript.Shell")
\r
75 WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SHIBSP_PREFIX", ConvertedDir, "REG_SZ"
\r
77 'Blow away any old SHIBSPP_SCHEMAS variable we find
\r
78 WshShell.RegDelete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SHIBSP_SCHEMAS"
\r
80 'Perform actual Substitutions
\r
81 'Afterwards, if the config file doesn't already exist, copy up to etc/shibboleth
\r
82 'Also strip *.in for files in dist
\r
84 ConfigFile = DistDir & "shibd.logger.in"
\r
85 ReplaceInFile ConfigFile, "@-PKGLOGDIR-@", ConvertedDir & "/var/log/shibboleth"
\r
86 If (NOT FileSystemObj.FileExists(ConfigDir & "shibd.logger")) then
\r
87 FileSystemObj.CopyFile ConfigFile, ConfigDir & "shibd.logger", false
\r
89 If (FileSystemObj.FileExists(DistDir & "shibd.logger")) then
\r
90 FileSystemObj.DeleteFile DistDir & "shibd.logger", true
\r
92 FileSystemObj.MoveFile ConfigFile, DistDir & "shibd.logger"
\r
94 ConfigFile = DistDir & "native.logger.in"
\r
95 ReplaceInFile ConfigFile, "@-SHIRELOGDIR-@", ConvertedDir & "/var/log/shibboleth"
\r
96 If (NOT FileSystemObj.FileExists(ConfigDir & "native.logger")) then
\r
97 FileSystemObj.CopyFile ConfigFile, ConfigDir & "native.logger", false
\r
99 If (FileSystemObj.FileExists(DistDir & "native.logger")) then
\r
100 FileSystemObj.DeleteFile DistDir & "native.logger", true
\r
102 FileSystemObj.MoveFile ConfigFile, DistDir & "native.logger"
\r
104 ConfigFile = DistDir & "apache.config.in"
\r
105 ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/" & LibDir & "/shibboleth"
\r
106 ReplaceInFile ConfigFile, "@-PKGWEBDIR-@", ConvertedDir & "/doc/shibboleth"
\r
107 If (NOT FileSystemObj.FileExists(ConfigDir & "apache.config")) then
\r
108 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache.config", false
\r
110 If (FileSystemObj.FileExists(DistDir & "apache.config")) then
\r
111 FileSystemObj.DeleteFile DistDir & "apache.config", true
\r
113 FileSystemObj.MoveFile ConfigFile, DistDir & "apache.config"
\r
115 ConfigFile = DistDir & "apache2.config.in"
\r
116 ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/" & LibDir & "/shibboleth"
\r
117 ReplaceInFile ConfigFile, "@-PKGWEBDIR-@", ConvertedDir & "/doc/shibboleth"
\r
118 If (NOT FileSystemObj.FileExists(ConfigDir & "apache2.config")) then
\r
119 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache2.config", false
\r
121 If (FileSystemObj.FileExists(DistDir & "apache2.config")) then
\r
122 FileSystemObj.DeleteFile DistDir & "apache2.config", true
\r
124 FileSystemObj.MoveFile ConfigFile, DistDir & "apache2.config"
\r
126 ConfigFile = DistDir & "apache22.config.in"
\r
127 ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/" & LibDir & "/shibboleth"
\r
128 ReplaceInFile ConfigFile, "@-PKGWEBDIR-@", ConvertedDir & "/doc/shibboleth"
\r
129 If (NOT FileSystemObj.FileExists(ConfigDir & "apache22.config")) then
\r
130 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache22.config", false
\r
132 If (FileSystemObj.FileExists(DistDir & "apache22.config")) then
\r
133 FileSystemObj.DeleteFile DistDir & "apache22.config", true
\r
135 FileSystemObj.MoveFile ConfigFile, DistDir & "apache22.config"
\r
137 ConfigFile = DistDir & "apache24.config.in"
\r
138 ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/" & LibDir & "/shibboleth"
\r
139 ReplaceInFile ConfigFile, "@-PKGWEBDIR-@", ConvertedDir & "/doc/shibboleth"
\r
140 If (NOT FileSystemObj.FileExists(ConfigDir & "apache24.config")) then
\r
141 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache24.config", false
\r
143 If (FileSystemObj.FileExists(DistDir & "apache24.config")) then
\r
144 FileSystemObj.DeleteFile DistDir & "apache24.config", true
\r
146 FileSystemObj.MoveFile ConfigFile, DistDir & "apache24.config"
\r
148 'Now just copy the other non-edited files over as well (if possible)
\r
150 If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth2.xml")) then
\r
151 FileSystemObj.CopyFile DistDir & "shibboleth2.xml", ConfigDir, false
\r
154 If (NOT FileSystemObj.FileExists(ConfigDir & "accessError.html")) then
\r
155 FileSystemObj.CopyFile DistDir & "accessError.html", ConfigDir, false
\r
158 If (NOT FileSystemObj.FileExists(ConfigDir & "metadataError.html")) then
\r
159 FileSystemObj.CopyFile DistDir & "metadataError.html", ConfigDir, false
\r
162 If (NOT FileSystemObj.FileExists(ConfigDir & "sessionError.html")) then
\r
163 FileSystemObj.CopyFile DistDir & "sessionError.html", ConfigDir, false
\r
166 If (NOT FileSystemObj.FileExists(ConfigDir & "sslError.html")) then
\r
167 FileSystemObj.CopyFile DistDir & "sslError.html", ConfigDir, false
\r
170 If (NOT FileSystemObj.FileExists(ConfigDir & "bindingTemplate.html")) then
\r
171 FileSystemObj.CopyFile DistDir & "bindingTemplate.html", ConfigDir, false
\r
174 If (NOT FileSystemObj.FileExists(ConfigDir & "discoveryTemplate.html")) then
\r
175 FileSystemObj.CopyFile DistDir & "discoveryTemplate.html", ConfigDir, false
\r
178 If (NOT FileSystemObj.FileExists(ConfigDir & "postTemplate.html")) then
\r
179 FileSystemObj.CopyFile DistDir & "postTemplate.html", ConfigDir, false
\r
182 If (NOT FileSystemObj.FileExists(ConfigDir & "localLogout.html")) then
\r
183 FileSystemObj.CopyFile DistDir & "localLogout.html", ConfigDir, false
\r
186 If (NOT FileSystemObj.FileExists(ConfigDir & "globalLogout.html")) then
\r
187 FileSystemObj.CopyFile DistDir & "globalLogout.html", ConfigDir, false
\r
190 If (NOT FileSystemObj.FileExists(ConfigDir & "partialLogout.html")) then
\r
191 FileSystemObj.CopyFile DistDir & "partialLogout.html", ConfigDir, false
\r
194 If (NOT FileSystemObj.FileExists(ConfigDir & "console.logger")) then
\r
195 FileSystemObj.CopyFile DistDir & "console.logger", ConfigDir, false
\r
198 If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth.logger")) then
\r
199 FileSystemObj.CopyFile DistDir & "shibboleth.logger", ConfigDir, false
\r
202 If (NOT FileSystemObj.FileExists(ConfigDir & "attribute-map.xml")) then
\r
203 FileSystemObj.CopyFile DistDir & "attribute-map.xml", ConfigDir, false
\r
206 If (NOT FileSystemObj.FileExists(ConfigDir & "attribute-policy.xml")) then
\r
207 FileSystemObj.CopyFile DistDir & "attribute-policy.xml", ConfigDir, false
\r
210 If (NOT FileSystemObj.FileExists(ConfigDir & "security-policy.xml")) then
\r
211 FileSystemObj.CopyFile DistDir & "security-policy.xml", ConfigDir, false
\r
214 If (NOT FileSystemObj.FileExists(ConfigDir & "protocols.xml")) then
\r
215 FileSystemObj.CopyFile DistDir & "protocols.xml", ConfigDir, false
\r
218 ConfigFile = ConfigDir & "SetService64.bat"
\r
219 ReplaceInFile ConfigFile, "@-INSTALLDIR-@", InstallDir
\r
221 ConfigFile = ConfigDir & "SetService32.bat"
\r
222 ReplaceInFile ConfigFile, "@-INSTALLDIR-@", InstallDir
\r