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, ShibdPort
\r
41 on error resume next
\r
42 Set FileSystemObj = CreateObject("Scripting.FileSystemObject")
\r
45 'Get the INSTALLDIR and SHIBD_PORT values via CustomActionData
\r
46 customData = Session.Property("CustomActionData")
\r
47 msiProperties = split(customData,";@;")
\r
48 InstallDir = msiProperties(0)
\r
49 ShibdPort = msiProperties(1)
\r
50 ProgramData = msiProperties(2)
\r
52 'Remove all trailing backslashes to normalize
\r
53 do while (mid(InstallDir,Len(InstallDir),1) = "\")
\r
54 InstallDir = mid(InstallDir,1,Len(InstallDir)-1)
\r
56 ConvertedDir = Replace(InstallDir, "\", "/")
\r
57 ConfigDir = InstallDir & "\etc\shibboleth\"
\r
58 DistDir = ConfigDir & "dist\"
\r
60 'Set ConvertedDir as the SHIBSP_PREFIX system variable.
\r
61 Set WshShell = CreateObject("WScript.Shell")
\r
62 WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SHIBSP_PREFIX", ConvertedDir, "REG_SZ"
\r
64 'Perform actual Substitutions
\r
65 'Afterwards, if the config file doesn't already exist, copy up to etc/shibboleth
\r
66 'Also strip *.in for files in dist
\r
68 ConfigFile = DistDir & "shibd.logger.in"
\r
69 ReplaceInFile ConfigFile, "@-PKGLOGDIR-@", ConvertedDir & "/var/log/shibboleth"
\r
70 If (NOT FileSystemObj.FileExists(ConfigDir & "shibd.logger")) then
\r
71 FileSystemObj.CopyFile ConfigFile, ConfigDir & "shibd.logger", false
\r
73 If (FileSystemObj.FileExists(DistDir & "shibd.logger")) then
\r
74 FileSystemObj.DeleteFile DistDir & "shibd.logger", true
\r
76 FileSystemObj.MoveFile ConfigFile, DistDir & "shibd.logger"
\r
78 ConfigFile = DistDir & "native.logger.in"
\r
79 ReplaceInFile ConfigFile, "@-SHIRELOGDIR-@", ConvertedDir & "/var/log/shibboleth"
\r
80 If (NOT FileSystemObj.FileExists(ConfigDir & "native.logger")) then
\r
81 FileSystemObj.CopyFile ConfigFile, ConfigDir & "native.logger", false
\r
83 If (FileSystemObj.FileExists(DistDir & "native.logger")) then
\r
84 FileSystemObj.DeleteFile DistDir & "native.logger", true
\r
86 FileSystemObj.MoveFile ConfigFile, DistDir & "native.logger"
\r
88 ConfigFile = DistDir & "apache.config.in"
\r
89 ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth"
\r
90 ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
\r
91 If (NOT FileSystemObj.FileExists(ConfigDir & "apache.config")) then
\r
92 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache.config", false
\r
94 If (FileSystemObj.FileExists(DistDir & "apache.config")) then
\r
95 FileSystemObj.DeleteFile DistDir & "apache.config", true
\r
97 FileSystemObj.MoveFile ConfigFile, DistDir & "apache.config"
\r
99 ConfigFile = DistDir & "apache2.config.in"
\r
100 ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth"
\r
101 ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
\r
102 If (NOT FileSystemObj.FileExists(ConfigDir & "apache2.config")) then
\r
103 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache2.config", false
\r
105 If (FileSystemObj.FileExists(DistDir & "apache2.config")) then
\r
106 FileSystemObj.DeleteFile DistDir & "apache2.config", true
\r
108 FileSystemObj.MoveFile ConfigFile, DistDir & "apache2.config"
\r
110 ConfigFile = DistDir & "apache22.config.in"
\r
111 ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth"
\r
112 ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
\r
113 If (NOT FileSystemObj.FileExists(ConfigDir & "apache22.config")) then
\r
114 FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache22.config", false
\r
116 If (FileSystemObj.FileExists(DistDir & "apache22.config")) then
\r
117 FileSystemObj.DeleteFile DistDir & "apache22.config", true
\r
119 FileSystemObj.MoveFile ConfigFile, DistDir & "apache22.config"
\r
121 'Now just copy the other non-edited files over as well (if possible)
\r
123 If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth2.xml")) then
\r
124 FileSystemObj.CopyFile DistDir & "shibboleth2.xml", ConfigDir, false
\r
127 If (NOT FileSystemObj.FileExists(ConfigDir & "accessError.html")) then
\r
128 FileSystemObj.CopyFile DistDir & "accessError.html", ConfigDir, false
\r
131 If (NOT FileSystemObj.FileExists(ConfigDir & "metadataError.html")) then
\r
132 FileSystemObj.CopyFile DistDir & "metadataError.html", ConfigDir, false
\r
135 If (NOT FileSystemObj.FileExists(ConfigDir & "sessionError.html")) then
\r
136 FileSystemObj.CopyFile DistDir & "sessionError.html", ConfigDir, false
\r
139 If (NOT FileSystemObj.FileExists(ConfigDir & "sslError.html")) then
\r
140 FileSystemObj.CopyFile DistDir & "sslError.html", ConfigDir, false
\r
143 If (NOT FileSystemObj.FileExists(ConfigDir & "bindingTemplate.html")) then
\r
144 FileSystemObj.CopyFile DistDir & "bindingTemplate.html", ConfigDir, false
\r
147 If (NOT FileSystemObj.FileExists(ConfigDir & "discoveryTemplate.html")) then
\r
148 FileSystemObj.CopyFile DistDir & "discoveryTemplate.html", ConfigDir, false
\r
151 If (NOT FileSystemObj.FileExists(ConfigDir & "postTemplate.html")) then
\r
152 FileSystemObj.CopyFile DistDir & "postTemplate.html", ConfigDir, false
\r
155 If (NOT FileSystemObj.FileExists(ConfigDir & "localLogout.html")) then
\r
156 FileSystemObj.CopyFile DistDir & "localLogout.html", ConfigDir, false
\r
159 If (NOT FileSystemObj.FileExists(ConfigDir & "globalLogout.html")) then
\r
160 FileSystemObj.CopyFile DistDir & "globalLogout.html", ConfigDir, false
\r
163 If (NOT FileSystemObj.FileExists(ConfigDir & "partialLogout.html")) then
\r
164 FileSystemObj.CopyFile DistDir & "partialLogout.html", ConfigDir, false
\r
167 If (NOT FileSystemObj.FileExists(ConfigDir & "console.logger")) then
\r
168 FileSystemObj.CopyFile DistDir & "console.logger", ConfigDir, false
\r
171 If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth.logger")) then
\r
172 FileSystemObj.CopyFile DistDir & "shibboleth.logger", ConfigDir, false
\r
175 If (NOT FileSystemObj.FileExists(ConfigDir & "attribute-map.xml")) then
\r
176 FileSystemObj.CopyFile DistDir & "attribute-map.xml", ConfigDir, false
\r
179 If (NOT FileSystemObj.FileExists(ConfigDir & "attribute-policy.xml")) then
\r
180 FileSystemObj.CopyFile DistDir & "attribute-policy.xml", ConfigDir, false
\r
183 If (NOT FileSystemObj.FileExists(ConfigDir & "security-policy.xml")) then
\r
184 FileSystemObj.CopyFile DistDir & "security-policy.xml", ConfigDir, false
\r
187 If (NOT FileSystemObj.FileExists(ConfigDir & "protocols.xml")) then
\r
188 FileSystemObj.CopyFile DistDir & "protocols.xml", ConfigDir, false
\r
191 ConfigFile = ConfigDir & "SetService64.bat"
\r
192 ReplaceInFile ConfigFile, "@-INSTALLDIR-@", InstallDir
\r
194 ConfigFile = ConfigDir & "SetService32.bat"
\r
195 ReplaceInFile ConfigFile, "@-INSTALLDIR-@", InstallDir
\r