Add detection diagnostic tools and fix silent detection on cached runs

NEW FEATURES:
- launcher.sh --detect-only: Force re-detect and show results
- test-detection.sh: Comprehensive detection diagnostic tool
- Better error feedback when detection fails

FIXES:
- launcher.sh: Detection now verified even on cached runs
- Added explicit check for SYS_DETECTION_COMPLETE before using cache
- User can now diagnose detection issues with --detect-only flag

USAGE:
  bash launcher.sh --detect-only        (check what was detected)
  bash test-detection.sh                (run full diagnostic)
  bash test-detection.sh verbose        (show file paths and details)

RESULTS:
- Users can now easily verify detection is working
- Detection issues are no longer silent
- Clear diagnostic output for troubleshooting
This commit is contained in:
Developer
2026-03-20 01:44:31 -04:00
parent 11c3d23626
commit 7c8bc085f7
2 changed files with 307 additions and 0 deletions
+51
View File
@@ -732,6 +732,13 @@ startup_detection() {
if ! read -p "Press Enter to continue..." </dev/tty 2>/dev/null; then
true # Continue even if read fails
fi
else
# Database is cached and fresh, but still ensure detection was completed
# (this addresses issue where detection output not shown on cached runs)
if [ -z "${SYS_DETECTION_COMPLETE:-}" ]; then
print_error "System detection failed - please check system configuration"
return 1
fi
fi
}
@@ -740,6 +747,50 @@ startup_detection() {
#############################################################################
main() {
# Handle command-line arguments
case "${1:-}" in
--detect-only|--check-detection)
# Initialize directories
init_directories || {
echo "ERROR: Failed to initialize directories"
return 1
}
# Force fresh detection regardless of cache
echo "Forcing system re-detection..."
echo ""
rm -f "$BASE_DIR/.sysref.beta" "$BASE_DIR/.sysref.beta.timestamp" 2>/dev/null || true
# Run detection
initialize_system_detection
# Show results
echo ""
echo "═══════════════════════════════════════════════════════════════"
echo " DETECTION RESULTS"
echo "═══════════════════════════════════════════════════════════════"
echo ""
echo "Control Panel: ${SYS_CONTROL_PANEL:-unknown} ${SYS_CONTROL_PANEL_VERSION:-}"
echo "Operating System: ${SYS_OS_TYPE:-unknown} ${SYS_OS_VERSION:-}"
echo "Web Server: ${SYS_WEB_SERVER:-unknown} ${SYS_WEB_SERVER_VERSION:-}"
echo "Database: ${SYS_DB_TYPE:-unknown} ${SYS_DB_VERSION:-}"
echo "Firewall: ${SYS_FIREWALL:-unknown} ${SYS_FIREWALL_VERSION:-} (${SYS_FIREWALL_ACTIVE:-unknown})"
echo "PHP Versions: ${SYS_PHP_VERSIONS[*]:-none detected}"
echo ""
echo "═══════════════════════════════════════════════════════════════"
return 0
;;
--help|--usage|-h|-?)
echo "Usage: launcher.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --detect-only Show system detection results and exit"
echo " --help Show this help message"
echo ""
return 0
;;
esac
# Initialize directories once at startup
init_directories || {
echo "ERROR: Failed to initialize directories"