Skip to content

Commit 0c737e4

Browse files
reliability improvements
1 parent dc0b419 commit 0c737e4

File tree

2 files changed

+134
-32
lines changed

2 files changed

+134
-32
lines changed

packer/base/install/install_bcc.sh

Lines changed: 75 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,90 @@
11
#!/usr/bin/env bash
2+
set -euo pipefail
23

3-
BCC_VERSION=0.31.0
4+
BCC_VERSION=0.35.0
5+
WORK_DIR=""
46

7+
# Cleanup function for trap
8+
cleanup() {
9+
if [ -n "$WORK_DIR" ] && [ -d "$WORK_DIR" ]; then
10+
echo "Cleaning up temporary directory..."
11+
sudo rm -rf "$WORK_DIR"
12+
fi
13+
}
14+
15+
trap cleanup EXIT
16+
17+
# Check if BCC is already installed
18+
if command -v bcc-lua &> /dev/null; then
19+
INSTALLED_VERSION=$(dpkg -l | grep bpfcc-tools | awk '{print $3}' || echo "unknown")
20+
echo "BCC already installed (version: $INSTALLED_VERSION), skipping installation"
21+
exit 0
22+
fi
23+
24+
echo "Installing BCC version ${BCC_VERSION}..."
25+
26+
# Remove any existing BCC installations
27+
echo "Removing existing BCC packages..."
528
sudo apt update
6-
sudo apt purge bpfcc-tools libbpfcc python3-bpfcc
29+
sudo apt purge -y bpfcc-tools libbpfcc python3-bpfcc || true
30+
31+
# Install build dependencies
32+
echo "Installing build dependencies..."
733
sudo apt install -y zip bison build-essential cmake flex git libedit-dev \
834
libllvm14 llvm-14-dev libclang-14-dev python3 zlib1g-dev libelf-dev libfl-dev python3-setuptools \
935
liblzma-dev libdebuginfod-dev arping netperf iperf
1036

11-
wget https://github.com/iovisor/bcc/releases/download/v${BCC_VERSION}/bcc-src-with-submodule.tar.gz
12-
tar xf bcc-src-with-submodule.tar.gz
37+
# Create temp directory for build
38+
WORK_DIR=$(mktemp -d)
39+
cd "$WORK_DIR"
40+
41+
# Download BCC source
42+
echo "Downloading BCC ${BCC_VERSION}..."
43+
wget -q --show-progress "https://github.com/iovisor/bcc/releases/download/v${BCC_VERSION}/bcc-src-with-submodule.tar.gz"
1344

45+
# Verify download succeeded and has content
46+
if [ ! -s bcc-src-with-submodule.tar.gz ]; then
47+
echo "ERROR: Download failed or file is empty"
48+
exit 1
49+
fi
1450

15-
# from https://github.com/iovisor/bcc/blob/master/INSTALL.md
51+
echo "Extracting source..."
52+
tar xf bcc-src-with-submodule.tar.gz
53+
54+
# Create python symlink if needed (idempotent)
55+
if [ ! -e /usr/bin/python ]; then
56+
echo "Creating python symlink..."
57+
sudo ln -s /usr/bin/python3 /usr/bin/python
58+
fi
1659

60+
# Build and install BCC
61+
# Reference: https://github.com/iovisor/bcc/blob/master/INSTALL.md
62+
echo "Building BCC (this may take several minutes)..."
1763
cd bcc/
18-
sudo ln -s /usr/bin/python3 /usr/bin/python
1964
mkdir build
2065
cd build/
21-
cmake ..
22-
make
23-
sudo make install
24-
cmake -DPYTHON_CMD=/usr/bin/python3 .. # build python3 binding
25-
pushd src/python/
26-
make
27-
sudo make install
28-
popd
29-
30-
# cleanup
31-
cd
32-
sudo rm -rf bcc bcc-src-with-submodule.tar.gz
3366

67+
echo "Running cmake..."
68+
cmake .. > /dev/null
69+
70+
echo "Compiling..."
71+
make -j$(nproc)
72+
73+
echo "Installing BCC..."
74+
sudo make install > /dev/null
75+
76+
echo "Building Python3 bindings..."
77+
cmake -DPYTHON_CMD=/usr/bin/python3 .. > /dev/null
78+
pushd src/python/ > /dev/null
79+
make -j$(nproc)
80+
sudo make install > /dev/null
81+
popd > /dev/null
82+
83+
# Verify installation
84+
echo "Verifying BCC installation..."
85+
if ! python3 -c "import bcc" 2>/dev/null; then
86+
echo "ERROR: BCC Python module not found after installation"
87+
exit 1
88+
fi
89+
90+
echo "BCC ${BCC_VERSION} installed successfully"

packer/base/install/install_fio.sh

Lines changed: 59 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,64 @@
1-
#!/bin/bash
2-
3-
set -x
1+
#!/usr/bin/env bash
2+
set -euo pipefail
43

54
VERSION="3.37"
5+
WORK_DIR=""
6+
7+
# Cleanup function for trap
8+
cleanup() {
9+
if [ -n "$WORK_DIR" ] && [ -d "$WORK_DIR" ]; then
10+
echo "Cleaning up temporary directory..."
11+
rm -rf "$WORK_DIR"
12+
fi
13+
}
14+
15+
trap cleanup EXIT
16+
17+
# Check if fio is already installed
18+
if command -v fio &> /dev/null; then
19+
INSTALLED_VERSION=$(fio --version 2>&1 | head -n1 | awk '{print $2}' || echo "unknown")
20+
echo "fio already installed (version: $INSTALLED_VERSION), skipping installation"
21+
exit 0
22+
fi
23+
24+
echo "Installing fio version ${VERSION}..."
25+
26+
# Create temp directory for build
27+
WORK_DIR=$(mktemp -d)
28+
cd "$WORK_DIR"
29+
30+
# Download fio source
31+
echo "Downloading fio ${VERSION}..."
32+
wget -q --show-progress "https://github.com/axboe/fio/archive/refs/tags/fio-${VERSION}.zip"
33+
34+
# Verify download succeeded and has content
35+
if [ ! -s "fio-${VERSION}.zip" ]; then
36+
echo "ERROR: Download failed or file is empty"
37+
exit 1
38+
fi
39+
40+
echo "Extracting source..."
41+
unzip -q "fio-${VERSION}.zip"
42+
43+
# Build and install fio
44+
echo "Building fio (this may take a few minutes)..."
45+
cd fio-fio-${VERSION}
46+
47+
echo "Running configure..."
48+
./configure > /dev/null
49+
50+
echo "Compiling..."
51+
make -j$(nproc)
652

7-
mkdir fio
8-
cd fio
9-
wget "https://github.com/axboe/fio/archive/refs/tags/fio-${VERSION}.zip"
10-
unzip fio-*.zip
53+
echo "Installing fio..."
54+
sudo make install > /dev/null
1155

12-
( # subshell
13-
cd fio-fio*
14-
./configure
15-
make
16-
sudo make install
17-
)
56+
# Verify installation
57+
echo "Verifying fio installation..."
58+
if ! command -v fio &> /dev/null; then
59+
echo "ERROR: fio command not found after installation"
60+
exit 1
61+
fi
1862

19-
rm -rf fio
63+
INSTALLED_VERSION=$(fio --version 2>&1 | head -n1)
64+
echo "fio installed successfully: $INSTALLED_VERSION"

0 commit comments

Comments
 (0)