#!/usr/bin/env bash # # PQS local test-stack setup (WSL2 Ubuntu / Debian). # # Stands up a throwaway PHP + MariaDB stack that mirrors the venue server # (Debian-family) closely enough to test PQS before deploying. # # Run once from inside WSL: # bash dev/setup-local.sh # # It will prompt for your sudo password (to install packages + start the DB). # Safe to re-run; it is idempotent. set -euo pipefail # Resolve repo root from this script's location (dev/ is one level down). SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" DB_NAME="pqs" DB_USER="pqs" DB_PASS="pqs" # matches includes/config.php; fine on an air-gapped/local box SCHEMA="$REPO_ROOT/docs/pqs.sql" echo "==> Repo root: $REPO_ROOT" echo "==> Installing php-cli, php-mysql, mariadb-server ..." sudo apt-get update -y sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php-cli php-mysql mariadb-server echo "==> Starting MariaDB ..." sudo service mariadb start || sudo service mysql start echo "==> Creating database '$DB_NAME' and user '$DB_USER' ..." sudo mariadb < Loading schema from $SCHEMA ..." sudo mariadb "$DB_NAME" < "$SCHEMA" echo "==> Verifying ..." php -r 'echo "PHP ".PHP_VERSION." / mysqli ".(extension_loaded("mysqli")?"ok":"MISSING")."\n";' mysql -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" -e "SHOW TABLES;" 2>/dev/null cat < Done. To serve the app (from the repo root, so URLs keep the /pqs/ prefix): cd "$(dirname "$REPO_ROOT")" php -S 0.0.0.0:8080 -t "$(dirname "$REPO_ROOT")" then open http://localhost:8080/$(basename "$REPO_ROOT")/callsign.php (The app has some hardcoded /pqs/ redirect URLs; serving the PARENT of the repo means http://localhost:8080/PQS/... resolves those. On /mnt/c the filesystem is case-insensitive so /pqs and /PQS both work.) If MariaDB isn't running after a WSL restart: sudo service mariadb start EOF