Files
os/tools/vm/hotswap.sh
2026-10-24 09:06:06 +02:00

26 lines
1015 B
Bash

#!/usr/bin/env bash
# Rebuilds SmartFox binaries in WSL and swaps them into the running VM (no image rebuild).
# hotswap.sh sf-remote sf-launcher
set -euo pipefail
SRC=/mnt/g/source/smartfox
WORK=/root/smartfox
VM="$WORK/tools/vm"
rsync -a --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r \
--exclude /target --exclude /image/mkosi.output --exclude /image/mkosi.cache --exclude /image/stage --exclude /image/ovmf-vars.fd \
"$SRC/" "$WORK/"
cd "$WORK"
args=()
for c in "$@"; do args+=(-p "$c"); done
~/.cargo/bin/cargo build --release "${args[@]}" 2>&1 | grep -E "^(error|warning)|-->|Finished" -A6 || true
for c in "$@"; do
bash "$VM/vmcp.sh" "target/release/$c" "vm:/usr/bin/$c.new"
bash "$VM/vmssh.sh" "mv /usr/bin/$c.new /usr/bin/$c && chmod 755 /usr/bin/$c"
done
for c in "$@"; do
case "$c" in
sf-remote) bash "$VM/vmssh.sh" "systemctl restart sf-remote" ;;
sf-launcher) bash "$VM/vmssh.sh" "pkill -x sf-launcher || true; systemctl restart getty@tty1" ;;
esac
done
echo "swapped: $*"