Initial check-in of install action scripts.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Tue, 19 Jul 2005 18:44:43 +0000 (18:44 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Tue, 19 Jul 2005 18:44:43 +0000 (18:44 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@1765 cb58f699-b61c-0410-a6fe-9272a202ed29

msi/scripts/shib_edit_config_files.vbs [new file with mode: 0644]
msi/scripts/shib_install_isapi_filter.vbs [new file with mode: 0644]
msi/scripts/shib_uninstall_isapi_filter.vbs [new file with mode: 0644]
msi/scripts/shib_uninstall_old_versions.vbs [new file with mode: 0644]
msi/scripts/shib_upgrade_check.vbs [new file with mode: 0644]

diff --git a/msi/scripts/shib_edit_config_files.vbs b/msi/scripts/shib_edit_config_files.vbs
new file mode 100644 (file)
index 0000000..c39f65c
--- /dev/null
@@ -0,0 +1,196 @@
+Function ReadFile( filePath )
+   Dim theFile
+
+   'OpenTextFile args: <path>, 1 = ForReading
+   'If you read an empty file, VBScript throws an error for some reason
+   if (FileSystemObj.FileExists(filePath)) then
+     Set theFile = FileSystemObj.GetFile(filePath)
+     if (theFile.size > 0) then
+       Set theFile = FileSystemObj.OpenTextFile(filePath, 1)
+       ReadFile = theFile.ReadAll
+     else
+       ReadFile = ""
+     end if
+   else
+     ReadFile = ""
+   end if
+End Function
+
+Sub WriteFile( filePath, contents )
+   Dim theFile
+
+   'OpenTextFile args: <path>, 2 = ForWriting, True = create if not exist
+   Set theFile = FileSystemObj.OpenTextFile(filePath, 2, True)
+   theFile.Write contents
+End Sub
+
+Sub ReplaceInFile( filePath, lookForStr, replaceWithStr )
+  Dim buffer
+
+  buffer = ReadFile(filePath)
+  if (buffer <> "") then
+    buffer = Replace(buffer, lookForStr, replaceWithStr)
+    WriteFile filePath, buffer
+  end if
+End Sub
+
+
+Dim FileSystemObj, ConvertedDir, ConfigFile
+Dim customData, msiProperties, InstallDir, ShibdPort
+
+on error resume next
+Set FileSystemObj = CreateObject("Scripting.FileSystemObject")
+if (Err = 0) then
+
+  'Get the INSTALLDIR and SHIBD_PORT values via CustomActionData
+  customData = Session.Property("CustomActionData")
+  msiProperties = split(customData,";@;")
+  InstallDir = msiProperties(0)
+  ShibdPort = msiProperties(1)
+
+  'Remove all trailing backslashes to normalize
+  do while (mid(InstallDir,Len(InstallDir),1) = "\")
+    InstallDir = mid(InstallDir,1,Len(InstallDir)-1)
+  loop
+  ConvertedDir = Replace(InstallDir, "\", "/")
+  ConfigDir = InstallDir & "\etc\shibboleth\"
+  DistDir = ConfigDir & "dist\"
+
+  '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 & "AAP.xml.in"
+  ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
+  If (NOT FileSystemObj.FileExists(ConfigDir & "AAP.xml")) then
+    FileSystemObj.CopyFile ConfigFile, ConfigDir & "AAP.xml", false
+  End If
+  If (FileSystemObj.FileExists(DistDir & "AAP.xml")) then
+    FileSystemObj.DeleteFile DistDir & "AAP.xml", true
+  End If
+  FileSystemObj.MoveFile ConfigFile, DistDir & "AAP.xml"
+  
+  ConfigFile = DistDir & "example-metadata.xml.in"
+  ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
+  If (NOT FileSystemObj.FileExists(ConfigDir & "example-metadata.xml")) then
+    FileSystemObj.CopyFile ConfigFile, ConfigDir & "example-metadata.xml", false
+  End If
+  If (FileSystemObj.FileExists(DistDir & "example-metadata.xml")) then
+    FileSystemObj.DeleteFile DistDir & "example-metadata.xml", true
+  End If
+  FileSystemObj.MoveFile ConfigFile, DistDir & "example-metadata.xml"
+
+  ConfigFile = DistDir & "IQ-metadata.xml.in"
+  ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
+  If (NOT FileSystemObj.FileExists(ConfigDir & "IQ-metadata.xml")) then
+    FileSystemObj.CopyFile ConfigFile, ConfigDir & "IQ-metadata.xml", false
+  End If
+  If (FileSystemObj.FileExists(DistDir & "IQ-metadata.xml")) then
+    FileSystemObj.DeleteFile DistDir & "IQ-metadata.xml", true
+  End If
+  FileSystemObj.MoveFile ConfigFile, DistDir & "IQ-metadata.xml"
+
+  ConfigFile = DistDir & "shibboleth.xml.in"
+  ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
+  ReplaceInFile ConfigFile, "@-PKGSYSCONFDIR-@", ConvertedDir & "/etc/shibboleth"
+  ReplaceInFile ConfigFile, "@-LIBEXECDIR-@", ConvertedDir & "/libexec"
+  ReplaceInFile ConfigFile, "@-LOGDIR-@", ConvertedDir & "/var/log/shibboleth"
+  ReplaceInFile ConfigFile, "@-PREFIX-@", ConvertedDir
+  ReplaceInFile ConfigFile, "   <UnixListener address=""@-VARRUNDIR-@/shib-shar.sock""/>", "<!-- <UnixListener address=""@-VARRUNDIR-@/shib-shar.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 & "shibboleth.xml")) then
+    FileSystemObj.CopyFile ConfigFile, ConfigDir & "shibboleth.xml", false
+  End If
+  If (FileSystemObj.FileExists(DistDir & "shibboleth.xml")) then
+    FileSystemObj.DeleteFile DistDir & "shibboleth.xml", true
+  End If
+  FileSystemObj.MoveFile ConfigFile, DistDir & "shibboleth.xml"
+
+  ConfigFile = DistDir & "shibd.logger.in"
+  ReplaceInFile ConfigFile, "@-PKGLOGDIR-@", ConvertedDir & "/var/log/shibboleth"
+  If (NOT FileSystemObj.FileExists(ConfigDir & "shibd.logger")) then
+    FileSystemObj.CopyFile ConfigFile, ConfigDir & "shibd.logger", false
+  End If
+  If (FileSystemObj.FileExists(DistDir & "shibd.logger")) then
+    FileSystemObj.DeleteFile DistDir & "shibd.logger", true
+  End If
+  FileSystemObj.MoveFile ConfigFile, DistDir & "shibd.logger"
+
+  ConfigFile = DistDir & "native.logger.in"
+  ReplaceInFile ConfigFile, "@-SHIRELOGDIR-@", ConvertedDir & "/var/log/shibboleth"
+  If (NOT FileSystemObj.FileExists(ConfigDir & "native.logger")) then
+    FileSystemObj.CopyFile ConfigFile, ConfigDir & "native.logger", false
+  End If
+  If (FileSystemObj.FileExists(DistDir & "native.logger")) then
+    FileSystemObj.DeleteFile DistDir & "native.logger", true
+  End If
+  FileSystemObj.MoveFile ConfigFile, DistDir & "native.logger"
+
+  ConfigFile = DistDir & "apache.config.in"
+  ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
+  ReplaceInFile ConfigFile, "@-PKGSYSCONFDIR-@", ConvertedDir & "/etc/shibboleth"
+  ReplaceInFile ConfigFile, "@-LIBEXECDIR-@", ConvertedDir & "/libexec"
+  ReplaceInFile ConfigFile, "@-PREFIX-@", ConvertedDir
+  If (NOT FileSystemObj.FileExists(ConfigDir & "apache.config")) then
+    FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache.config", false
+  End If
+  If (FileSystemObj.FileExists(DistDir & "apache.config")) then
+    FileSystemObj.DeleteFile DistDir & "apache.config", true
+  End If
+  FileSystemObj.MoveFile ConfigFile, DistDir & "apache.config"
+
+  ConfigFile = DistDir & "apache2.config.in"
+  ReplaceInFile ConfigFile, "@-PKGXMLDIR-@", ConvertedDir & "/share/xml/shibboleth"
+  ReplaceInFile ConfigFile, "@-PKGSYSCONFDIR-@", ConvertedDir & "/etc/shibboleth"
+  ReplaceInFile ConfigFile, "@-LIBEXECDIR-@", ConvertedDir & "/libexec"
+  ReplaceInFile ConfigFile, "@-PREFIX-@", ConvertedDir
+  If (NOT FileSystemObj.FileExists(ConfigDir & "apache2.config")) then
+    FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache2.config", false
+  End If
+  If (FileSystemObj.FileExists(DistDir & "apache2.config")) then
+    FileSystemObj.DeleteFile DistDir & "apache2.config", true
+  End If
+  FileSystemObj.MoveFile ConfigFile, DistDir & "apache2.config"
+
+
+  'Now just copy the other non-edited files over as well (if possible)
+
+  If (NOT FileSystemObj.FileExists(ConfigDir & "accessError.html")) then
+    FileSystemObj.CopyFile DistDir & "accessError.html", ConfigDir, false
+  End If
+
+  If (NOT FileSystemObj.FileExists(ConfigDir & "inqueue.pem")) then
+    FileSystemObj.CopyFile DistDir & "inqueue.pem", ConfigDir, false
+  End If
+
+  If (NOT FileSystemObj.FileExists(ConfigDir & "metadataError.html")) then
+    FileSystemObj.CopyFile DistDir & "metadataError.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 & "rmError.html")) then
+    FileSystemObj.CopyFile DistDir & "rmError.html", ConfigDir, false
+  End If
+
+  If (NOT FileSystemObj.FileExists(ConfigDir & "sessionError.html")) then
+    FileSystemObj.CopyFile DistDir & "sessionError.html", ConfigDir, false
+  End If
+
+  If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth.logger")) 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
+  End If
+
+  If (NOT FileSystemObj.FileExists(ConfigDir & "sp-example.key")) then
+    FileSystemObj.CopyFile DistDir & "sp-example.key", ConfigDir, false
+  End If
+
+
+'Last End If
+End If
\ No newline at end of file
diff --git a/msi/scripts/shib_install_isapi_filter.vbs b/msi/scripts/shib_install_isapi_filter.vbs
new file mode 100644 (file)
index 0000000..77c76f9
--- /dev/null
@@ -0,0 +1,141 @@
+Dim FiltersObj
+Dim FilterObj
+Dim LoadOrder
+Dim FilterName
+Dim FilterPath
+Dim FilterDesc
+Dim WebObj
+Dim existsFlag
+Dim ScriptMaps
+Dim newScriptLine
+Dim line, lineArray, lineIndex
+Dim WebSvcExts
+Dim newWebSvcExtLine
+Dim customData, msiProperties, InstallDir, ShibFileExtension
+
+On Error Resume Next
+Set WebObj = GetObject("IIS://LocalHost/W3SVC")
+if (Err = 0) then
+
+  'Get the INSTALLDIR and SHIB_FILE_EXTENSION values via CustomActionData
+  customData = Session.Property("CustomActionData")
+  msiProperties = split(customData,";@;")
+  InstallDir = msiProperties(0)
+  ShibFileExtension = msiProperties(1)
+
+  'Remove all trailing backslashes to normalize
+  do while (mid(InstallDir,Len(InstallDir),1) = "\")
+    InstallDir = mid(InstallDir,1,Len(InstallDir)-1)
+  loop
+  ShibISAPIPath = InstallDir & "\libexec\isapi_shib.dll"
+  'Make sure ShibFileExtension is in proper format
+  'First, strip any preceding periods
+  do while (mid(ShibFileExtension,1,1) = ".")
+    ShibFileExtension = mid(ShibFileExtension,2,Len(ShibFileExtension)-1)
+  loop
+  'If there is nothing left (or was nothing to begin with), use the default
+  if (ShibFileExtension = "") then
+    ShibFileExtension = ".sso"
+  else
+    'Add preceding period
+    ShibFileExtension = "." & ShibFileExtension
+  end if
+
+  'Specify other ISAPI Filter details
+  FilterName = "Shibboleth"
+  FilterPath = ShibISAPIPath
+  FilterDesc = ""
+
+  Set FiltersObj = GetObject("IIS://LocalHost/W3SVC/Filters")
+  LoadOrder = FiltersObj.FilterLoadOrder
+  'Check to see if 'Shibboleth' is already sequenced
+  existsFlag = "not_exist"
+  lineArray = split(LoadOrder, ",")
+  for each line in lineArray
+    if (line = FilterName) then
+      existsFlag = "exists"
+    end if
+  next
+  if (existsFlag = "not_exist") then
+    If LoadOrder <> "" Then
+      LoadOrder = LoadOrder & ","
+    End If
+    LoadOrder = LoadOrder & FilterName
+    FiltersObj.FilterLoadOrder = LoadOrder
+    FiltersObj.SetInfo
+  else
+    'msgbox "Shib Filter already sequenced"
+  end if
+
+  Set FilterObj = FiltersObj.Create("IIsFilter", FilterName)
+  If (Err <> 0) then
+    'Open existing filter for updating
+    Err = 0
+    Set FilterObj = GetObject("IIS://LocalHost/W3SVC/Filters/" & FilterName)
+  End If
+  FilterObj.FilterPath = FilterPath
+  FilterObj.FilterDescription = FilterDesc
+  FilterObj.SetInfo
+
+  'Create file extension mapping to ISAPI filter
+  ScriptMaps = WebObj.ScriptMaps
+  'Check if exists
+  newScriptLine = ShibFileExtension & "," & ShibISAPIPath & ",1"
+  existsFlag = "not_exist"
+  lineIndex = 0
+  for each line in ScriptMaps
+    lineArray = split(line,",")
+    if (lineArray(0) = ShibFileExtension) then
+      existsFlag = "exists"
+      Exit For
+    end if
+    lineIndex = lineIndex + 1
+  next
+  if (existsFlag = "not_exist") then
+    redim preserve ScriptMaps(UBound(ScriptMaps)+1)
+    ScriptMaps(UBound(ScriptMaps)) = newScriptLine
+    WebObj.ScriptMaps = ScriptMaps
+    WebObj.SetInfo
+  else
+    'msgbox ".sso already exists: " & lineIndex
+    'We already warned user in dialog that this value would be updated
+    ScriptMaps(lineIndex) = newScriptLine
+    WebObj.ScriptMaps = ScriptMaps
+    WebObj.SetInfo
+  end if
+
+
+  'Web Services Extension
+  Err = 0
+  WebSvcExts = WebObj.WebSvcExtRestrictionList
+  if (Err = 0) then
+  newWebSvcExtLine = "1," & ShibISAPIPath & ",1,ShibGroup,Shibboleth Web Service Extension"
+
+    existsFlag = "not_exist"
+    lineIndex = 0
+    for each line in WebSvcExts
+      lineArray = split(line,",")
+      if (lineArray(1) = ShibISAPIPath) then
+        existsFlag = "exists"
+        Exit For
+      end if
+      lineIndex = lineIndex + 1
+    next
+
+    if (existsFlag = "not_exist") then
+      redim preserve WebSvcExts(UBound(WebSvcExts)+1)
+      WebSvcExts(UBound(WebSVCExts)) = newWebSvcExtLine
+      WebObj.WebSvcExtRestrictionList = WebSvcExts
+      WebObj.SetInfo
+    else
+      'msgbox "Shibboleth Web Services Extension already exists: " & lineIndex
+      'We already warned user in dialog that this value would be updated
+      WebSvcExts(lineIndex) = newWebSvcExtLine
+      WebObj.WebSvcExtRestrictionList = WebSvcExts
+      WebObj.SetInfo
+    end if
+
+  end if
+
+'final end if
+end if
\ No newline at end of file
diff --git a/msi/scripts/shib_uninstall_isapi_filter.vbs b/msi/scripts/shib_uninstall_isapi_filter.vbs
new file mode 100644 (file)
index 0000000..8106e94
--- /dev/null
@@ -0,0 +1,125 @@
+Sub DeleteISAPIFilters(IISPath,dllPath)
+
+  Dim filter, FiltersObj, LoadOrder, FilterArray, FilterItem
+
+  Set FiltersObj = GetObject(IISPath & "/Filters")
+  LoadOrder = FiltersObj.FilterLoadOrder
+
+  for each filter in FiltersObj
+    if (filter.Class = "IIsFilter") then
+      if (filter.FilterPath = dllPath) then
+
+        'Delete the found filter here
+        'If there's anything to potentially delete...
+        if (LoadOrder <> "") then
+          FilterArray = split(LoadOrder,",")
+          LoadOrder = ""
+          for each FilterItem in FilterArray
+            if (FilterItem <> filter.Name) then
+              LoadOrder = LoadOrder & FilterItem & ","
+            end if
+          next
+          'Remove trailing comma if any filters were kept
+          if (LoadOrder <> "") then
+            LoadOrder = mid(LoadOrder,1,len(LoadOrder)-1)
+          end if
+
+          'Set the Load Order to the new shibboleth-less order
+          if (FiltersObj.FilterLoadOrder <> LoadOrder) then
+            FiltersObj.FilterLoadOrder = LoadOrder
+            FiltersObj.SetInfo
+          end if
+        end if
+
+        'Delete the actual IISFilter object
+        FiltersObj.Delete "IIsFilter",filter.Name
+
+      end if
+    end if
+  next
+
+End Sub
+
+
+Sub DeleteFileExtensions(siteObj, dllPath)
+
+Dim ScriptMaps, newScriptMaps
+Dim line, lineArray, lineIndex
+Dim fileExtension
+Dim existsFlag
+
+  ScriptMaps = siteObj.ScriptMaps
+  redim newScriptMaps(0)
+  lineIndex = 0
+  'copy each entry from the old ScriptMaps to newScriptMaps
+  'unless it is for dllPath
+  for each line in ScriptMaps
+    lineArray = split(line,",")
+    if (lineArray(1) <> dllPath) then
+      redim preserve newScriptMaps(lineIndex)
+      newScriptMaps(lineIndex) = line
+      lineIndex = lineIndex + 1
+    else
+      existsFlag = "exists"
+    end if
+  next
+  'If we found dllPath, then use the newScriptMaps instead
+  if (existsFlag = "exists") then
+    siteObj.ScriptMaps = newScriptMaps
+    siteObj.SetInfo
+  end if
+
+End Sub
+
+
+'*** Begin Main Code ***
+Dim WebObj
+Dim InstallDir
+Dim ShibISAPIPath
+Dim site, siteObj, sitePath
+
+
+'Don't show errors, we'll handle anything important
+On Error Resume Next
+
+'Attempt to get W3SVC.  If failure, end script (e.g. IIS isn't available)
+Set WebObj = GetObject("IIS://LocalHost/W3SVC")
+if (Err = 0) then
+
+  'Get the INSTALLDIR value via CustomActionData
+  InstallDir = Session.Property("CustomActionData")
+
+  'Remove all trailing backslashes to normalize
+  do while (mid(InstallDir,Len(InstallDir),1) = "\")
+    InstallDir = mid(InstallDir,1,Len(InstallDir)-1)
+  loop
+  ShibISAPIPath = InstallDir & "\libexec\isapi_shib.dll"
+
+  'Delete ISAPI Filter
+  'First do the master service
+  DeleteISAPIFilters "IIS://LocalHost/W3SVC",ShibISAPIPath
+  'Now do the websites
+  for each site in WebObj
+    if (site.Class = "IIsWebServer") then
+      sitePath = "IIS://LocalHost/W3SVC/" & site.Name
+      DeleteISAPIFilters sitePath,ShibISAPIPath
+    end if
+  next
+
+  'Delete File Extensions
+  'First do the master service
+  DeleteFileExtensions WebObj,ShibISAPIPath
+  'Now do the websites
+  for each site in WebObj
+    if (site.Class = "IIsWebServer") then
+      set siteObj = GetObject("IIS://LocalHost/W3SVC/" & site.Name & "/ROOT")
+      DeleteFileExtensions siteObj,ShibISAPIPath
+    end if
+  next
+
+
+  'Delete Web Services Extension (universal, no need to do for each site)
+  WebObj.DeleteExtensionFileRecord ShibISAPIPath
+
+'Last end if
+end if
\ No newline at end of file
diff --git a/msi/scripts/shib_uninstall_old_versions.vbs b/msi/scripts/shib_uninstall_old_versions.vbs
new file mode 100644 (file)
index 0000000..6a7d366
--- /dev/null
@@ -0,0 +1,199 @@
+'In order to get the list of versions to uninstall during deferred mode,
+'We need to set UninstallOldShibVersions property during the Immediate
+'Execution sequence.  We can then read the value via CustomActionData.
+'To accomplish this, create a CA as follows:
+'  Action: SetShibVersionsImmediate
+'  Source: UninstallOldShibVersions
+'  Type:   51
+'  Target: [OLDSHIBVERSIONSFOUND]
+'Sequence this action near the beginning of InstallExecuteSequence with
+'  Condition: (NOT Installed) AND (OLDSHIBVERSIONSFOUND <> "") AND (OLDSHIBPERFORMUNINSTALL = "TRUE")
+
+
+'*********************************
+'* This code is the entire body of shib_uninstall_isapi_filter.vbs
+'* The only exception is that the main function of that code is made
+'* a Sub in this code so we can call it, and we pass it the InstallDir
+'* from the Uninst.isu string instead of pulling it from the MSI.
+'*********************************
+
+Sub DeleteISAPIFilters(IISPath,dllPath)
+
+  Dim filter, FiltersObj, LoadOrder, FilterArray, FilterItem
+
+  Set FiltersObj = GetObject(IISPath & "/Filters")
+  LoadOrder = FiltersObj.FilterLoadOrder
+
+  for each filter in FiltersObj
+    if (filter.Class = "IIsFilter") then
+      if (filter.FilterPath = dllPath) then
+
+        'Delete the found filter here
+        'If there's anything to potentially delete...
+        if (LoadOrder <> "") then
+          FilterArray = split(LoadOrder,",")
+          LoadOrder = ""
+          for each FilterItem in FilterArray
+            if (FilterItem <> filter.Name) then
+              LoadOrder = LoadOrder & FilterItem & ","
+            end if
+          next
+          'Remove trailing comma if any filters were kept
+          if (LoadOrder <> "") then
+            LoadOrder = mid(LoadOrder,1,len(LoadOrder)-1)
+          end if
+
+          'Set the Load Order to the new shibboleth-less order
+          if (FiltersObj.FilterLoadOrder <> LoadOrder) then
+            FiltersObj.FilterLoadOrder = LoadOrder
+            FiltersObj.SetInfo
+          end if
+        end if
+
+        'Delete the actual IISFilter object
+        FiltersObj.Delete "IIsFilter",filter.Name
+
+      end if
+    end if
+  next
+
+End Sub
+
+
+Sub DeleteFileExtensions(siteObj, dllPath)
+
+Dim ScriptMaps, newScriptMaps
+Dim line, lineArray, lineIndex
+Dim fileExtension
+Dim existsFlag
+
+  ScriptMaps = siteObj.ScriptMaps
+  redim newScriptMaps(0)
+  lineIndex = 0
+  'copy each entry from the old ScriptMaps to newScriptMaps
+  'unless it is for dllPath
+  for each line in ScriptMaps
+    lineArray = split(line,",")
+    if (lineArray(1) <> dllPath) then
+      redim preserve newScriptMaps(lineIndex)
+      newScriptMaps(lineIndex) = line
+      lineIndex = lineIndex + 1
+    else
+      existsFlag = "exists"
+    end if
+  next
+  'If we found dllPath, then use the newScriptMaps instead
+  if (existsFlag = "exists") then
+    siteObj.ScriptMaps = newScriptMaps
+    siteObj.SetInfo
+  end if
+
+End Sub
+
+
+Sub CleanUpISAPI(InstallDir)
+
+Dim WebObj
+'Dim InstallDir
+Dim ShibISAPIPath
+Dim site, siteObj, sitePath
+
+
+'Don't show errors, we'll handle anything important
+On Error Resume Next
+
+'Attempt to get W3SVC.  If failure, end script (e.g. IIS isn't available)
+Set WebObj = GetObject("IIS://LocalHost/W3SVC")
+if (Err = 0) then
+
+  'Get the INSTALLDIR value via CustomActionData
+  'Commented out for embedding in this .vbs, passed instead
+'  InstallDir = Session.Property("CustomActionData")
+
+  'Remove all trailing backslashes to normalize
+  do while (mid(InstallDir,Len(InstallDir),1) = "\")
+    InstallDir = mid(InstallDir,1,Len(InstallDir)-1)
+  loop
+  'Set dll Path
+  ShibISAPIPath = InstallDir & "\libexec\isapi_shib.dll"
+
+  'Delete ISAPI Filter
+  'First do the master service
+  DeleteISAPIFilters "IIS://LocalHost/W3SVC",ShibISAPIPath
+  'Now do the websites
+  for each site in WebObj
+    if (site.Class = "IIsWebServer") then
+      sitePath = "IIS://LocalHost/W3SVC/" & site.Name
+      DeleteISAPIFilters sitePath,ShibISAPIPath
+    end if
+  next
+
+  'Delete File Extensions
+  'First do the master service
+  DeleteFileExtensions WebObj,ShibISAPIPath
+  'Now do the websites
+  for each site in WebObj
+    if (site.Class = "IIsWebServer") then
+      set siteObj = GetObject("IIS://LocalHost/W3SVC/" & site.Name & "/ROOT")
+      DeleteFileExtensions siteObj,ShibISAPIPath
+    end if
+  next
+
+
+  'Delete Web Services Extension (universal, no need to do for each site)
+  WebObj.DeleteExtensionFileRecord ShibISAPIPath
+
+'Last end if
+end if
+
+End Sub
+
+
+'******** Begin Main Code ***************
+
+Dim WshShell, WshEnv, versionArray, versionElement, versionNumbers, regValue, UninstallArray, uninstallStr, UninstIsuArray, path, pathArray, NewPathEnv
+
+on error resume next
+Set WshShell = CreateObject("WScript.Shell")
+
+versionNumbers = Session.Property("CustomActionData")
+
+versionArray = split( versionNumbers, vbCRLF )
+
+for each versionElement in versionArray
+  if (versionElement<>"") then
+
+    'if RegRead fails, it won't set regValue, and it will hold the last value instead.  Make sure the 'last' value is ""
+    regValue = ""
+    on error resume next
+      regValue=WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & versionElement & "\UninstallString")
+    if (regValue<>"") then
+      UninstallArray = split( regValue, " -f")
+      'Save off the INSTALLDIR path for later use
+      UninstIsuArray = split(UninstallArray(1),"Uninst.isu")
+      InstallDir = UninstIsuArray(0)
+
+      'Now create the silent uninstall string and execute it
+      uninstallStr=UninstallArray(0) & " -y -a -f" & UninstallArray(1)
+      WshShell.Run( uninstallStr )
+
+      'Remove entry from path environment variable
+      Set WshEnv = WshShell.Environment("SYSTEM")
+      PathEnv = WshEnv("PATH")
+      NewPathEnv = ""
+      PathArray = split(PathEnv,";")
+      for each path in PathArray
+        if ((path<>InstallDir & "lib\") AND (path<>InstallDir & "lib")) then
+          NewPathEnv = NewPathEnv & path & ";"
+        end if
+      next
+      NewPathEnv = mid(NewPathEnv,1,len(NewPathEnv)-1)
+      WshEnv("PATH") = NewPathEnv
+
+      'Clean up all the ISAPI filters and file extension
+      CleanUpISAPI InstallDir
+
+    end if
+
+  end if
+next
\ No newline at end of file
diff --git a/msi/scripts/shib_upgrade_check.vbs b/msi/scripts/shib_upgrade_check.vbs
new file mode 100644 (file)
index 0000000..427032c
--- /dev/null
@@ -0,0 +1,26 @@
+Dim WshShell, versionArray, versionElement, versionNumbers, regValue, foundVersionsStr
+Set WshShell = CreateObject("WScript.Shell")
+
+versionNumbers = Session.Property("OLDSHIBVERSIONSTOUNINSTALL")
+
+versionArray = split( versionNumbers, ";" )
+
+foundVersionsStr = ""
+
+for each versionElement in versionArray
+  if (versionElement<>"") then
+
+    'if RegRead fails, it won't set regValue, and it will hold the last value instead.  Make sure the 'last' value is ""
+    regValue = ""
+    on error resume next
+      regValue=WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Shibboleth " & versionElement & "\UninstallString")
+    if (regValue<>"") then
+      foundVersionsStr = foundVersionsStr & "Shibboleth " & versionElement & vbCRLF
+    end if
+
+  end if
+next
+
+if (foundVersionsStr<>"") then
+  Session.Property("OLDSHIBVERSIONSFOUND") = foundVersionsStr
+end if
\ No newline at end of file