rename posterg → xamxam throughout: nginx conf, scripts, PHP source, docs

This commit is contained in:
Pontoporeia
2026-04-30 10:50:23 +02:00
parent 3e35bbc40f
commit c949cf9481
31 changed files with 283 additions and 267 deletions

View File

@@ -8,12 +8,12 @@ echo "Creating investigation directory..."
mkdir -p ~/crash_investigation
echo "Copying nginx logs..."
sudo cp /var/log/nginx/posterg_error.log ~/crash_investigation/
sudo cp /var/log/nginx/posterg_error.log.1 ~/crash_investigation/ 2>/dev/null || true
sudo cp /var/log/nginx/posterg_access.log ~/crash_investigation/
sudo cp /var/log/nginx/posterg_access.log.1 ~/crash_investigation/ 2>/dev/null || true
sudo cp /var/log/nginx/posterg_error.log.2.gz ~/crash_investigation/ 2>/dev/null || true
sudo cp /var/log/nginx/posterg_access.log.2.gz ~/crash_investigation/ 2>/dev/null || true
sudo cp /var/log/nginx/xamxam_error.log ~/crash_investigation/
sudo cp /var/log/nginx/xamxam_error.log.1 ~/crash_investigation/ 2>/dev/null || true
sudo cp /var/log/nginx/xamxam_access.log ~/crash_investigation/
sudo cp /var/log/nginx/xamxam_access.log.1 ~/crash_investigation/ 2>/dev/null || true
sudo cp /var/log/nginx/xamxam_error.log.2.gz ~/crash_investigation/ 2>/dev/null || true
sudo cp /var/log/nginx/xamxam_access.log.2.gz ~/crash_investigation/ 2>/dev/null || true
echo "Exporting journal from previous boot..."
sudo journalctl -b -1 --no-pager > ~/crash_investigation/journal_previous_boot.log 2>&1
@@ -50,4 +50,4 @@ echo "Total size:"
du -sh ~/crash_investigation/
echo ""
echo "To download to your local machine, run:"
echo " scp -P 3274 -r theophile@posterg.erg.be:~/crash_investigation/ ."
echo " scp -P 3274 -r theophile@xamxam.erg.be:~/crash_investigation/ ."

View File

@@ -1,6 +1,6 @@
#!/bin/bash
# Deploy production nginx configuration for Post-ERG
# Fixes permissions and installs /tmp/posterg.conf into nginx sites-available.
# Deploy production nginx configuration for XAMXAM
# Fixes permissions and installs /tmp/xamxam.conf into nginx sites-available.
#
# Usage: just deploy-nginx (uploads script + config, then runs this)
# or: sudo bash /tmp/deploy-server.sh
@@ -27,8 +27,8 @@ printf "==================================\n\n"
printf "📋 Step 1: Fixing file permissions...\n"
echo "--------------------------------------"
chown -R www-data:posterg /var/www/xamxam/
ok "Ownership: www-data:posterg"
chown -R www-data:xamxam /var/www/xamxam/
ok "Ownership: www-data:xamxam"
find /var/www/xamxam -type d -exec chmod 2775 {} \;
ok "Directories: 2775 (setgid)"
@@ -44,30 +44,30 @@ fi
# Ensure writable cache subdirectories exist for php-fpm (www-data)
mkdir -p /var/www/xamxam/storage/cache/rate_limit
chown -R www-data:posterg /var/www/xamxam/storage/cache
chown -R www-data:xamxam /var/www/xamxam/storage/cache
chmod -R 2775 /var/www/xamxam/storage/cache
ok "Cache dirs: created and owned by www-data:posterg"
ok "Cache dirs: created and owned by www-data:xamxam"
# ── Step 2: Nginx config ──────────────────────────────────────────────────────
printf "\n📋 Step 2: Deploying nginx configuration...\n"
echo "--------------------------------------------"
if [ ! -f "/tmp/posterg.conf" ]; then
err "/tmp/posterg.conf not found — run: just deploy-nginx"
if [ ! -f "/tmp/xamxam.conf" ]; then
err "/tmp/xamxam.conf not found — run: just deploy-nginx"
exit 1
fi
if [ -f "/etc/nginx/sites-available/posterg" ]; then
cp /etc/nginx/sites-available/posterg \
"/etc/nginx/sites-available/posterg.backup.$(date +%Y%m%d_%H%M%S)"
if [ -f "/etc/nginx/sites-available/xamxam" ]; then
cp /etc/nginx/sites-available/xamxam \
"/etc/nginx/sites-available/xamxam.backup.$(date +%Y%m%d_%H%M%S)"
ok "Backed up existing config"
fi
cp /tmp/posterg.conf /etc/nginx/sites-available/posterg
cp /tmp/xamxam.conf /etc/nginx/sites-available/xamxam
ok "Installed new nginx config"
if [ ! -L "/etc/nginx/sites-enabled/posterg" ]; then
ln -s /etc/nginx/sites-available/posterg /etc/nginx/sites-enabled/posterg
if [ ! -L "/etc/nginx/sites-enabled/xamxam" ]; then
ln -s /etc/nginx/sites-available/xamxam /etc/nginx/sites-enabled/xamxam
ok "Created sites-enabled symlink"
fi
@@ -79,8 +79,8 @@ if nginx -t 2>&1; then
ok "Nginx configuration is valid"
else
err "Nginx configuration has errors — restoring backup"
latest=$(ls -t /etc/nginx/sites-available/posterg.backup.* 2>/dev/null | head -1)
[ -n "$latest" ] && cp "$latest" /etc/nginx/sites-available/posterg
latest=$(ls -t /etc/nginx/sites-available/xamxam.backup.* 2>/dev/null | head -1)
[ -n "$latest" ] && cp "$latest" /etc/nginx/sites-available/xamxam
exit 1
fi
@@ -99,6 +99,6 @@ ok "Nginx config installed"
ok "Configuration validated"
ok "Nginx reloaded"
printf "\nVerify:\n"
printf " https://posterg.erg.be/\n"
printf " https://posterg.erg.be/admin/\n"
printf " https://posterg.erg.be/storage/posterg.db (should 403/404)\n"
printf " https://xamxam.erg.be/\n"
printf " https://xamxam.erg.be/admin/\n"
printf " https://xamxam.erg.be/storage/xamxam.db (should 403/404)\n"

View File

@@ -10,7 +10,7 @@ YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
PASSWORD_FILE="/etc/nginx/.htpasswd-posterg"
PASSWORD_FILE="/etc/nginx/.htpasswd-xamxam"
# Check if running as root
if [ "$EUID" -ne 0 ]; then

View File

@@ -2,14 +2,14 @@
# Initialise the Post-ERG SQLite database from schema.sql.
# Safe to run on existing databases — schema uses IF NOT EXISTS / INSERT OR IGNORE.
# Usage:
# scripts/migrate.sh # posterg.db (default)
# scripts/migrate.sh # xamxam.db (default)
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
APP_DIR="$REPO_ROOT/app"
SCHEMA="$APP_DIR/storage/schema.sql"
PROD_DB="$APP_DIR/storage/posterg.db"
PROD_DB="$APP_DIR/storage/xamxam.db"
init_db() {
local db="$1"
@@ -19,4 +19,4 @@ init_db() {
echo " [$label] done"
}
init_db "$PROD_DB" "posterg.db"
init_db "$PROD_DB" "xamxam.db"

View File

@@ -34,12 +34,12 @@ else
echo "✓ Cloned php-live-reload"
fi
# Create posterg.db if needed
if [ ! -f "storage/posterg.db" ]; then
# Create xamxam.db if needed
if [ ! -f "storage/xamxam.db" ]; then
echo ""
echo "📊 Creating posterg.db…"
sqlite3 storage/posterg.db < storage/schema.sql
echo "✓ Created posterg.db"
echo "📊 Creating xamxam.db…"
sqlite3 storage/xamxam.db < storage/schema.sql
echo "✓ Created xamxam.db"
fi
# Create data directories

View File

@@ -22,18 +22,18 @@ die() { printf "${RED}✗${NC} %s\n" "$*" >&2; exit 1; }
# ── Config ────────────────────────────────────────────────────────────────────
# DEPLOY_USER is passed explicitly by the justfile (read from ~/.ssh/config via
# `ssh -G posterg`). Falls back to $SUDO_USER if run manually with sudo.
# `ssh -G xamxam`). Falls back to $SUDO_USER if run manually with sudo.
DEPLOY_USER="${DEPLOY_USER:-${SUDO_USER}}"
[ -n "$DEPLOY_USER" ] || die "DEPLOY_USER is not set. Pass it explicitly: sudo DEPLOY_USER=youruser bash $0"
APP_DIR="/var/www/posterg"
APP_GROUP="posterg"
APP_DIR="/var/www/xamxam"
APP_GROUP="xamxam"
WEB_USER="www-data"
# ─────────────────────────────────────────────────────────────────────────────
printf "🔧 Post-ERG Server Setup\n"
printf "========================\n\n"
# ── 1. Create posterg group ───────────────────────────────────────────────────
# ── 1. Create xamxam group ───────────────────────────────────────────────────
if ! getent group "$APP_GROUP" >/dev/null; then
groupadd "$APP_GROUP"
ok "Created group: $APP_GROUP"
@@ -65,9 +65,9 @@ ok "Ownership: $WEB_USER:$APP_GROUP on $APP_DIR"
# ── 5. Set directory permissions with setgid ──────────────────────────────────
# 2775 = rwxrwsr-x
# - owner (www-data) and group (posterg) can read/write/execute
# - setgid bit ensures new files/dirs inherit the posterg group
# - this is what allows rsync --chown=www-data:posterg to succeed
# - owner (www-data) and group (xamxam) can read/write/execute
# - setgid bit ensures new files/dirs inherit the xamxam group
# - this is what allows rsync --chown=www-data:xamxam to succeed
find "$APP_DIR" -type d -exec chmod 2775 {} \;
ok "Directories: 2775 (setgid) on $APP_DIR/**"