Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gtrevi committed Mar 21, 2024
1 parent 358ca0b commit 636c06e
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions scripts/install_ebpf.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function Stop-eBPFComponents {
Stop-Service "eBPFSvc" -ErrorAction Stop 2>&1 | Write-Log
Write-Log "eBPFSvc service stopped." -ForegroundColor Green
} catch {
throw "Failed to stop 'eBPFSvc' service: $_"
throw "Failed to stop 'eBPFSvc' service: $_."
}
} else {
Write-Log "'eBPFSvc' service is not present (i.e., release build), skipping stopping." -ForegroundColor Green
Expand All @@ -140,7 +140,7 @@ function Stop-eBPFComponents {
Write-Log "$($_.Key) driver stopped." -ForegroundColor Green
}
} catch {
throw "Failed to stop $($_.Key) driver: $_"
throw "Failed to stop $($_.Key) driver: $_."
}
}
}
Expand Down Expand Up @@ -169,8 +169,8 @@ function Install-eBPFComponents
Write-Log("Installing Visual C++ Redistributable from '$VcRedistPath'...")
$process = Start-Process -FilePath $VcRedistPath -ArgumentList "/quiet", "/norestart" -Wait -PassThru
if ($process.ExitCode -ne 0) {
Write-Log("Visual C++ Redistributable installation FAILED. Exit code: $($process.ExitCode)") -ForegroundColor Red
throw ("Visual C++ Redistributable installation FAILED. Exit code: $($process.ExitCode)")
Write-Log("Visual C++ Redistributable installation FAILED. Exit code: $($process.ExitCode).") -ForegroundColor Red
throw ("Visual C++ Redistributable installation FAILED. Exit code: $($process.ExitCode).")
}
Write-Log("Cleaning up...")
Remove-Item $VcRedistPath -Force
Expand Down Expand Up @@ -199,15 +199,15 @@ function Install-eBPFComponents
Write-Log("Installing the eBPF MSI package: 'msiexec.exe $arguments'...")
$process = Start-Process -FilePath msiexec.exe -ArgumentList $arguments -Wait -PassThru
if ($process.ExitCode -ne 0) {
Write-Log("MSI installation FAILED. Exit code: $($process.ExitCode)") -ForegroundColor Red
Write-Log("MSI installation FAILED. Exit code: $($process.ExitCode).") -ForegroundColor Red

# For clear readability within the CICD pipeline and final uploaded log output,
# read each line of the log file and print it (otherwise all the log content is printed as a single line).
Write-Log("Contents of msi-install.log:")
Get-Content -Path "msi-install.log" | ForEach-Object {
Write-Log($_)
}
throw ("MSI installation FAILED. Exit code: $($process.ExitCode)")
throw ("MSI installation FAILED. Exit code: $($process.ExitCode).")
}
Write-Log("eBPF MSI installation completed successfully!") -ForegroundColor Green

Expand Down Expand Up @@ -267,13 +267,24 @@ function Uninstall-eBPFComponents
# This section double-checks that all drivers and services are stopped before proceeding with uninstallation.
# It iterates through each driver and service, retrieving its status, and if any service is found to be running, it throws an error.
$allStopped = $true
$EbpfDrivers.GetEnumerator() | ForEach-Object {
$serviceName = $_.Name
$serviceStatus = (Get-Service $serviceName).Status
if (Get-Service "eBPFSvc" -ErrorAction SilentlyContinue) {
$serviceStatus = (Get-Service "eBPFSvc").Status
if ($serviceStatus -ne "Stopped") {
Write-Log "$serviceName service is not stopped." -ForegroundColor Red
Write-Log "eBPFSvc service is not stopped." -ForegroundColor Red
$allStopped = $false
}
Write-Log "eBPFSvc service stopped." -ForegroundColor Green
} else {
Write-Log "'eBPFSvc' service is not present (i.e., release build), skipping stopping." -ForegroundColor Green
}
$EbpfDrivers.GetEnumerator() | ForEach-Object {
if ($_.Value.IsDriver) {
$driverStatus = (Get-Service $_.Key).Status
if ($driverStatus -ne "Stopped") {
Write-Log "$($_.Key) driver is not stopped." -ForegroundColor Red
$allStopped = $false
}
}
}
if (-not $allStopped) {
throw "One or more services are not stopped."
Expand Down Expand Up @@ -319,7 +330,7 @@ function Uninstall-eBPFComponents
Get-Content -Path "msi-uninstall.log" | ForEach-Object {
Write-Log($_)
}
throw ("MSI uninstallation FAILED. Exit code: $($process.ExitCode)")
throw ("MSI uninstallation FAILED. Exit code: $($process.ExitCode).")
}
Write-Log("MSI uninstallation completed successfully!") -ForegroundColor Green

Expand Down

0 comments on commit 636c06e

Please sign in to comment.