Skip to content

Commit d02810f

Browse files
authored
renamed scripts + lint (#53)
* renamed scripts + lint * v0.10.0 * shellcheck * storage checks * create * destroy * storage * debugged scripts * almost done * fixed name * linter fix * testcase dir * lit fix
1 parent 40e4c11 commit d02810f

43 files changed

Lines changed: 1074 additions & 604 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,22 @@ jobs:
5555
env:
5656
CGO_ENABLED: 1
5757

58+
shellcheck:
59+
name: Shellcheck
60+
runs-on: ubuntu-latest
61+
permissions:
62+
contents: read
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@v6
66+
- name: Run ShellCheck
67+
uses: ludeeus/action-shellcheck@master
68+
with:
69+
version: v0.10.0
70+
5871
build-and-package:
5972
name: Build, Deb (${{ matrix.arch }})
60-
needs: test
73+
needs: [test, shellcheck]
6174
runs-on: ubuntu-latest
6275
container: debian:trixie
6376
strategy:

BENCHMARK.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ scp -r ./benchmark proxmox:/benchmark
1414

1515
ssh to your proxmox
1616

17+
#XXXXXXXXXXXXXXX THIS IS BROKEN atm
18+
1719
```bash
1820
cd /benchmark
1921

@@ -41,6 +43,35 @@ cd /benchmark
4143
/benchmark/scripts/orchestrator.py -t helloworld -v
4244
# run quiet (only the step names)
4345
/benchmark/scripts/orchestrator.py -t helloworld -q
46+
47+
## vm wariant - /benchmark/scripts/vm-to-testcase-template.sh 101 helloworld /benchmark/testcase/helloworld init.sh /benchmark/scripts/cleanup-debian-for-template.sh
48+
49+
50+
/benchmark/scripts/vm-destroy.sh 101 --force
51+
#/benchmark/scripts/vm-create.sh 101 1002 --full
52+
/benchmark/scripts/vm-create.sh 101 1002
53+
/benchmark/scripts/vm-start.sh 101
54+
/benchmark/scripts/vm-wait-for-agent.sh 101
55+
56+
/benchmark/scripts/vm-to-testcase-template.sh 101 helloworld /benchmark/testcase/helloworld init.sh /benchmark/scripts/cleanup-debian-for-template.sh
57+
58+
/benchmark/scripts/vm-create.sh 102 101 || true
59+
/benchmark/scripts/vm-create.sh 103 101 || true
60+
61+
/benchmark/scripts/vm-start.sh 102
62+
/benchmark/scripts/vm-start.sh 103
63+
64+
/benchmark/scripts/vm-wait-for-agent.sh 102
65+
/benchmark/scripts/vm-wait-for-agent.sh 103
66+
67+
# https://stackoverflow.com/questions/22381686/how-can-size-of-the-root-disk-in-google-compute-engine-be-increased
68+
# resize hack
69+
# $ sudo apt install -y cloud-utils # Debian jessie
70+
# $ sudo apt install -y cloud-guest-utils # Debian stretch, Ubuntu
71+
# $ sudo growpart /dev/sda 1
72+
# $ sudo resize2fs /dev/sda1
73+
74+
4475
```
4576

4677
## Results

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all deps build clean test coverage lint tidy deploy deb get-status-core-ranking get-status-svg run-service run-status
1+
.PHONY: all deps build clean test coverage lint lint-benchmark tidy deploy deb get-status-core-ranking get-status-svg run-service run-status
22

33
VERSION ?= 0.0.10
44

@@ -51,6 +51,9 @@ lint:
5151
gosec ./...
5252
govulncheck ./...
5353

54+
lint-shellcheck:
55+
find . -name "*.sh" -type f -exec shellcheck {} +
56+
5457
tidy:
5558
go mod tidy
5659

benchmark/env.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
########### Proxmox Infrastructure (PVE)
99
#PVE_STORAGE="local-zfs"
10-
#PVE_STORAGE_SNIPPETS="local-zfs"
10+
#PVE_STORAGE_SNIPPETS="local"
11+
#PVE_STORAGE_SNIPPETS_PATH="/var/lib/vz/snippets"
1112
#PVE_VM_SSH_KEY_FILE_PUB="/root/.ssh/id_rsa.pub"
1213
#PVE_VM_SSH_KEY_FILE="/root/.ssh/id_rsa"
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/bin/bash
2+
3+
4+
if [ ! -d "/testcase" ]; then
5+
echo "Error: Testcase path '/testcase' does not exist - ensure this only runs in a Testcase Debian VM."
6+
exit 1
7+
fi
8+
9+
if [ "$(id -u)" -ne 0 ]; then
10+
echo "Error: This script must be run as root."
11+
exit 1
12+
fi
13+
14+
echo "Preparing VM for Template use"
15+
16+
set -x
17+
set -e
18+
19+
echo "--- Updating System ---"
20+
apt update && apt dist-upgrade -y
21+
apt autoremove -y
22+
apt clean
23+
24+
# This overrides the default DUID behavior to use the MAC address.
25+
mkdir -p /etc/systemd/network
26+
27+
cat <<EOF > /etc/systemd/network/99-default.link
28+
[Match]
29+
OriginalName=*
30+
31+
[Link]
32+
MACAddressPolicy=persistent
33+
EOF
34+
35+
cat <<EOF > /etc/systemd/network/99-dhcp-mac.network
36+
[Match]
37+
Name=e*
38+
39+
[Network]
40+
DHCP=ipv4
41+
42+
[DHCPv4]
43+
ClientIdentifier=mac
44+
EOF
45+
46+
# If netplan exists, we append the mac identifier to the config.
47+
if command -v netplan > /dev/null; then
48+
echo "Netplan detected. Applying fix..."
49+
# We can't easily sed YAML, so we ensure a file exists with the override
50+
# This might require manual checking if you have complex netplan configs,
51+
# but for standard templates, this ensures future renders use MAC.
52+
grep -q "dhcp-identifier: mac" /etc/netplan/*.yaml || echo "WARNING: Please manually add 'dhcp-identifier: mac' to your /etc/netplan/ config if you use Netplan."
53+
fi
54+
55+
# Remove the machine-id file and create an empty one.
56+
# Systemd will generate a new unique ID on the next boot.
57+
rm -f /etc/machine-id
58+
touch /etc/machine-id
59+
rm -f /var/lib/dbus/machine-id
60+
ln -s /etc/machine-id /var/lib/dbus/machine-id
61+
rm -f /var/lib/systemd/random-seed
62+
rm -f /var/lib/systemd/duid
63+
rm -f /var/lib/dhcp/*
64+
rm -f /var/lib/NetworkManager/*.lease
65+
66+
# For Standard Debian (ISC-DHCP-Client / ifupdown).
67+
if [ -f /etc/dhcp/dhclient.conf ]; then
68+
# Remove old entry if exists to avoid duplicates
69+
sed -i '/send dhcp-client-identifier/d' /etc/dhcp/dhclient.conf
70+
echo 'send dhcp-client-identifier = hardware;' >> /etc/dhcp/dhclient.conf
71+
fi
72+
73+
# Clean Cloud-init
74+
if dpkg -l | grep -q cloud-init; then
75+
echo "Cloud-init detected. Cleaning logs..."
76+
cloud-init clean --logs --seed
77+
# Remove generated network configs so they regenerate on next boot
78+
rm -f /etc/network/interfaces.d/50-cloud-init
79+
rm -f /etc/netplan/50-cloud-init.yaml
80+
else
81+
echo "Cloud-init not installed. Skipping."
82+
fi
83+
84+
# Keys will be regenerated on the first boot
85+
rm -f /etc/ssh/ssh_host_*
86+
87+
# Clear audit logs, wtmp, btmp and other log files to reduce image size
88+
truncate -s 0 /var/log/wtmp
89+
truncate -s 0 /var/log/btmp
90+
truncate -s 0 /var/log/lastlog
91+
find /var/log -type f -name "*.log" -exec truncate -s 0 {} \;
92+
find /var/log -type f -name "*.gz" -delete
93+
94+
# Clean history
95+
history -c
96+
unset HISTFILE
97+
rm -f /root/.bash_history
98+
rm -f /home/*/.bash_history
99+
100+
# Delete this script
101+
rm -f "$0"

benchmark/scripts/install-dependencies.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#/bin/bash
1+
#!/bin/bash
22

33
set -e
44

55
SCRIPTDIR="$(dirname "$0")"
66

77
if [ -z "$ORCHESTRATOR_MODE" ] && [ -f "${SCRIPTDIR}/../.env" ]; then
8+
# shellcheck disable=SC1091
89
. "${SCRIPTDIR}/../.env"
910
fi
1011

benchmark/scripts/modify-vms-install-hookscript.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)