forgejo db issues; eod checkin

This commit is contained in:
Mark Randall Havens 2025-05-25 01:27:32 -05:00
parent d2d01d7f63
commit 7c11e6163c
21 changed files with 1529 additions and 43 deletions

66
scripts/diagnose-dev.sh Executable file
View file

@ -0,0 +1,66 @@
#!/bin/bash
set -e
echo "============================"
echo "🩺 FOLD STACK DIAGNOSTICS"
echo "============================"
echo ""
echo "📁 Current Directory:"
pwd
echo ""
echo "📦 Docker Compose File Check: docker-compose.dev.yml"
if grep -q "^services:" docker-compose.dev.yml; then
echo "✅ docker-compose.dev.yml looks valid."
else
echo "⚠️ Missing 'services:' in docker-compose.dev.yml — check formatting."
fi
echo ""
echo "📋 Containers Status:"
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
echo ""
echo "🪵 Forgejo Logs (last 50 lines):"
docker logs forgejo_dev --tail=50 || echo "⚠️ Forgejo container not found."
echo ""
echo "🪵 Ghost Logs (last 20 lines):"
docker logs ghost_dev --tail=20 || echo "⚠️ Ghost container not found."
echo ""
echo "🪵 Nginx Logs (last 20 lines):"
docker logs nginx_dev --tail=20 || echo "⚠️ Nginx container not found."
echo ""
echo "🌐 Port Bindings:"
docker compose -f docker-compose.dev.yml port ghost 2368 || echo "❌ Ghost not exposing port 2368"
docker compose -f docker-compose.dev.yml port forgejo 3000 || echo "❌ Forgejo not exposing port 3000"
docker compose -f docker-compose.dev.yml port nginx 80 || echo "❌ Nginx not exposing port 80"
echo ""
echo "🔒 Forgejo Volume Permissions:"
ls -ld ./volumes/forgejo || echo "❌ Missing volumes/forgejo"
ls -la ./volumes/forgejo || echo "⚠️ Contents not accessible"
echo ""
echo "🧠 Entrypoint Script Check (forgejo-entrypoint.sh):"
head -n 10 scripts/forgejo-entrypoint.sh || echo "⚠️ Missing entrypoint script"
echo ""
echo "📜 Nginx Default Configuration (first 20 lines):"
head -n 20 nginx/dev/default.conf || echo "⚠️ Missing default.conf"
echo ""
echo "📜 Environment Variables (.env.dev):"
if [ -f .env.dev ]; then
cat .env.dev | grep -v '^#'
else
echo "⚠️ .env.dev not found."
fi
echo ""
echo "✅ All checks completed."
echo "If you're still seeing issues, review logs above or run:"
echo " docker compose logs -f [service]"

2
scripts/down-dev.sh Executable file
View file

@ -0,0 +1,2 @@
#!/bin/bash
docker compose -f docker-compose.dev.yml --env-file .env.dev down -v

23
scripts/forgejo-entrypoint.sh Executable file
View file

@ -0,0 +1,23 @@
#!/bin/sh
# Fix ownership (ignore failure in rootless mode)
chown -R 1000:1000 /var/lib/gitea || echo "Warning: chown failed, likely due to rootless mode."
APP_INI="/var/lib/gitea/custom/conf/app.ini"
# Delay until config is saved by frontend, then patch it (if it exists)
fix_config() {
if [ -f "$APP_INI" ]; then
echo "Patching ROOT_URL to /forgejo subpath..."
sed -i 's|^ROOT_URL *=.*|ROOT_URL = http://localhost:8080/forgejo/|' "$APP_INI"
fi
}
# Background config fixer that waits for web setup to complete
(
echo "Waiting to patch app.ini..."
sleep 10
fix_config
) &
exec /usr/bin/dumb-init -- /usr/local/bin/forgejo "$@"

View file

@ -0,0 +1,24 @@
#!/bin/sh
# Attempt to fix perms if possible, ignore failure
chown -R 1000:1000 /var/lib/gitea || echo "Warning: chown failed, likely due to rootless mode."
# Ensure app.ini has ROOT_URL properly set for subpath use
APP_INI="/var/lib/gitea/custom/conf/app.ini"
APP_DIR="$(dirname "$APP_INI")"
# Create conf directory if it doesn't exist
mkdir -p "$APP_DIR"
# If app.ini doesn't exist, create a minimal config with ROOT_URL
if [ ! -f "$APP_INI" ]; then
echo "Creating default app.ini for Forgejo with subpath ROOT_URL..."
cat > "$APP_INI" <<EOF
[server]
ROOT_URL = http://localhost:8080/forgejo/
APP_NAME = Forgejo
EOF
fi
# Continue to Forgejo's normal entrypoint
exec /usr/bin/dumb-init -- /usr/local/bin/forgejo "$@"

41
scripts/seal-foldstate.sh Executable file
View file

@ -0,0 +1,41 @@
#!/bin/bash
set -e
# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ 🪙 FOLD STATE SEALING SCRIPT ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
# Optional tag passed as argument
TAG="$1"
# Ensure required dirs
mkdir -p foldstate
mkdir -p .foldarchive
# Timestamp
NOW=$(date +"%Y-%m-%dT%H-%M-%S")
FILENAME_BASE="foldstate.${NOW}"
[ -n "$TAG" ] && FILENAME_BASE="${FILENAME_BASE}-${TAG}"
# File paths
LATEST_PATH="foldstate/foldstate.latest.scroll"
ROLLING_PATH="foldstate/${FILENAME_BASE}.scroll"
ARCHIVE_PATH=".foldarchive/${FILENAME_BASE}.scroll"
# Run integrity snapshot and save to files
echo "📜 Sealing foldstate snapshot..."
./scripts/watch-fold-integrity.sh > "$LATEST_PATH"
cp "$LATEST_PATH" "$ROLLING_PATH"
cp "$LATEST_PATH" "$ARCHIVE_PATH"
# Trim oldest foldstate/ files if over limit (5 max)
MAX_KEEP=5
cd foldstate
ls -1tr foldstate.*.scroll 2>/dev/null | head -n -$MAX_KEEP | xargs -r rm
cd ..
# Confirm
echo "✅ Foldstate sealed:"
echo " 🧭 Latest: $LATEST_PATH"
echo " 🌀 Snapshot: $ROLLING_PATH"
echo " 🗃 Archive: $ARCHIVE_PATH"

42
scripts/watch-fold-integrity.sh Executable file
View file

@ -0,0 +1,42 @@
#!/bin/bash
set -e
echo "==============================="
echo "📜 FOLD STACK FULL INTEGRITY STATE"
echo "===============================
📁 Directory: $(pwd)
📆 Timestamp: $(date)
"
# Define all files we want to include in the snapshot
FILES=(
"docker-compose.dev.yml"
".env.dev"
"nginx/dev/default.conf"
"scripts/up-dev.sh"
"scripts/down-dev.sh"
"scripts/diagnose-dev.sh"
"scripts/watch-fold-integrity.sh"
"volumes/forgejo/custom/conf/app.ini"
)
# Loop through each and print with formatting
for FILE in "${FILES[@]}"; do
if [ -f "$FILE" ]; then
echo ""
echo "───────────────────────────────"
echo "📂 FILE: $FILE"
echo "───────────────────────────────"
cat "$FILE"
echo ""
else
echo ""
echo "⚠️ MISSING FILE: $FILE"
echo ""
fi
done
echo "==============================="
echo "✅ INTEGRITY DUMP COMPLETE"
echo "==============================="