-
Notifications
You must be signed in to change notification settings - Fork 0
/
ubuntu-vm.yaml
70 lines (61 loc) · 2.22 KB
/
ubuntu-vm.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
images:
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-arm64.img"
arch: "aarch64"
mounts:
- location: "~"
writable: true
provision:
- mode: system
script: |
#!/bin/bash
set -e
# Update and install required packages
sudo apt-get update
sudo apt-get install -y bpfcc-tools linux-headers-$(uname -r)
sudo apt-get install -y build-essential pkg-config libssl-dev git
sudo snap install go --classic
sudo apt install -y llvm clang libbpf-dev graphviz
sudo ln -s /usr/include/asm-generic /usr/include/asm
# Install kernel tools
sudo apt install -y linux-tools-$(uname -r)
# Clone and install bpftool
git clone --recurse-submodules "https://github.com/libbpf/bpftool.git"
cd bpftool/src
sudo make install
cd ../..
# Add /usr/sbin to PATH in the user's shell configuration file
user_shell=$(basename "$SHELL")
# Determine the correct shell config file
case "$user_shell" in
bash)
config_file="$HOME/.bashrc"
;;
zsh)
config_file="$HOME/.zshrc"
;;
ksh)
config_file="$HOME/.kshrc"
;;
*)
echo "Unsupported shell: $user_shell"
exit 1
;;
esac
# Append export statement to the shell's config file if not already present
if ! grep -q 'export PATH=/usr/sbin:$PATH' "$config_file"; then
echo 'export PATH=/usr/sbin:$PATH' >> "$config_file"
echo "Added export statement to $config_file"
else
echo "Export statement already exists in $config_file"
fi
# Install Rust and additional tools
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
source "$HOME/.cargo/env"
rustup default stable
rustup toolchain add nightly
rustup component add rust-src --toolchain nightly
cargo install cargo-generate
cargo install bpf-linker
cargo install bindgen-cli