Skip to content

Commit

Permalink
Fix Bugs and Introduce Enhancements in Install-OVS.ps1 (#5562)
Browse files Browse the repository at this point in the history
* Fix the bug to prevent downloading the SSL library if files exist in the host path.
* Add a parameter to support installing local SSL library.
* Update the SSL download URL to the GitHub link.

Fixes #5479

Signed-off-by: Shuyang Xin <gavinx@vmware.com>
  • Loading branch information
XinShuYang authored Oct 16, 2023
1 parent b71c877 commit ff33739
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions hack/windows/Install-OVS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@
.PARAMETER ImportCertificate
Specifies if a certificate file is needed for OVS package. If true, certificate
will be retrieved from OVSExt.sys and a package.cer file will be generated.
.PARAMETER LocalSSLFile
Specifies the path of a local SSL package to be used for installation.
#>
Param(
[parameter(Mandatory = $false)] [string] $DownloadDir,
[parameter(Mandatory = $false)] [string] $DownloadURL,
[parameter(Mandatory = $false)] [string] $OVSInstallDir = "C:\openvswitch",
[parameter(Mandatory = $false)] [bool] $CheckFileHash = $true,
[parameter(Mandatory = $false)] [string] $LocalFile,
[parameter(Mandatory = $false)] [bool] $ImportCertificate = $true
[parameter(Mandatory = $false)] [bool] $ImportCertificate = $true,
[parameter(Mandatory = $false)] [string] $LocalSSLFile
)

$ErrorActionPreference = "Stop"
Expand Down Expand Up @@ -201,30 +205,41 @@ function InstallOVS() {

function InstallDependency() {
# Check if SSL library has been installed
$pathEntries = $env:Path.Split(";") | ForEach-Object {
if ((Test-Path "$_/ssleay32.dll" -PathType Leaf) -and (Test-Path "$_/libeay32.dll" -PathType Leaf)) {
$paths = $env:Path.Split(";")
foreach($path in $paths) {
if ((Test-Path "$path/ssleay32.dll" -PathType Leaf) -and (Test-Path "$path/libeay32.dll" -PathType Leaf)) {
Log "Found existing SSL library."
return
}
}
$SSLZip = "openssl-1.0.2u-x64_86-win64.zip"
$SSLMD5 = "E723E1C479983F35A0901243881FA046"
$SSLDownloadURL = "https://indy.fulgan.com/SSL/$SSLZip"
curl.exe -LO $SSLDownloadURL
If (!$?) {
Log "Download SSL files failed, URL: $SSLDownloadURL"
Log "Please install ssleay32.dll and libeay32.dll to $OVSInstallDir\usr\sbin\ manually"
exit 1
}
$MD5Result = Get-FileHash $SSLZip -Algorithm MD5 | Select -ExpandProperty "Hash"
If ($MD5Result -ne $SSLMD5){
Log "Wrong md5sum, Please check the file integrity"
exit 1
if ($LocalSSLFile) {
if ($LocalSSLFile -like "*.zip") {
Log "Install local SSL library."
Expand-Archive $LocalSSLFile -DestinationPath openssl
} else {
Log "The local SSL package must be in ZIP format, exit"
exit 1
}
} else {
$SSLZip = "openssl-1.0.2u-x64_86-win64.zip"
$SSLMD5 = "E723E1C479983F35A0901243881FA046"
$SSLDownloadURL = "https://github.com/IndySockets/OpenSSL-Binaries/raw/21d81384bfe589273e6b2ac1389c40e8f0ca610d/$SSLZip"
curl.exe -LO $SSLDownloadURL
If (!$?) {
Log "Download SSL files failed, URL: $SSLDownloadURL"
Log "Please install ssleay32.dll and libeay32.dll to $OVSInstallDir\usr\sbin\ manually"
exit 1
}
$MD5Result = Get-FileHash $SSLZip -Algorithm MD5 | Select -ExpandProperty "Hash"
If ($MD5Result -ne $SSLMD5){
Log "Wrong md5sum, Please check the file integrity"
exit 1
}
Expand-Archive $SSLZip -DestinationPath openssl
rm $SSLZip
}
Expand-Archive $SSLZip -DestinationPath openssl
cp -Force openssl/*.dll $OVSInstallDir\usr\sbin\
rm -Recurse -Force openssl
rm $SSLZip
}

function ConfigOVS() {
Expand Down

0 comments on commit ff33739

Please sign in to comment.