Initial commit: Server Management Toolkit v2.0
- Complete security menu restructure (3-mode: Analysis/Actions/Live) - Intelligent cPHulk enablement with CSF whitelist import - Live network security monitoring dashboard - Multi-source threat detection and classification - 50+ organized security tools across 4-level menu hierarchy - System health diagnostics with cPanel/WHM integration - Reference database for cross-module intelligence sharing
This commit is contained in:
Executable
+73
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Quick test script to validate domain detection is working
|
||||
# Returns exit code 0 if working, 1 if broken
|
||||
|
||||
echo "========================================"
|
||||
echo "Domain Detection Test"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
# Source libraries
|
||||
SCRIPT_DIR="/root/server-toolkit"
|
||||
source "$SCRIPT_DIR/lib/common-functions.sh"
|
||||
source "$SCRIPT_DIR/lib/system-detect.sh"
|
||||
source "$SCRIPT_DIR/lib/user-manager.sh"
|
||||
|
||||
echo "Step 1: Check system detection variables"
|
||||
echo " SYS_CONTROL_PANEL: [$SYS_CONTROL_PANEL]"
|
||||
echo " SYS_DETECTION_COMPLETE: [$SYS_DETECTION_COMPLETE]"
|
||||
|
||||
if [ -z "$SYS_CONTROL_PANEL" ]; then
|
||||
echo " ❌ FAIL: SYS_CONTROL_PANEL is empty!"
|
||||
exit 1
|
||||
else
|
||||
echo " ✓ PASS: SYS_CONTROL_PANEL is set"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Step 2: Test get_user_domains function"
|
||||
domains=$(get_user_domains "pickledperil")
|
||||
echo " Domains for pickledperil: [$domains]"
|
||||
|
||||
if [ -z "$domains" ]; then
|
||||
echo " ❌ FAIL: No domains returned!"
|
||||
exit 1
|
||||
else
|
||||
echo " ✓ PASS: Domains found: $domains"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Step 3: Test select_user_interactive caching"
|
||||
# Just test the caching logic without user input
|
||||
users=(pickledperil)
|
||||
declare -A user_primary_domain
|
||||
declare -A user_domain_count
|
||||
|
||||
for user in "${users[@]}"; do
|
||||
local_domains=$(get_user_domains "$user" 2>/dev/null | grep -v "^$")
|
||||
if [ -n "$local_domains" ]; then
|
||||
user_domain_count["$user"]=$(echo "$local_domains" | wc -l)
|
||||
user_primary_domain["$user"]=$(echo "$local_domains" | head -1)
|
||||
else
|
||||
user_domain_count["$user"]=0
|
||||
user_primary_domain["$user"]="(no domains)"
|
||||
fi
|
||||
done
|
||||
|
||||
echo " Cached domain: ${user_primary_domain[pickledperil]}"
|
||||
echo " Cached count: ${user_domain_count[pickledperil]}"
|
||||
|
||||
if [ "${user_primary_domain[pickledperil]}" = "(no domains)" ]; then
|
||||
echo " ❌ FAIL: User shows as having no domains!"
|
||||
exit 1
|
||||
else
|
||||
echo " ✓ PASS: User cache working correctly"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo "✓ ALL TESTS PASSED!"
|
||||
echo "Domain detection is working correctly."
|
||||
echo "========================================"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user