Fix backslashes in SHIBSP_PREFIX variable by manually creating it during the script...
[shibboleth/sp.git] / msi / scripts / shib_edit_config_files.vbs
index 3d9626f..3ce7ad1 100644 (file)
@@ -35,7 +35,7 @@ Sub ReplaceInFile( filePath, lookForStr, replaceWithStr )
 End Sub
 
 
-Dim FileSystemObj, ConvertedDir, ConfigFile, XMLDir
+Dim FileSystemObj, ConvertedDir, ConfigFile, XMLDir, WshShell
 Dim customData, msiProperties, InstallDir, ShibdPort
 
 on error resume next
@@ -56,46 +56,14 @@ if (Err = 0) then
   ConfigDir = InstallDir & "\etc\shibboleth\"
   DistDir = ConfigDir & "dist\"
 
+  'Set ConvertedDir as the SHIBSP_PREFIX system variable.
+  Set WshShell = CreateObject("WScript.Shell")
+  WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SHIBSP_PREFIX", ConvertedDir, "REG_SZ"
+
   'Perform actual Substitutions
   'Afterwards, if the config file doesn't already exist, copy up to etc/shibboleth
   'Also strip *.in for files in dist
 
-  ConfigFile = DistDir & "attribute-map.xml.in"
-  ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
-  If (NOT FileSystemObj.FileExists(ConfigDir & "attribute-map.xml")) then
-    FileSystemObj.CopyFile ConfigFile, ConfigDir & "attribute-map.xml", false
-  End If
-  If (FileSystemObj.FileExists(DistDir & "attribute-map.xml")) then
-    FileSystemObj.DeleteFile DistDir & "attribute-map.xml", true
-  End If
-  FileSystemObj.MoveFile ConfigFile, DistDir & "attribute-map.xml"
-
-  ConfigFile = DistDir & "attribute-policy.xml.in"
-  ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
-  If (NOT FileSystemObj.FileExists(ConfigDir & "attribute-policy.xml")) then
-    FileSystemObj.CopyFile ConfigFile, ConfigDir & "attribute-policy.xml", false
-  End If
-  If (FileSystemObj.FileExists(DistDir & "attribute-policy.xml")) then
-    FileSystemObj.DeleteFile DistDir & "attribute-policy.xml", true
-  End If
-  FileSystemObj.MoveFile ConfigFile, DistDir & "attribute-policy.xml"
-  
-  ConfigFile = DistDir & "shibboleth2.xml.in"
-  ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
-  ReplaceInFile ConfigFile, "@-PKGSYSCONFDIR-@", ConvertedDir & "/etc/shibboleth"
-  ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth"
-  ReplaceInFile ConfigFile, "@-LOGDIR-@", ConvertedDir & "/var/log/shibboleth"
-  ReplaceInFile ConfigFile, "@-PREFIX-@", ConvertedDir
-  ReplaceInFile ConfigFile, "   <UnixListener address=""@-PKGRUNDIR-@/shibd.sock""/>", "<!-- <UnixListener address=""@-PKGRUNDIR-@/shibd.sock""/> -->"
-  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""/>"
-  If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth2.xml")) then
-    FileSystemObj.CopyFile ConfigFile, ConfigDir & "shibboleth2.xml", false
-  End If
-  If (FileSystemObj.FileExists(DistDir & "shibboleth2.xml")) then
-    FileSystemObj.DeleteFile DistDir & "shibboleth2.xml", true
-  End If
-  FileSystemObj.MoveFile ConfigFile, DistDir & "shibboleth2.xml"
-
   ConfigFile = DistDir & "shibd.logger.in"
   ReplaceInFile ConfigFile, "@-PKGLOGDIR-@", ConvertedDir & "/var/log/shibboleth"
   If (NOT FileSystemObj.FileExists(ConfigDir & "shibd.logger")) then
@@ -117,13 +85,8 @@ if (Err = 0) then
   FileSystemObj.MoveFile ConfigFile, DistDir & "native.logger"
 
   ConfigFile = DistDir & "apache.config.in"
-  ReplaceInFile ConfigFile, "@-XMLTOOLINGXMLDIR-@", ConvertedDir & "/share/xml/xmltooling"
-  ReplaceInFile ConfigFile, "@-OPENSAMLXMLDIR-@", ConvertedDir & "/share/xml/opensaml"
-  ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
-  ReplaceInFile ConfigFile, "catalog.xml:", "catalog.xml;"
-  ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
-  ReplaceInFile ConfigFile, "@-PKGSYSCONFDIR-@", ConvertedDir & "/etc/shibboleth"
   ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth"
+  ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
   If (NOT FileSystemObj.FileExists(ConfigDir & "apache.config")) then
     FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache.config", false
   End If
@@ -133,13 +96,8 @@ if (Err = 0) then
   FileSystemObj.MoveFile ConfigFile, DistDir & "apache.config"
 
   ConfigFile = DistDir & "apache2.config.in"
-  ReplaceInFile ConfigFile, "@-XMLTOOLINGXMLDIR-@", ConvertedDir & "/share/xml/xmltooling"
-  ReplaceInFile ConfigFile, "@-OPENSAMLXMLDIR-@", ConvertedDir & "/share/xml/opensaml"
-  ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
-  ReplaceInFile ConfigFile, "catalog.xml:", "catalog.xml;"
-  ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
-  ReplaceInFile ConfigFile, "@-PKGSYSCONFDIR-@", ConvertedDir & "/etc/shibboleth"
   ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth"
+  ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
   If (NOT FileSystemObj.FileExists(ConfigDir & "apache2.config")) then
     FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache2.config", false
   End If
@@ -149,13 +107,8 @@ if (Err = 0) then
   FileSystemObj.MoveFile ConfigFile, DistDir & "apache2.config"
 
   ConfigFile = DistDir & "apache22.config.in"
-  ReplaceInFile ConfigFile, "@-XMLTOOLINGXMLDIR-@", ConvertedDir & "/share/xml/xmltooling"
-  ReplaceInFile ConfigFile, "@-OPENSAMLXMLDIR-@", ConvertedDir & "/share/xml/opensaml"
-  ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
-  ReplaceInFile ConfigFile, "catalog.xml:", "catalog.xml;"
-  ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
-  ReplaceInFile ConfigFile, "@-PKGSYSCONFDIR-@", ConvertedDir & "/etc/shibboleth"
   ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth"
+  ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth"
   If (NOT FileSystemObj.FileExists(ConfigDir & "apache22.config")) then
     FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache22.config", false
   End If
@@ -164,6 +117,13 @@ if (Err = 0) then
   End If
   FileSystemObj.MoveFile ConfigFile, DistDir & "apache22.config"
 
+  ConfigFile = DistDir & "shibboleth2.xml"
+  ReplaceInFile ConfigFile, "   <UnixListener address=""shibd.sock""/>", "<!-- <UnixListener address=""shibd.sock""/> -->"
+  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""/>"
+  If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth2.xml")) then
+    FileSystemObj.CopyFile ConfigFile, ConfigDir & "shibboleth2.xml", false
+  End If
+
   'Now just copy the other non-edited files over as well (if possible)
 
   If (NOT FileSystemObj.FileExists(ConfigDir & "accessError.html")) then
@@ -194,10 +154,6 @@ if (Err = 0) then
     FileSystemObj.CopyFile DistDir & "globalLogout.html", ConfigDir, false
   End If
 
-  If (NOT FileSystemObj.FileExists(ConfigDir & "openssl.cnf")) then
-    FileSystemObj.CopyFile DistDir & "openssl.cnf", ConfigDir, false
-  End If
-
   If (NOT FileSystemObj.FileExists(ConfigDir & "console.logger")) then
     FileSystemObj.CopyFile DistDir & "console.logger", ConfigDir, false
   End If
@@ -206,16 +162,16 @@ if (Err = 0) then
     FileSystemObj.CopyFile DistDir & "shibboleth.logger", ConfigDir, false
   End If
 
-  If (NOT FileSystemObj.FileExists(ConfigDir & "sp-example.crt")) then
-    FileSystemObj.CopyFile DistDir & "sp-example.crt", ConfigDir, false
+  If (NOT FileSystemObj.FileExists(ConfigDir & "example-metadata.xml")) then
+    FileSystemObj.CopyFile DistDir & "example-metadata.xml", ConfigDir, false
   End If
 
-  If (NOT FileSystemObj.FileExists(ConfigDir & "sp-example.key")) then
-    FileSystemObj.CopyFile DistDir & "sp-example.key", ConfigDir, false
+  If (NOT FileSystemObj.FileExists(ConfigDir & "attribute-map.xml")) then
+    FileSystemObj.CopyFile DistDir & "attribute-map.xml", ConfigDir, false
   End If
 
-  If (NOT FileSystemObj.FileExists(ConfigDir & "example-metadata.xml")) then
-    FileSystemObj.CopyFile DistDir & "example-metadata.xml", ConfigDir, false
+  If (NOT FileSystemObj.FileExists(ConfigDir & "attribute-policy.xml")) then
+    FileSystemObj.CopyFile DistDir & "attribute-policy.xml", ConfigDir, false
   End If
 
   ' Finally, fix up schema catalogs.