#!/bin/bash # Version 08 # Setup script for new game deployment (dirs only, port check) set -e if [ -z "$1" ]; then echo "Usage: $0 [additional pip packages]" exit 1 fi GAMENAME="$1" DIR="/var/www/$GAMENAME" DOMAIN="$GAMENAME.orangeicebear.at" # Find a free port between 8000–8999 that is not currently in use for i in {8000..8999}; do if ! lsof -iTCP:$i -sTCP:LISTEN -Pn >/dev/null 2>&1; then PORT=$i break fi done if [ -z "$PORT" ]; then echo "[ERROR] No free port found in range 8000–8999" exit 2 fi echo "Using free port $PORT" echo echo "Creating project folder at $DIR" install -d -m 0750 -o games -g games "$DIR/static" echo cd "$DIR" python3 -m venv venv source venv/bin/activate echo "[INFO] Erstelle requirements.txt" echo -e "fastapi\nuvicorn\n${*:2}" | tr ' ' '\n' > requirements.txt pip install -r requirements.txt if pip list | grep -q jinja2; then install -d -m 0750 -o games -g games "$DIR/templates" echo "[INFO] $DIR/templates created" else echo "[INFO] Kein Jinja2 installiert – templates/ wird nicht erstellt" fi echo echo "Creating systemd service" echo "cat > /etc/systemd/system/$GAMENAME.service < "/etc/systemd/system/$GAMENAME.service" < /etc/nginx/sites-available/$DOMAIN <