fix: replace build_bee_debug with proper apkovl mechanism for Alpine LiveCD
- genapkovl-bee_debug.sh: creates apkovl tarball with overlay files, /etc/apk/world package list, runlevel symlinks, dropbear config - mkimg.bee_debug.sh: set hostname/apkovl, remove invalid build_bee_debug
This commit is contained in:
112
iso/builder/genapkovl-bee_debug.sh
Executable file
112
iso/builder/genapkovl-bee_debug.sh
Executable file
@@ -0,0 +1,112 @@
|
||||
#!/bin/sh -e
|
||||
# genapkovl-bee_debug.sh — generate apkovl for bee debug LiveCD
|
||||
# Called by mkimage.sh: receives hostname as , must create .apkovl.tar.gz
|
||||
|
||||
HOSTNAME="$1"
|
||||
if [ -z "$HOSTNAME" ]; then
|
||||
echo "usage: $0 hostname"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OVERLAY="${BEE_OVERLAY_DIR}"
|
||||
if [ -z "$OVERLAY" ]; then
|
||||
echo "ERROR: BEE_OVERLAY_DIR not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cleanup() { rm -rf "$tmp"; }
|
||||
tmp="$(mktemp -d)"
|
||||
trap cleanup EXIT
|
||||
|
||||
makefile() {
|
||||
OWNER="$1" PERMS="$2" FILENAME="$3"
|
||||
cat > "$FILENAME"
|
||||
chown "$OWNER" "$FILENAME"
|
||||
chmod "$PERMS" "$FILENAME"
|
||||
}
|
||||
|
||||
rc_add() {
|
||||
mkdir -p "$tmp/etc/runlevels/$2"
|
||||
ln -sf /etc/init.d/"$1" "$tmp/etc/runlevels/$2/$1"
|
||||
}
|
||||
|
||||
# --- hostname ---
|
||||
mkdir -p "$tmp/etc"
|
||||
makefile root:root 0644 "$tmp/etc/hostname" <<EOF
|
||||
$HOSTNAME
|
||||
EOF
|
||||
|
||||
# --- packages to install at boot ---
|
||||
mkdir -p "$tmp/etc/apk"
|
||||
makefile root:root 0644 "$tmp/etc/apk/world" <<EOF
|
||||
alpine-base
|
||||
dmidecode
|
||||
smartmontools
|
||||
nvme-cli
|
||||
pciutils
|
||||
ipmitool
|
||||
util-linux
|
||||
lsblk
|
||||
e2fsprogs
|
||||
lshw
|
||||
dropbear
|
||||
libqrencode-tools
|
||||
tzdata
|
||||
ca-certificates
|
||||
strace
|
||||
procps
|
||||
lsof
|
||||
file
|
||||
less
|
||||
vim
|
||||
EOF
|
||||
|
||||
# --- standard sysinit/boot/shutdown services ---
|
||||
rc_add devfs sysinit
|
||||
rc_add dmesg sysinit
|
||||
rc_add mdev sysinit
|
||||
rc_add hwdrivers sysinit
|
||||
rc_add modloop sysinit
|
||||
|
||||
rc_add hwclock boot
|
||||
rc_add modules boot
|
||||
rc_add sysctl boot
|
||||
rc_add hostname boot
|
||||
rc_add bootmisc boot
|
||||
rc_add syslog boot
|
||||
|
||||
rc_add mount-ro shutdown
|
||||
rc_add killprocs shutdown
|
||||
rc_add savecache shutdown
|
||||
|
||||
# --- bee services ---
|
||||
for svc in bee-sshsetup bee-network dropbear bee-audit-debug; do
|
||||
rc_add "$svc" default
|
||||
done
|
||||
|
||||
# --- copy overlay etc/ (init.d scripts, motd, etc.) ---
|
||||
if [ -d "$OVERLAY/etc" ]; then
|
||||
cp -r "$OVERLAY/etc/." "$tmp/etc/"
|
||||
fi
|
||||
|
||||
# --- copy overlay usr/ (bee-network.sh, audit binary) ---
|
||||
if [ -d "$OVERLAY/usr" ]; then
|
||||
mkdir -p "$tmp/usr"
|
||||
cp -r "$OVERLAY/usr/." "$tmp/usr/"
|
||||
fi
|
||||
|
||||
# --- copy root/.ssh/authorized_keys if present ---
|
||||
if [ -d "$OVERLAY/root" ]; then
|
||||
mkdir -p "$tmp/root"
|
||||
cp -r "$OVERLAY/root/." "$tmp/root/"
|
||||
chmod 700 "$tmp/root/.ssh" 2>/dev/null || true
|
||||
chmod 600 "$tmp/root/.ssh/authorized_keys" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# --- dropbear: enable root login ---
|
||||
mkdir -p "$tmp/etc/dropbear" "$tmp/etc/conf.d"
|
||||
makefile root:root 0644 "$tmp/etc/conf.d/dropbear" <<EOF
|
||||
DROPBEAR_OPTS="-R"
|
||||
EOF
|
||||
|
||||
tar -c -C "$tmp" etc usr root 2>/dev/null | gzip -9n > "$HOSTNAME.apkovl.tar.gz"
|
||||
@@ -1,12 +1,12 @@
|
||||
#!/bin/sh
|
||||
# Alpine mkimage profile: bee_debug
|
||||
# Minimal LiveCD with audit binary + SSH for development/testing.
|
||||
# No NVIDIA driver. SSH root login enabled.
|
||||
|
||||
profile_bee_debug() {
|
||||
title="Bee Hardware Audit (debug)"
|
||||
desc="Hardware audit LiveCD with SSH access for testing"
|
||||
arch="x86_64"
|
||||
hostname="alpine-bee"
|
||||
apkovl="genapkovl-bee_debug.sh"
|
||||
image_ext="iso"
|
||||
output_format="iso"
|
||||
kernel_flavors="lts"
|
||||
@@ -43,21 +43,4 @@ profile_bee_debug() {
|
||||
less
|
||||
vim
|
||||
"
|
||||
|
||||
# overlay is applied after package install
|
||||
# contains: audit binary, dropbear init, authorized_keys
|
||||
}
|
||||
|
||||
build_bee_debug() {
|
||||
# BEE_OVERLAY_DIR is exported by build-debug.sh (absolute path).
|
||||
local overlay="${BEE_OVERLAY_DIR}"
|
||||
if [ -d "$overlay" ]; then
|
||||
cp -r "${overlay}/." "${ROOTFS}/"
|
||||
fi
|
||||
|
||||
# enable services
|
||||
_bootscript default bee-sshsetup
|
||||
_bootscript default dropbear
|
||||
_bootscript default bee-network
|
||||
_bootscript default bee-audit-debug
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user