chore: add install.sh for backend systemd setup

This commit is contained in:
Claus Lohmar 2026-07-21 15:01:02 +00:00
parent 439b0c51a1
commit be756e33bf

56
backend/install.sh Executable file
View file

@ -0,0 +1,56 @@
#!/bin/bash
set -e
# VM Bench Backend — Installer for Proxmox host (srv2)
# Run: bash /mnt/converter/backend/install.sh
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SERVICE_NAME="vm-bench-backend"
SERVICE_FILE="${SCRIPT_DIR}/${SERVICE_NAME}.service"
SYSTEMD_DIR="/etc/systemd/system"
echo "=== VM Bench Backend Installer ==="
echo ""
# 1. Install Python dependencies
echo "[1/4] Installing Python dependencies..."
cd "$SCRIPT_DIR"
python3 -m pip install --break-system-packages -r requirements.txt -q
echo " Dependencies installed."
# 2. Copy systemd service file
echo "[2/4] Installing systemd service..."
if [ ! -f "$SERVICE_FILE" ]; then
echo " ERROR: ${SERVICE_FILE} not found."
exit 1
fi
cp "$SERVICE_FILE" "$SYSTEMD_DIR/${SERVICE_NAME}.service"
echo " Service file copied to ${SYSTEMD_DIR}/"
# 3. Reload systemd and enable
echo "[3/4] Enabling service..."
systemctl daemon-reload
systemctl enable "$SERVICE_NAME"
echo " Service enabled (auto-start on boot)."
# 4. Start the service
echo "[4/4] Starting service..."
systemctl restart "$SERVICE_NAME"
sleep 2
# Verify
if systemctl is-active --quiet "$SERVICE_NAME"; then
echo ""
echo " Backend is RUNNING on port 9000"
echo ""
echo " Check: curl http://127.0.0.1:9000/health"
echo " Logs: journalctl -u ${SERVICE_NAME} -f"
else
echo ""
echo " WARNING: Service did not start. Check logs:"
echo " journalctl -u ${SERVICE_NAME} -n 30"
exit 1
fi
echo ""
echo "=== Done ==="