Files
mitm-webserver/start_dev.sh
malmert 0615d83134
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 8s
feat: add netplan configuration models and backend API for applying netplan
2025-11-22 23:25:39 +01:00

93 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
set -e
# Kill children on exit
cleanup() {
echo
echo "🛑 Stopping dev environment…"
kill 0 2>/dev/null
}
trap cleanup EXIT
START_BE=true
START_FE=true
case "$1" in
backend|be)
START_FE=false
;;
frontend|fe)
START_BE=false
;;
"" )
# default → both
;;
* )
echo "❌ Unknown argument: $1"
echo "Usage:"
echo " ./dev.sh → start both"
echo " ./dev.sh be → start backend only"
echo " ./dev.sh fe → start frontend only"
exit 1
;;
esac
###############################
# Backend
###############################
if [ "$START_BE" = true ]; then
(
echo "🚀 Starting backend…"
cd backend || { echo "❌ backend folder missing"; exit 1; }
if [ ! -d venv ]; then
echo "⚙️ Creating virtual environment…"
python3 -m venv venv
./venv/bin/pip install -r requirements.txt
fi
echo "📡 Backend at http://localhost:8000"
./venv/bin/uvicorn src.main:app --reload --host 0.0.0.0 --port 8000
) &
BE_PID=$!
else
echo "⏭ Skipping backend"
fi
###############################
# Frontend
###############################
if [ "$START_FE" = true ]; then
(
echo "🚀 Starting frontend…"
cd frontend || { echo "❌ frontend folder missing"; exit 1; }
if [ ! -d node_modules ]; then
echo "📦 Installing frontend dependencies…"
npm install
fi
echo "🌍 Frontend at http://localhost:5173"
npm run dev-local
) &
FE_PID=$!
else
echo "⏭ Skipping frontend"
fi
###############################
# Wait for both
###############################
echo
echo "💡 Dev environment running."
[ "$START_BE" = true ] && echo " Backend PID: $BE_PID"
[ "$START_FE" = true ] && echo " Frontend PID: $FE_PID"
echo " Press CTRL+C to stop everything."
echo
wait