From c556b4dfae0e9cf55a5870cc28dc53ee601a109d Mon Sep 17 00:00:00 2001 From: Michael Friesen <3517159+mtfriesen@users.noreply.github.com> Date: Wed, 1 Feb 2023 18:13:25 -0500 Subject: [PATCH] Add support for deploying eBPF to arbitrary filesystem locations (#1995) * add support for deploying ebpf to arbitrary filesystem locations * fix typo * add documentation * fix coding style --- docs/InstallEbpf.md | 4 ++++ scripts/deploy-ebpf.ps1.in | 21 +++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/docs/InstallEbpf.md b/docs/InstallEbpf.md index 3766e590c..875bc7809 100644 --- a/docs/InstallEbpf.md +++ b/docs/InstallEbpf.md @@ -71,6 +71,10 @@ has already built the binaries for `x64/Debug` or `x64/Release`. ```ps .\x64\debug\deploy-ebpf --vm="" -t ``` + or, to copy files to a specific directory, including file shares, run: + ```ps + .\x64\debug\deploy-ebpf -l="c:\some\path" + ``` 2. From within the VM, install the binaries by starting an administrator Command Prompt shell (cmd.exe) , and running the following commands: diff --git a/scripts/deploy-ebpf.ps1.in b/scripts/deploy-ebpf.ps1.in index 3792d95e2..97af5c977 100644 --- a/scripts/deploy-ebpf.ps1.in +++ b/scripts/deploy-ebpf.ps1.in @@ -179,7 +179,7 @@ OVERVIEW: Copies eBPF framework files into a temp directory on the local machine or into a VM - $ deploy-ebpf [--dir="..."] [-h] [-l] [-m] [-t] [--vm="..."] + $ deploy-ebpf [--dir="..."] [-h] [-l[=path]] [-m] [-t] [--vm="..."] OPTIONS: --dir Specifies the source directory path, which defaults to "." @@ -202,8 +202,11 @@ OPTIONS: $vm=($arg -split "=")[1]; break } - { @("-l", "--local") -contains $_ } + "^(?:-l|--list)(?:=(.+))?$" { + if ($matches[1]) { + $destination_directory = $matches[1] + } Clear-Variable -name vm break } @@ -234,22 +237,24 @@ if ($vm -eq $null) { foreach ( $file in $built_files ) { $source_path = "$build_directory\$file" $destination_path = "$destination_directory\$file" + $destination_full_directory = Split-Path $destination_path Write-Host " $source_path -> $destination_path" - Copy-Item "$source_path" -Destination "$destination_path" - if (! $?) { - exit 1 + if (! (Test-Path $destination_full_directory)) { + New-Item -Type Directory $destination_full_directory -ErrorAction Stop | Write-Verbose } + Copy-Item "$source_path" -Destination "$destination_path" -ErrorAction Stop } Write-Host "Copying files from `"$source_directory`" to `"$destination_directory`"" foreach ( $file in $source_files ) { $source_path = "$source_directory\$file" $destination_path = "$destination_directory\$file" + $destination_full_directory = Split-Path $destination_path Write-Host " $source_path -> $destination_path" - Copy-Item "$source_path" -Destination "$destination_path" - if (! $?) { - exit 1 + if (! (Test-Path $destination_full_directory)) { + New-Item -Type Directory $destination_full_directory -ErrorAction Stop | Write-Verbose } + Copy-Item "$source_path" -Destination "$destination_path" -ErrorAction Stop } exit 0 }