Files
runtipi/apps/rego-tunnel/build/start-vm.sh
alexz 9bde91f047
Some checks failed
Test / test (push) Has been cancelled
fix(rego-tunnel): exclude swap files from ssh.zip
2025-12-28 14:08:32 +00:00

39 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# If provided, extract ssh.zip to /root/.ssh/zip (not baked into the image)
SSH_ZIP_PATH="/shared/ssh.zip"
SSH_ZIP_DEST="/root/.ssh/zip"
if [ -f "$SSH_ZIP_PATH" ]; then
mkdir -p "$SSH_ZIP_DEST"
chmod 700 /root/.ssh
chmod 700 "$SSH_ZIP_DEST"
echo "[rego-tunnel] Extracting $SSH_ZIP_PATH -> $SSH_ZIP_DEST"
# Exclude editor swap/backup files; overwrite existing.
7z x -y -aoa -o"$SSH_ZIP_DEST" "$SSH_ZIP_PATH" \
-x!*.swp -x!*.swo -x!*.swx -x!*~ -x!.DS_Store >/dev/null
find "$SSH_ZIP_DEST" -type d -exec chmod 700 {} \;
find "$SSH_ZIP_DEST" -type f -exec chmod 600 {} \;
else
echo "[rego-tunnel] No $SSH_ZIP_PATH found; skipping SSH zip extraction"
fi
# Wait for network setup
sleep 2
exec qemu-system-x86_64 \
-enable-kvm \
-cpu host \
-m ${VM_RAM:-8G} \
-smp ${VM_CPUS:-4} \
-hda /vm/linux-vm.qcow2 \
-netdev tap,id=net0,ifname=tap0,script=no,downscript=no \
-device virtio-net-pci,netdev=net0,mac=52:54:00:12:34:56 \
-vnc :0 \
-vga virtio \
-usb \
-device usb-tablet