#!/usr/bin/env bash
set -u
printf '\n== Host identity ==\n'
printf 'User: '; id -un
printf 'Home: %s\n' "$HOME"
printf '\n== Available runtimes ==\n'
for x in node npm psql git; do command -v "$x" || true; done
for x in /opt/alt/alt-nodejs22/root/usr/bin/node "$HOME/nodevenv/novin-site/core/22/bin/node"; do if [ -x "$x" ]; then "$x" --version; fi; done
printf '\n== Existing app directories (non-destructive) ==\n'
for d in "$HOME/novin-site" "$HOME/fara" "$HOME/fara-core" "$HOME/public_html/fara" "$HOME/public_html"; do if [ -d "$d" ]; then ls -ld "$d"; else printf 'Missing: %s\n' "$d"; fi; done
printf '\n== Target domain: fara.amlaakeno.ir ==\n'
if command -v getent >/dev/null 2>&1; then getent ahostsv4 fara.amlaakeno.ir | head -3 || true; fi
if command -v curl >/dev/null 2>&1; then curl -k -I -sS --max-time 8 https://fara.amlaakeno.ir/ | head -12 || true; fi
for d in "$HOME/fara-app" "$HOME/public_html/fara"; do if [ -e "$d" ]; then ls -ld "$d"; else printf 'Missing: %s\n' "$d"; fi; done
printf '\n== cPanel subdomain indicators ==\n'
for f in "$HOME/etc" "$HOME/.cpanel"; do if [ -d "$f" ]; then printf 'Exists: %s\n' "$f"; fi; done
printf '\n== Passenger mappings (no secrets) ==\n'
for f in "$HOME/public_html/.htaccess" "$HOME/public_html/fara/.htaccess"; do if [ -f "$f" ]; then printf '%s\n' "$f"; grep -E '^Passenger(AppRoot|StartupFile|Nodejs|BaseURI)' "$f" || true; fi; done
printf '\n== PostgreSQL tools ==\n'
if command -v pg_config >/dev/null 2>&1; then pg_config --version; fi
printf '\n== Git remotes, if inside an independent fara repo ==\n'
if [ -d "$HOME/fara/.git" ]; then git -C "$HOME/fara" remote -v | sed -E 's#(https?://)[^/@]+@#\1***@#g'; fi
printf '\nComplete: Read-only checks. No changes made.\n'
