Add local WSL test-stack setup tooling

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-07-01 12:48:38 -05:00
co-authored by Claude Opus 4.8
parent 00d6ec148e
commit 7d643dde17
2 changed files with 105 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
#!/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 <<SQL
CREATE DATABASE IF NOT EXISTS \`$DB_NAME\`;
CREATE USER IF NOT EXISTS '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';
GRANT ALL PRIVILEGES ON \`$DB_NAME\`.* TO '$DB_USER'@'localhost';
FLUSH PRIVILEGES;
SQL
echo "==> 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 <<EOF
==> 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