Compare commits
8 Commits
992b4e9e17
...
11c3d23626
| Author | SHA1 | Date | |
|---|---|---|---|
| 11c3d23626 | |||
| 1626b53de3 | |||
| 0e69254b9d | |||
| fd52a4aa15 | |||
| 496dbf4f17 | |||
| 50f5e2e378 | |||
| 71e662d17d | |||
| 9199aa3153 |
+215
-261
@@ -31,18 +31,7 @@ source "$LIB_DIR/system-detect.sh" || { echo "ERROR: Failed to load system-detec
|
|||||||
source "$LIB_DIR/domain-discovery.sh" || { echo "ERROR: Failed to load domain-discovery.sh"; return 1; }
|
source "$LIB_DIR/domain-discovery.sh" || { echo "ERROR: Failed to load domain-discovery.sh"; return 1; }
|
||||||
source "$LIB_DIR/user-manager.sh" || { echo "ERROR: Failed to load user-manager.sh"; return 1; }
|
source "$LIB_DIR/user-manager.sh" || { echo "ERROR: Failed to load user-manager.sh"; return 1; }
|
||||||
source "$LIB_DIR/reference-db.sh" || { echo "ERROR: Failed to load reference-db.sh"; return 1; }
|
source "$LIB_DIR/reference-db.sh" || { echo "ERROR: Failed to load reference-db.sh"; return 1; }
|
||||||
|
source "$LIB_DIR/menu-functions.sh" || { echo "ERROR: Failed to load menu-functions.sh"; return 1; }
|
||||||
# Safe read helper function - handles both interactive and non-interactive modes
|
|
||||||
safe_read_choice() {
|
|
||||||
if [ "$INTERACTIVE_MODE" -eq 0 ]; then
|
|
||||||
# Non-interactive: return 1 to indicate read failed
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Color codes
|
# Color codes
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
@@ -169,26 +158,28 @@ show_main_menu() {
|
|||||||
# Show quick system overview if detection is complete
|
# Show quick system overview if detection is complete
|
||||||
[ -n "${SYS_DETECTION_COMPLETE:-}" ] && show_system_overview
|
[ -n "${SYS_DETECTION_COMPLETE:-}" ] && show_system_overview
|
||||||
|
|
||||||
echo "Quick Diagnostics:"
|
menu_header "Server Management Toolkit"
|
||||||
|
|
||||||
|
menu_section "Quick Diagnostics"
|
||||||
|
menu_option 1 "System Health Check" "Full server diagnostics"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo " 1) 🏥 System Health Check - Full server diagnostics"
|
menu_section "Main Categories"
|
||||||
|
menu_option 2 "Security & Monitoring"
|
||||||
|
menu_option 3 "Website Diagnostics"
|
||||||
|
menu_option 4 "Performance & Maintenance"
|
||||||
|
menu_option 5 "Backup & Recovery"
|
||||||
|
menu_option 6 "Email Troubleshooting"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Main Categories:"
|
menu_section "System"
|
||||||
|
menu_option 7 "Cleanup Toolkit Data" "Clear cached data"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo " 2) 🛡️ Security & Monitoring"
|
menu_exit
|
||||||
echo " 3) 🌐 Website Diagnostics"
|
menu_divider
|
||||||
echo " 4) 🔧 Performance & Maintenance"
|
|
||||||
echo " 5) 💾 Backup & Recovery"
|
read_menu_choice "Select option" 0 7
|
||||||
echo " 6) 📧 Email Troubleshooting"
|
|
||||||
echo ""
|
|
||||||
echo "System:"
|
|
||||||
echo ""
|
|
||||||
echo " 7) 🗑️ Cleanup Toolkit Data - Clear cached data"
|
|
||||||
echo ""
|
|
||||||
echo " 0) Exit"
|
|
||||||
echo ""
|
|
||||||
echo "═══════════════════════════════════════════════════════════════"
|
|
||||||
echo -n "Select option: "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
@@ -202,19 +193,20 @@ show_main_menu() {
|
|||||||
# Threat Analysis Sub-Menu
|
# Threat Analysis Sub-Menu
|
||||||
show_threat_analysis_menu() {
|
show_threat_analysis_menu() {
|
||||||
show_banner
|
show_banner
|
||||||
echo -e "📊 Threat Analysis"
|
menu_header "Threat Analysis"
|
||||||
|
|
||||||
|
menu_option 1 "Bot & Traffic Analyzer" "Full analysis (all logs)"
|
||||||
|
menu_option 2 "Quick Scan (1 hour)" "Recent activity only"
|
||||||
|
menu_option 3 "IP Reputation Manager" "Query/manage IP database"
|
||||||
|
menu_option 4 "Suspicious Login Monitor" "SSH/Panel login analysis"
|
||||||
|
menu_option 5 "Malware Scanner" "ImunifyAV, ClamAV, Maldet"
|
||||||
|
menu_option 6 "Historical Attack Analysis" "Scan past logs (ET Open)"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " 1) 🤖 Bot & Traffic Analyzer - Full analysis (all logs)"
|
menu_back "Security Menu"
|
||||||
echo -e " 2) 🤖 Quick Scan (1 hour) - Recent activity only"
|
menu_divider
|
||||||
echo -e " 3) 📊 IP Reputation Manager - Query/manage IP database"
|
|
||||||
echo -e " 4) 🔐 Suspicious Login Monitor - SSH/Panel login analysis"
|
read_menu_choice "Select option" 0 6
|
||||||
echo -e " 5) 🦠 Malware Scanner - ImunifyAV, ClamAV, Maldet"
|
|
||||||
echo -e " 6) 🛡️ Historical Attack Analysis - Scan past logs (ET Open)"
|
|
||||||
echo ""
|
|
||||||
echo -e " 0) Back to Security Menu"
|
|
||||||
echo ""
|
|
||||||
echo -e "──────────────────────────────────────────────────────────────"
|
|
||||||
echo -n "Select option: "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_threat_analysis_menu() {
|
handle_threat_analysis_menu() {
|
||||||
@@ -224,11 +216,8 @@ handle_threat_analysis_menu() {
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
show_threat_analysis_menu
|
show_threat_analysis_menu
|
||||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
|
||||||
return 0 # Exit if read fails
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$choice" in
|
case "$MENU_CHOICE" in
|
||||||
1) run_module "security" "bot-analyzer.sh" ;;
|
1) run_module "security" "bot-analyzer.sh" ;;
|
||||||
2) run_module "security" "bot-analyzer.sh" -H 1 ;;
|
2) run_module "security" "bot-analyzer.sh" -H 1 ;;
|
||||||
3) run_module "security" "ip-reputation-manager.sh" ;;
|
3) run_module "security" "ip-reputation-manager.sh" ;;
|
||||||
@@ -236,7 +225,7 @@ handle_threat_analysis_menu() {
|
|||||||
5) run_module "security" "malware-scanner.sh" ;;
|
5) run_module "security" "malware-scanner.sh" ;;
|
||||||
6) bash "$BASE_DIR/tools/analyze-historical-attacks.sh" ;;
|
6) bash "$BASE_DIR/tools/analyze-historical-attacks.sh" ;;
|
||||||
0) return ;;
|
0) return ;;
|
||||||
*) echo -e "Invalid option"; sleep 1 ;;
|
*) menu_invalid_choice ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -244,17 +233,18 @@ handle_threat_analysis_menu() {
|
|||||||
# Live Monitoring Sub-Menu
|
# Live Monitoring Sub-Menu
|
||||||
show_live_monitoring_menu() {
|
show_live_monitoring_menu() {
|
||||||
show_banner
|
show_banner
|
||||||
echo -e "🔴 Live Monitoring"
|
menu_header "Live Monitoring"
|
||||||
|
|
||||||
|
menu_option 1 "Live Attack Monitor" "Unified threat intelligence"
|
||||||
|
menu_option 2 "SSH Attack Monitor" "SSH brute force detection"
|
||||||
|
menu_option 3 "Web Traffic Monitor" "HTTP attack detection"
|
||||||
|
menu_option 4 "Firewall Activity Monitor" "CSF/iptables monitoring"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " 1) 📡 Live Attack Monitor - Unified threat intelligence"
|
menu_back "Security Menu"
|
||||||
echo -e " 2) 🔐 SSH Attack Monitor - SSH brute force detection"
|
menu_divider
|
||||||
echo -e " 3) 🌐 Web Traffic Monitor - HTTP attack detection"
|
|
||||||
echo -e " 4) 🔥 Firewall Activity Monitor - CSF/iptables monitoring"
|
read_menu_choice "Select option" 0 4
|
||||||
echo ""
|
|
||||||
echo -e " 0) Back to Security Menu"
|
|
||||||
echo ""
|
|
||||||
echo -e "──────────────────────────────────────────────────────────────"
|
|
||||||
echo -n "Select option: "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_live_monitoring_menu() {
|
handle_live_monitoring_menu() {
|
||||||
@@ -264,17 +254,14 @@ handle_live_monitoring_menu() {
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
show_live_monitoring_menu
|
show_live_monitoring_menu
|
||||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
|
||||||
return 0 # Exit if read fails
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$choice" in
|
case "$MENU_CHOICE" in
|
||||||
1) run_module "security" "live-attack-monitor.sh" ;;
|
1) run_module "security" "live-attack-monitor.sh" ;;
|
||||||
2) run_module "security" "ssh-attack-monitor.sh" ;;
|
2) run_module "security" "ssh-attack-monitor.sh" ;;
|
||||||
3) run_module "security" "web-traffic-monitor.sh" ;;
|
3) run_module "security" "web-traffic-monitor.sh" ;;
|
||||||
4) run_module "security" "firewall-activity-monitor.sh" ;;
|
4) run_module "security" "firewall-activity-monitor.sh" ;;
|
||||||
0) return ;;
|
0) return ;;
|
||||||
*) echo -e "Invalid option"; sleep 1 ;;
|
*) menu_invalid_choice ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -282,17 +269,18 @@ handle_live_monitoring_menu() {
|
|||||||
# Log Viewers Sub-Menu
|
# Log Viewers Sub-Menu
|
||||||
show_log_viewers_menu() {
|
show_log_viewers_menu() {
|
||||||
show_banner
|
show_banner
|
||||||
echo -e "📋 Log Viewers"
|
menu_header "Log Viewers"
|
||||||
|
|
||||||
|
menu_option 1 "Apache Access Log" "Live web access"
|
||||||
|
menu_option 2 "Apache Error Log" "Live web errors"
|
||||||
|
menu_option 3 "Mail Log" "Live email activity"
|
||||||
|
menu_option 4 "Security Log" "Live auth attempts"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " 1) 🌐 Apache Access Log - Live web access"
|
menu_back "Security Menu"
|
||||||
echo -e " 2) ❌ Apache Error Log - Live web errors"
|
menu_divider
|
||||||
echo -e " 3) 📧 Mail Log - Live email activity"
|
|
||||||
echo -e " 4) 🔐 Security Log - Live auth attempts"
|
read_menu_choice "Select option" 0 4
|
||||||
echo ""
|
|
||||||
echo -e " 0) Back to Security Menu"
|
|
||||||
echo ""
|
|
||||||
echo -e "──────────────────────────────────────────────────────────────"
|
|
||||||
echo -n "Select option: "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_log_viewers_menu() {
|
handle_log_viewers_menu() {
|
||||||
@@ -302,17 +290,14 @@ handle_log_viewers_menu() {
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
show_log_viewers_menu
|
show_log_viewers_menu
|
||||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
|
||||||
return 0 # Exit if read fails
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$choice" in
|
case "$MENU_CHOICE" in
|
||||||
1) run_module "security" "tail-apache-access.sh" ;;
|
1) run_module "security" "tail-apache-access.sh" ;;
|
||||||
2) run_module "security" "tail-apache-error.sh" ;;
|
2) run_module "security" "tail-apache-error.sh" ;;
|
||||||
3) run_module "security" "tail-mail-log.sh" ;;
|
3) run_module "security" "tail-mail-log.sh" ;;
|
||||||
4) run_module "security" "tail-secure-log.sh" ;;
|
4) run_module "security" "tail-secure-log.sh" ;;
|
||||||
0) return ;;
|
0) return ;;
|
||||||
*) echo -e "Invalid option"; sleep 1 ;;
|
*) menu_invalid_choice ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -320,16 +305,17 @@ handle_log_viewers_menu() {
|
|||||||
# Security Actions Sub-Menu
|
# Security Actions Sub-Menu
|
||||||
show_security_actions_menu() {
|
show_security_actions_menu() {
|
||||||
show_banner
|
show_banner
|
||||||
echo -e "🔒 Security Actions"
|
menu_header "Security Actions"
|
||||||
|
|
||||||
|
menu_option 1 "Enable cPHulk Protection" "Brute force protection"
|
||||||
|
menu_option 2 "Optimize CT_LIMIT" "Connection tracking tuning"
|
||||||
|
menu_option 3 "Block Malicious Bots" "User-Agent blocking (Apache)"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " 1) 🔒 Enable cPHulk Protection - Brute force protection"
|
menu_back "Security Menu"
|
||||||
echo -e " 2) ⚙️ Optimize CT_LIMIT - Connection tracking tuning"
|
menu_divider
|
||||||
echo -e " 3) 🤖 Block Malicious Bots - User-Agent blocking (Apache)"
|
|
||||||
echo ""
|
read_menu_choice "Select option" 0 3
|
||||||
echo -e " 0) Back to Security Menu"
|
|
||||||
echo ""
|
|
||||||
echo -e "──────────────────────────────────────────────────────────────"
|
|
||||||
echo -n "Select option: "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_security_actions_menu() {
|
handle_security_actions_menu() {
|
||||||
@@ -339,16 +325,13 @@ handle_security_actions_menu() {
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
show_security_actions_menu
|
show_security_actions_menu
|
||||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
|
||||||
return 0 # Exit if read fails
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$choice" in
|
case "$MENU_CHOICE" in
|
||||||
1) run_module "security" "enable-cphulk.sh" ;;
|
1) run_module "security" "enable-cphulk.sh" ;;
|
||||||
2) run_module "security" "optimize-ct-limit.sh" ;;
|
2) run_module "security" "optimize-ct-limit.sh" ;;
|
||||||
3) run_module "security" "bot-blocker.sh" ;;
|
3) run_module "security" "bot-blocker.sh" ;;
|
||||||
0) return ;;
|
0) return ;;
|
||||||
*) echo -e "Invalid option"; sleep 1 ;;
|
*) menu_invalid_choice ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -359,17 +342,18 @@ handle_security_actions_menu() {
|
|||||||
|
|
||||||
show_security_menu() {
|
show_security_menu() {
|
||||||
show_banner
|
show_banner
|
||||||
echo -e "🛡️ Security & Monitoring"
|
menu_header "Security & Monitoring"
|
||||||
|
|
||||||
|
menu_option 1 "Threat Analysis" "Analyze threats & reputation"
|
||||||
|
menu_option 2 "Live Monitoring" "Real-time attack detection"
|
||||||
|
menu_option 3 "Log Viewers" "Tail system/security logs"
|
||||||
|
menu_option 4 "Security Actions" "Hardening & protection"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " 1) 📊 Threat Analysis → Analyze threats & reputation"
|
menu_back "Main Menu"
|
||||||
echo -e " 2) 🔴 Live Monitoring → Real-time attack detection"
|
menu_divider
|
||||||
echo -e " 3) 📋 Log Viewers → Tail system/security logs"
|
|
||||||
echo -e " 4) 🔒 Security Actions → Hardening & protection"
|
read_menu_choice "Select option" 0 4
|
||||||
echo ""
|
|
||||||
echo -e " 0) Back to Main Menu"
|
|
||||||
echo ""
|
|
||||||
echo -e "──────────────────────────────────────────────────────────────"
|
|
||||||
echo -n "Select option: "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_security_menu() {
|
handle_security_menu() {
|
||||||
@@ -379,17 +363,14 @@ handle_security_menu() {
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
show_security_menu
|
show_security_menu
|
||||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
|
||||||
return 0 # Exit if read fails
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$choice" in
|
case "$MENU_CHOICE" in
|
||||||
1) handle_threat_analysis_menu ;;
|
1) handle_threat_analysis_menu ;;
|
||||||
2) handle_live_monitoring_menu ;;
|
2) handle_live_monitoring_menu ;;
|
||||||
3) handle_log_viewers_menu ;;
|
3) handle_log_viewers_menu ;;
|
||||||
4) handle_security_actions_menu ;;
|
4) handle_security_actions_menu ;;
|
||||||
0) return ;;
|
0) return ;;
|
||||||
*) echo -e "Invalid option"; sleep 1 ;;
|
*) menu_invalid_choice ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -400,30 +381,29 @@ handle_security_menu() {
|
|||||||
|
|
||||||
show_website_menu() {
|
show_website_menu() {
|
||||||
show_banner
|
show_banner
|
||||||
echo -e "🌐 Website Diagnostics"
|
menu_header "Website Diagnostics"
|
||||||
|
|
||||||
|
menu_section "Error Analysis"
|
||||||
|
menu_option 1 "Website Error Analyzer" "Find 500/config errors"
|
||||||
|
menu_option 2 "Fast 500 Error Tracker" "ONLY 500s + root cause"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "Error Analysis:"
|
menu_section "Performance & Slowness"
|
||||||
|
menu_option 3 "Website Slowness Diagnostics" "Multi-framework analysis"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " 1) 🔍 Website Error Analyzer - Find 500/config errors (filters bots)"
|
menu_section "WordPress Management"
|
||||||
echo -e " 2) 🔥 Fast 500 Error Tracker - ONLY 500s + root cause diagnosis"
|
menu_option 4 "WordPress Tools" "WP-Cron manager & tools"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "Performance & Slowness:"
|
menu_section "Domain Analysis"
|
||||||
|
menu_option 5 "Cloudflare Detector" "Domains using Cloudflare"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " 3) 🐢 Website Slowness Diagnostics - Multi-framework analysis"
|
menu_back "Main Menu"
|
||||||
echo " └─ WordPress, Drupal, Joomla, Magento, Laravel, Node.js, etc."
|
menu_divider
|
||||||
echo ""
|
|
||||||
echo -e "WordPress Management:"
|
read_menu_choice "Select option" 0 5
|
||||||
echo ""
|
|
||||||
echo -e " 4) 📦 WordPress Tools → WP-Cron manager & more tools"
|
|
||||||
echo ""
|
|
||||||
echo -e "Domain Analysis:"
|
|
||||||
echo ""
|
|
||||||
echo -e " 5) 🔶 Cloudflare Detector - Which domains use Cloudflare + location"
|
|
||||||
echo ""
|
|
||||||
echo -e " 0) Back to Main Menu"
|
|
||||||
echo ""
|
|
||||||
echo -e "──────────────────────────────────────────────────────────────"
|
|
||||||
echo -n "Select option: "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_website_menu() {
|
handle_website_menu() {
|
||||||
@@ -433,18 +413,15 @@ handle_website_menu() {
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
show_website_menu
|
show_website_menu
|
||||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
|
||||||
return 0 # Exit if read fails
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$choice" in
|
case "$MENU_CHOICE" in
|
||||||
1) run_module "website" "website-error-analyzer.sh" ;;
|
1) run_module "website" "website-error-analyzer.sh" ;;
|
||||||
2) run_module "website" "500-error-tracker.sh" ;;
|
2) run_module "website" "500-error-tracker.sh" ;;
|
||||||
3) run_module "website" "website-slowness-diagnostics.sh" ;;
|
3) run_module "website" "website-slowness-diagnostics.sh" ;;
|
||||||
4) bash "$MODULES_DIR/website/wordpress-menu.sh" ;;
|
4) bash "$MODULES_DIR/website/wordpress-menu.sh" ;;
|
||||||
5) run_module "website" "cloudflare-detector.sh" ;;
|
5) run_module "website" "cloudflare-detector.sh" ;;
|
||||||
0) return ;;
|
0) return ;;
|
||||||
*) echo -e "Invalid option"; sleep 1 ;;
|
*) menu_invalid_choice ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -455,34 +432,34 @@ handle_website_menu() {
|
|||||||
|
|
||||||
show_performance_menu() {
|
show_performance_menu() {
|
||||||
show_banner
|
show_banner
|
||||||
echo -e "🔧 Performance & Maintenance"
|
menu_header "Performance & Maintenance"
|
||||||
|
|
||||||
|
menu_section "Database"
|
||||||
|
menu_option 1 "MySQL Query Analyzer" "Find slow queries & optimize"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "Database:"
|
menu_section "Network & Resources"
|
||||||
|
menu_option 2 "Network & Bandwidth" "Traffic & top consumers"
|
||||||
|
menu_option 3 "Hardware Health Check" "SMART, memory, CPU sensors"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " 1) 🗄️ MySQL Query Analyzer - Find slow queries & optimize"
|
menu_section "PHP Optimization"
|
||||||
|
menu_option 4 "PHP Configuration Optimizer" "Per-domain PHP tuning"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "Network & Resources:"
|
menu_section "System Health"
|
||||||
|
menu_option 5 "Loadwatch Health Analyzer" "Historical system analysis"
|
||||||
|
menu_option 6 "Disk Space Analyzer" "Find space issues"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " 2) 🌐 Network & Bandwidth - Traffic & top consumers"
|
menu_section "Caching Solutions"
|
||||||
echo -e " 3) 💻 Hardware Health Check - SMART, memory, CPU sensors"
|
menu_option 7 "Nginx + Varnish Manager" "Setup/manage caching stack"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "PHP Optimization:"
|
menu_back "Main Menu"
|
||||||
echo ""
|
menu_divider
|
||||||
echo -e " 4) ⚙️ PHP Configuration Optimizer - Per-domain PHP tuning"
|
|
||||||
echo ""
|
read_menu_choice "Select option" 0 7
|
||||||
echo -e "System Health:"
|
|
||||||
echo ""
|
|
||||||
echo -e " 5) 📊 Loadwatch Health Analyzer - Historical system analysis"
|
|
||||||
echo -e " 6) 💿 Disk Space Analyzer - Find space issues & cleanup files"
|
|
||||||
echo ""
|
|
||||||
echo -e "Caching Solutions:"
|
|
||||||
echo ""
|
|
||||||
echo -e " 7) ⚡ Nginx + Varnish Manager - Setup/manage caching stack"
|
|
||||||
echo ""
|
|
||||||
echo -e " 0) Back to Main Menu"
|
|
||||||
echo ""
|
|
||||||
echo -e "──────────────────────────────────────────────────────────────"
|
|
||||||
echo -n "Select option: "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_performance_menu() {
|
handle_performance_menu() {
|
||||||
@@ -492,11 +469,8 @@ handle_performance_menu() {
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
show_performance_menu
|
show_performance_menu
|
||||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
|
||||||
return 0 # Exit if read fails
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$choice" in
|
case "$MENU_CHOICE" in
|
||||||
1) run_module "performance" "mysql-query-analyzer.sh" ;;
|
1) run_module "performance" "mysql-query-analyzer.sh" ;;
|
||||||
2) run_module "performance" "network-bandwidth-analyzer.sh" ;;
|
2) run_module "performance" "network-bandwidth-analyzer.sh" ;;
|
||||||
3) run_module "performance" "hardware-health-check.sh" ;;
|
3) run_module "performance" "hardware-health-check.sh" ;;
|
||||||
@@ -505,7 +479,7 @@ handle_performance_menu() {
|
|||||||
6) run_module "maintenance" "disk-space-analyzer.sh" ;;
|
6) run_module "maintenance" "disk-space-analyzer.sh" ;;
|
||||||
7) run_module "performance" "nginx-varnish-manager.sh" ;;
|
7) run_module "performance" "nginx-varnish-manager.sh" ;;
|
||||||
0) return ;;
|
0) return ;;
|
||||||
*) echo -e "Invalid option"; sleep 1 ;;
|
*) menu_invalid_choice ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -516,33 +490,29 @@ handle_loadwatch_analyzer() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
show_banner
|
show_banner
|
||||||
echo -e "📊 Loadwatch Health Analyzer"
|
menu_header "Loadwatch Health Analyzer"
|
||||||
echo ""
|
|
||||||
echo -e "Select time range for analysis:"
|
|
||||||
echo ""
|
|
||||||
echo -e " 1) Last 1 Hour - Recent activity"
|
|
||||||
echo -e " 2) Last 6 Hours - Mid-term trending"
|
|
||||||
echo -e " 3) Last 24 Hours - Full day analysis"
|
|
||||||
echo -e " 4) Last 7 Days - Weekly patterns"
|
|
||||||
echo -e " 5) Last 30 Days - Monthly overview"
|
|
||||||
echo ""
|
|
||||||
echo -e " 0) Back"
|
|
||||||
echo ""
|
|
||||||
echo -e "──────────────────────────────────────────────────────────────"
|
|
||||||
echo -n "Select time range: "
|
|
||||||
|
|
||||||
if ! read -r range_choice </dev/tty 2>/dev/null; then
|
menu_section "Select time range for analysis"
|
||||||
return 0 # Exit if read fails
|
menu_option 1 "Last 1 Hour" "Recent activity"
|
||||||
fi
|
menu_option 2 "Last 6 Hours" "Mid-term trending"
|
||||||
|
menu_option 3 "Last 24 Hours" "Full day analysis"
|
||||||
|
menu_option 4 "Last 7 Days" "Weekly patterns"
|
||||||
|
menu_option 5 "Last 30 Days" "Monthly overview"
|
||||||
|
|
||||||
case "$range_choice" in
|
echo ""
|
||||||
|
menu_back "Performance Menu"
|
||||||
|
menu_divider
|
||||||
|
|
||||||
|
read_menu_choice "Select time range" 0 5
|
||||||
|
|
||||||
|
case "$MENU_CHOICE" in
|
||||||
1) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "1h" ;;
|
1) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "1h" ;;
|
||||||
2) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "6h" ;;
|
2) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "6h" ;;
|
||||||
3) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "24h" ;;
|
3) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "24h" ;;
|
||||||
4) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "7d" ;;
|
4) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "7d" ;;
|
||||||
5) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "30d" ;;
|
5) run_module "diagnostics" "loadwatch-analyzer.sh" "-r" "30d" ;;
|
||||||
0) return ;;
|
0) return ;;
|
||||||
*) echo -e "Invalid option"; sleep 1 ;;
|
*) menu_invalid_choice ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,55 +522,55 @@ handle_loadwatch_analyzer() {
|
|||||||
|
|
||||||
show_backup_menu() {
|
show_backup_menu() {
|
||||||
show_banner
|
show_banner
|
||||||
echo -e "💾 Backup & Recovery"
|
menu_header "Backup & Recovery"
|
||||||
|
|
||||||
|
menu_section "Acronis Cyber Protect"
|
||||||
|
menu_option 1 "Acronis Management" "Complete backup management"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "Acronis Cyber Protect:"
|
menu_section "Database Tools"
|
||||||
|
menu_option 2 "MySQL File Restore" "Convert restored DB files"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " 1) 🔷 Acronis Management → Complete backup management"
|
menu_section "Maintenance"
|
||||||
|
menu_option 3 "Cleanup Toolkit Data" "Remove temp files"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "Database Tools:"
|
menu_back "Main Menu"
|
||||||
echo ""
|
menu_divider
|
||||||
echo -e " 2) 🔄 MySQL File Restore - Convert restored DB files to .sql"
|
|
||||||
echo ""
|
read_menu_choice "Select option" 0 3
|
||||||
echo -e "Maintenance:"
|
|
||||||
echo ""
|
|
||||||
echo -e " 3) 🗑️ Cleanup Toolkit Data - Remove IP reputation & temp files"
|
|
||||||
echo ""
|
|
||||||
echo -e " 0) Back to Main Menu"
|
|
||||||
echo ""
|
|
||||||
echo -e "──────────────────────────────────────────────────────────────"
|
|
||||||
echo -n "Select option: "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
show_acronis_menu() {
|
show_acronis_menu() {
|
||||||
show_banner
|
show_banner
|
||||||
echo -e "🔷 Acronis Cyber Protect"
|
menu_header "Acronis Cyber Protect"
|
||||||
|
|
||||||
|
menu_section "Installation & Setup"
|
||||||
|
menu_option 1 "Install Acronis Agent" "Download and install"
|
||||||
|
menu_option 2 "Register with Cloud" "Connect to Acronis Cloud"
|
||||||
|
menu_option 3 "Configure Agent" "Adjust settings"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "Installation & Setup:"
|
menu_section "Backup Management"
|
||||||
|
menu_option 4 "Manage Backups" "Complete backup interface"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " 1) Install Acronis Agent - Download and install"
|
menu_section "Status & Monitoring"
|
||||||
echo -e " 2) Register with Cloud - Connect to Acronis Cloud"
|
menu_option 5 "Check Agent Status" "Verify Acronis running"
|
||||||
echo -e " 3) Configure Agent - Adjust settings"
|
menu_option 6 "View Logs" "Check Acronis logs"
|
||||||
|
menu_option 7 "Troubleshoot" "Diagnose backup failures"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "Backup Management:"
|
menu_section "Maintenance"
|
||||||
|
menu_option 8 "Update Agent" "Upgrade to latest version"
|
||||||
|
menu_option 9 "Uninstall Acronis" "Remove agent"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " 4) 📊 Manage Backups - Complete backup interface"
|
menu_back "Backup Menu"
|
||||||
echo ""
|
menu_divider
|
||||||
echo -e "Status & Monitoring:"
|
|
||||||
echo ""
|
read_menu_choice "Select option" 0 9
|
||||||
echo -e " 5) Check Agent Status - Verify Acronis is running"
|
|
||||||
echo -e " 6) View Logs - Check Acronis logs"
|
|
||||||
echo -e " 7) Troubleshoot - Diagnose backup failures"
|
|
||||||
echo ""
|
|
||||||
echo -e "Maintenance:"
|
|
||||||
echo ""
|
|
||||||
echo -e " 8) Update Agent - Upgrade to latest version"
|
|
||||||
echo -e " 9) Uninstall Acronis - Remove agent"
|
|
||||||
echo ""
|
|
||||||
echo -e " 0) Back to Backup Menu"
|
|
||||||
echo ""
|
|
||||||
echo -e "──────────────────────────────────────────────────────────────"
|
|
||||||
echo -n "Select option: "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_backup_menu() {
|
handle_backup_menu() {
|
||||||
@@ -610,16 +580,13 @@ handle_backup_menu() {
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
show_backup_menu
|
show_backup_menu
|
||||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
|
||||||
return 0 # Exit if read fails
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$choice" in
|
case "$MENU_CHOICE" in
|
||||||
1) handle_acronis_menu ;;
|
1) handle_acronis_menu ;;
|
||||||
2) run_module "backup" "mysql-restore-to-sql.sh" ;;
|
2) run_module "backup" "mysql-restore-to-sql.sh" ;;
|
||||||
3) run_module "maintenance" "cleanup-toolkit-data.sh" ;;
|
3) run_module "maintenance" "cleanup-toolkit-data.sh" ;;
|
||||||
0) return ;;
|
0) return ;;
|
||||||
*) echo -e "Invalid option"; sleep 1 ;;
|
*) menu_invalid_choice ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -631,11 +598,8 @@ handle_acronis_menu() {
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
show_acronis_menu
|
show_acronis_menu
|
||||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
|
||||||
return 0 # Exit if read fails
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$choice" in
|
case "$MENU_CHOICE" in
|
||||||
1) run_module "backup" "acronis-install.sh" ;;
|
1) run_module "backup" "acronis-install.sh" ;;
|
||||||
2) run_module "backup" "acronis-register.sh" ;;
|
2) run_module "backup" "acronis-register.sh" ;;
|
||||||
3) run_module "backup" "acronis-configure.sh" ;;
|
3) run_module "backup" "acronis-configure.sh" ;;
|
||||||
@@ -646,7 +610,7 @@ handle_acronis_menu() {
|
|||||||
8) run_module "backup" "acronis-update.sh" ;;
|
8) run_module "backup" "acronis-update.sh" ;;
|
||||||
9) run_module "backup" "acronis-uninstall.sh" ;;
|
9) run_module "backup" "acronis-uninstall.sh" ;;
|
||||||
0) return ;;
|
0) return ;;
|
||||||
*) echo -e "Invalid option"; sleep 1 ;;
|
*) menu_invalid_choice ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -657,31 +621,31 @@ handle_acronis_menu() {
|
|||||||
|
|
||||||
show_email_menu() {
|
show_email_menu() {
|
||||||
show_banner
|
show_banner
|
||||||
echo -e "📧 Email Troubleshooting & Maintenance"
|
menu_header "Email Troubleshooting & Maintenance"
|
||||||
|
|
||||||
|
menu_section "Diagnostics"
|
||||||
|
menu_option 1 "Email Diagnostics" "Verify email/domain working"
|
||||||
|
menu_option 2 "Email Deliverability Test" "Test sending/receiving"
|
||||||
|
menu_option 3 "Mail Queue Inspector" "View stuck emails"
|
||||||
|
menu_option 4 "SMTP Connection Test" "Verify mail server"
|
||||||
|
menu_option 5 "SPF/DKIM/DMARC Check" "Email authentication"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "Diagnostics:"
|
menu_section "Troubleshooting"
|
||||||
|
menu_option 6 "Blacklist Check" "Check IP reputation"
|
||||||
|
menu_option 7 "Mail Log Analyzer" "Search mail logs"
|
||||||
|
menu_option 8 "Flush Mail Queue" "Clear stuck emails"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " 1) 🔍 Email Diagnostics - Verify email/domain is working ⭐"
|
menu_section "Maintenance"
|
||||||
echo -e " 2) 📬 Email Deliverability Test - Test sending/receiving"
|
menu_option 9 "Clean Mailboxes" "Remove old emails"
|
||||||
echo -e " 3) 🔍 Mail Queue Inspector - View stuck emails"
|
menu_option 10 "Mailbox Size Report" "Show usage per account"
|
||||||
echo -e " 4) 📊 SMTP Connection Test - Verify mail server"
|
|
||||||
echo -e " 5) 🔐 SPF/DKIM/DMARC Check - Email authentication"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "Troubleshooting:"
|
menu_back "Main Menu"
|
||||||
echo ""
|
menu_divider
|
||||||
echo -e " 6) 🚫 Blacklist Check - Check IP reputation"
|
|
||||||
echo -e " 7) 📧 Mail Log Analyzer - Search mail logs"
|
read_menu_choice "Select option" 0 10
|
||||||
echo -e " 8) 🔄 Flush Mail Queue - Clear stuck emails"
|
|
||||||
echo ""
|
|
||||||
echo -e "Maintenance:"
|
|
||||||
echo ""
|
|
||||||
echo -e " 9) 🧹 Clean Mailboxes - Remove old emails"
|
|
||||||
echo -e " 10) 📈 Mailbox Size Report - Show usage per account"
|
|
||||||
echo ""
|
|
||||||
echo -e " 0) Back to Main Menu"
|
|
||||||
echo ""
|
|
||||||
echo -e "──────────────────────────────────────────────────────────────"
|
|
||||||
echo -n "Select option: "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_email_menu() {
|
handle_email_menu() {
|
||||||
@@ -691,11 +655,8 @@ handle_email_menu() {
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
show_email_menu
|
show_email_menu
|
||||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
|
||||||
return 0 # Exit if read fails
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$choice" in
|
case "$MENU_CHOICE" in
|
||||||
1) run_module "email" "email-diagnostics.sh" ;;
|
1) run_module "email" "email-diagnostics.sh" ;;
|
||||||
2) run_module "email" "deliverability-test.sh" ;;
|
2) run_module "email" "deliverability-test.sh" ;;
|
||||||
3) run_module "email" "mail-queue-inspector.sh" ;;
|
3) run_module "email" "mail-queue-inspector.sh" ;;
|
||||||
@@ -707,7 +668,7 @@ handle_email_menu() {
|
|||||||
9) run_module "email" "clean-mailboxes.sh" ;;
|
9) run_module "email" "clean-mailboxes.sh" ;;
|
||||||
10) run_module "email" "mailbox-size-report.sh" ;;
|
10) run_module "email" "mailbox-size-report.sh" ;;
|
||||||
0) return ;;
|
0) return ;;
|
||||||
*) echo -e "Invalid option"; sleep 1 ;;
|
*) menu_invalid_choice ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -799,13 +760,7 @@ main() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Read from terminal (use /dev/tty directly for interaction)
|
case "$MENU_CHOICE" in
|
||||||
if ! read -r choice </dev/tty 2>/dev/null; then
|
|
||||||
# No terminal available, return from function gracefully
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$choice" in
|
|
||||||
1) run_module "diagnostics" "system-health-check.sh" ;;
|
1) run_module "diagnostics" "system-health-check.sh" ;;
|
||||||
2) handle_security_menu ;;
|
2) handle_security_menu ;;
|
||||||
3) handle_website_menu ;;
|
3) handle_website_menu ;;
|
||||||
@@ -837,8 +792,7 @@ main() {
|
|||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "Invalid option"
|
menu_invalid_choice
|
||||||
sleep 1
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -665,7 +665,10 @@ detect_all_attacks() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${#attacks[@]} -gt 0 ]; then
|
if [ ${#attacks[@]} -gt 0 ]; then
|
||||||
IFS=','; echo "${attacks[*]}"
|
local old_IFS="$IFS"
|
||||||
|
IFS=','
|
||||||
|
echo "${attacks[*]}"
|
||||||
|
IFS="$old_IFS"
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|||||||
Executable
+299
@@ -0,0 +1,299 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# MENU FUNCTIONS LIBRARY - EXAMPLE SCRIPT
|
||||||
|
################################################################################
|
||||||
|
# This script demonstrates how to use lib/menu-functions.sh
|
||||||
|
# Usage: bash lib/menu-functions-example.sh
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# Source required libraries
|
||||||
|
source "$SCRIPT_DIR/menu-functions.sh"
|
||||||
|
source "$SCRIPT_DIR/common-functions.sh"
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# EXAMPLE 1: SIMPLE MENU WITH 3 OPTIONS
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
show_simple_menu() {
|
||||||
|
while true; do
|
||||||
|
show_menu "Simple Menu" "3" "Main Menu" \
|
||||||
|
"Option 1" \
|
||||||
|
"Option 2" \
|
||||||
|
"Option 3"
|
||||||
|
|
||||||
|
case "$MENU_CHOICE" in
|
||||||
|
1) echo "You selected Option 1"; sleep 1 ;;
|
||||||
|
2) echo "You selected Option 2"; sleep 1 ;;
|
||||||
|
3) echo "You selected Option 3"; sleep 1 ;;
|
||||||
|
0) return ;;
|
||||||
|
*) menu_invalid_choice ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# EXAMPLE 2: MENU WITH STATUS INDICATORS
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
show_status_menu() {
|
||||||
|
while true; do
|
||||||
|
menu_header "Server Status"
|
||||||
|
menu_option_status 1 "Web Server" "running"
|
||||||
|
menu_option_status 2 "Database" "enabled"
|
||||||
|
menu_option_disabled 3 "Backup Manager" "(admin only)"
|
||||||
|
echo ""
|
||||||
|
menu_back "Main Menu"
|
||||||
|
menu_divider
|
||||||
|
|
||||||
|
read_menu_choice "Select option" 0 3
|
||||||
|
|
||||||
|
case "$MENU_CHOICE" in
|
||||||
|
1) echo "Web Server is running"; sleep 1 ;;
|
||||||
|
2) echo "Database is enabled"; sleep 1 ;;
|
||||||
|
3) echo "Backup Manager requires admin access"; sleep 1 ;;
|
||||||
|
0) return ;;
|
||||||
|
*) menu_invalid_choice ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# EXAMPLE 3: HIERARCHICAL MENUS WITH BREADCRUMBS
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
show_security_menu() {
|
||||||
|
menu_push "Security Menu"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
menu_header "Security Menu"
|
||||||
|
menu_show_depth
|
||||||
|
menu_option 1 "Threat Analysis"
|
||||||
|
menu_option 2 "Firewall Rules"
|
||||||
|
menu_option 3 "User Permissions"
|
||||||
|
echo ""
|
||||||
|
menu_back "$(menu_parent)"
|
||||||
|
menu_divider
|
||||||
|
menu_breadcrumb
|
||||||
|
|
||||||
|
read_menu_choice "Select option" 0 3
|
||||||
|
|
||||||
|
case "$MENU_CHOICE" in
|
||||||
|
1) show_threat_menu ;;
|
||||||
|
2) echo "Firewall Rules selected"; sleep 1 ;;
|
||||||
|
3) echo "User Permissions selected"; sleep 1 ;;
|
||||||
|
0) menu_pop; return ;;
|
||||||
|
*) menu_invalid_choice ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
show_threat_menu() {
|
||||||
|
menu_push "Threat Analysis"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
menu_header "Threat Analysis"
|
||||||
|
menu_show_depth
|
||||||
|
menu_option 1 "Bot Analyzer"
|
||||||
|
menu_option 2 "Malware Scanner"
|
||||||
|
echo ""
|
||||||
|
menu_back "$(menu_parent)"
|
||||||
|
menu_divider
|
||||||
|
menu_breadcrumb
|
||||||
|
|
||||||
|
read_menu_choice "Select option" 0 2
|
||||||
|
|
||||||
|
case "$MENU_CHOICE" in
|
||||||
|
1) echo "Running Bot Analysis..."; sleep 2 ;;
|
||||||
|
2) echo "Running Malware Scan..."; sleep 2 ;;
|
||||||
|
0) menu_pop; return ;;
|
||||||
|
*) menu_invalid_choice ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
menu_log_selection "Threat Analysis" "$MENU_CHOICE"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# EXAMPLE 4: MENU WITH PAGINATION
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
show_pagination_menu() {
|
||||||
|
menu_header "Long Options Menu (Paginated)"
|
||||||
|
|
||||||
|
local options=(
|
||||||
|
"Database Options"
|
||||||
|
"Backup Management"
|
||||||
|
"Security Hardening"
|
||||||
|
"Performance Tuning"
|
||||||
|
"User Management"
|
||||||
|
"Log Analysis"
|
||||||
|
"Network Configuration"
|
||||||
|
"Monitoring Tools"
|
||||||
|
"System Update"
|
||||||
|
"Documentation"
|
||||||
|
)
|
||||||
|
|
||||||
|
menu_paginate 5 "${options[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# EXAMPLE 5: MENU WITH SEARCH CAPABILITY
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
show_search_menu() {
|
||||||
|
menu_header "Search in Menu Options"
|
||||||
|
|
||||||
|
echo "Available options:"
|
||||||
|
local options=(
|
||||||
|
"Bot Analyzer"
|
||||||
|
"Bot Blocker"
|
||||||
|
"Malware Scanner"
|
||||||
|
"WordPress Manager"
|
||||||
|
"WordPress Cron Manager"
|
||||||
|
"IP Reputation Manager"
|
||||||
|
"Performance Analyzer"
|
||||||
|
)
|
||||||
|
|
||||||
|
printf " %s\n" "${options[@]}"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
printf "Search for (e.g., 'wordpress', 'bot'): "
|
||||||
|
read -r search_term
|
||||||
|
|
||||||
|
if [ -z "$search_term" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
menu_search "$search_term" "${options[@]}" || echo "No results found"
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# EXAMPLE 6: MENU WITH CONFIRMATION
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
show_confirmation_menu() {
|
||||||
|
menu_header "Dangerous Operations"
|
||||||
|
|
||||||
|
menu_option 1 "Delete all logs"
|
||||||
|
menu_option 2 "Reset configuration"
|
||||||
|
menu_option 3 "Purge cache"
|
||||||
|
echo ""
|
||||||
|
menu_back "Main Menu"
|
||||||
|
menu_divider
|
||||||
|
|
||||||
|
read_menu_choice "Select option" 0 3
|
||||||
|
|
||||||
|
case "$MENU_CHOICE" in
|
||||||
|
1)
|
||||||
|
if confirm_action "Really delete all logs?"; then
|
||||||
|
echo "Deleting logs..."
|
||||||
|
sleep 1
|
||||||
|
else
|
||||||
|
echo "Operation cancelled"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
if confirm_action "Really reset configuration? This cannot be undone"; then
|
||||||
|
echo "Resetting configuration..."
|
||||||
|
sleep 1
|
||||||
|
else
|
||||||
|
echo "Operation cancelled"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
if confirm_action "Really purge cache?"; then
|
||||||
|
echo "Purging cache..."
|
||||||
|
sleep 1
|
||||||
|
else
|
||||||
|
echo "Operation cancelled"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
0) return ;;
|
||||||
|
*) menu_invalid_choice ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# EXAMPLE 7: MENU WITH BATCH MODE
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
show_batch_menu() {
|
||||||
|
menu_header "Batch Mode Example"
|
||||||
|
|
||||||
|
echo "Current mode: $(is_batch_mode && echo "BATCH" || echo "INTERACTIVE")"
|
||||||
|
echo ""
|
||||||
|
menu_option 1 "Enable batch mode"
|
||||||
|
menu_option 2 "Disable batch mode"
|
||||||
|
menu_option 3 "Run task (auto-default in batch)"
|
||||||
|
echo ""
|
||||||
|
menu_back "Main Menu"
|
||||||
|
menu_divider
|
||||||
|
|
||||||
|
read_menu_choice "Select option" 0 3
|
||||||
|
|
||||||
|
case "$MENU_CHOICE" in
|
||||||
|
1) set_batch_mode on; echo "Batch mode enabled" ;;
|
||||||
|
2) set_batch_mode off; echo "Batch mode disabled" ;;
|
||||||
|
3)
|
||||||
|
# This will return "1" immediately in batch mode
|
||||||
|
menu_or_batch "1" "Execute task" 0 3
|
||||||
|
echo "Task executed with choice: $MENU_CHOICE"
|
||||||
|
;;
|
||||||
|
0) return ;;
|
||||||
|
*) menu_invalid_choice ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# MAIN MENU
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
show_main_menu() {
|
||||||
|
while true; do
|
||||||
|
menu_header "Menu Functions Library - Examples"
|
||||||
|
|
||||||
|
menu_option 1 "Simple Menu (3 options)"
|
||||||
|
menu_option 2 "Menu with Status Indicators"
|
||||||
|
menu_option 3 "Hierarchical Menus (nested)"
|
||||||
|
menu_option 4 "Menu Pagination"
|
||||||
|
menu_option 5 "Menu Search/Filter"
|
||||||
|
menu_option 6 "Confirmation Dialogs"
|
||||||
|
menu_option 7 "Batch Mode"
|
||||||
|
menu_option 8 "View Menu Help"
|
||||||
|
echo ""
|
||||||
|
menu_exit
|
||||||
|
menu_divider
|
||||||
|
|
||||||
|
read_menu_choice "Select example" 0 8
|
||||||
|
|
||||||
|
case "$MENU_CHOICE" in
|
||||||
|
1) show_simple_menu ;;
|
||||||
|
2) show_status_menu ;;
|
||||||
|
3) show_security_menu ;;
|
||||||
|
4) show_pagination_menu ;;
|
||||||
|
5) show_search_menu ;;
|
||||||
|
6) show_confirmation_menu ;;
|
||||||
|
7) show_batch_menu ;;
|
||||||
|
8) menu_help ;;
|
||||||
|
0) echo "Exiting..."; return ;;
|
||||||
|
*) menu_invalid_choice ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# EXECUTION
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
clear
|
||||||
|
show_banner
|
||||||
|
show_main_menu
|
||||||
|
press_enter
|
||||||
File diff suppressed because it is too large
Load Diff
+4
-2
@@ -508,8 +508,10 @@ analyze_domain_traffic_advanced() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Sort values
|
# Sort values
|
||||||
IFS=$'\n' rpm_sorted=($(sort -n <<<"${rpm_values[*]}"))
|
local old_IFS="$IFS"
|
||||||
unset IFS
|
IFS=$'\n'
|
||||||
|
rpm_sorted=($(sort -n <<<"${rpm_values[*]}"))
|
||||||
|
IFS="$old_IFS"
|
||||||
|
|
||||||
local peak_rpm=${rpm_sorted[-1]:-0}
|
local peak_rpm=${rpm_sorted[-1]:-0}
|
||||||
|
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ while IFS= read -r username; do
|
|||||||
# Determine if optimization needed
|
# Determine if optimization needed
|
||||||
# Flag as YES if: different from current (increase or decrease)
|
# Flag as YES if: different from current (increase or decrease)
|
||||||
# AND has meaningful traffic (>= 5 concurrent) OR memory efficiency gain (> 20% reduction)
|
# AND has meaningful traffic (>= 5 concurrent) OR memory efficiency gain (> 20% reduction)
|
||||||
local memory_reduction=0
|
memory_reduction=0
|
||||||
if [ "$recommended" -lt "$current" ]; then
|
if [ "$recommended" -lt "$current" ]; then
|
||||||
memory_reduction=$(( (current - recommended) * 100 / current ))
|
memory_reduction=$(( (current - recommended) * 100 / current ))
|
||||||
fi
|
fi
|
||||||
@@ -170,7 +170,7 @@ while IFS= read -r username; do
|
|||||||
# Check if change is meaningful:
|
# Check if change is meaningful:
|
||||||
# 1. Has significant traffic (>= 5 concurrent requests)
|
# 1. Has significant traffic (>= 5 concurrent requests)
|
||||||
# 2. OR significant memory reduction (>= 20%)
|
# 2. OR significant memory reduction (>= 20%)
|
||||||
local has_traffic=0
|
has_traffic=0
|
||||||
[ "$peak" != "?" ] && [ "$peak" -ge 5 ] && has_traffic=1
|
[ "$peak" != "?" ] && [ "$peak" -ge 5 ] && has_traffic=1
|
||||||
|
|
||||||
if [ "$has_traffic" = "1" ] || [ "$memory_reduction" -ge 20 ]; then
|
if [ "$has_traffic" = "1" ] || [ "$memory_reduction" -ge 20 ]; then
|
||||||
|
|||||||
@@ -991,7 +991,7 @@ optimize_multiple_domains_wrapper() {
|
|||||||
optimize_domain_direct "$domain" "$username"
|
optimize_domain_direct "$domain" "$username"
|
||||||
local result=$?
|
local result=$?
|
||||||
|
|
||||||
if [ $result -eq 0 ]; then
|
if [ "$result" -eq 0 ]; then
|
||||||
optimized=$((optimized + 1))
|
optimized=$((optimized + 1))
|
||||||
else
|
else
|
||||||
failed=$((failed + 1))
|
failed=$((failed + 1))
|
||||||
|
|||||||
@@ -1626,13 +1626,15 @@ show_blocking_menu() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Sort by score
|
# Sort by score
|
||||||
IFS=$'\n' blockable_list=($(sort -t'|' -k2 -rn <<<"${blockable_list[*]}"))
|
local old_IFS="$IFS"
|
||||||
unset IFS
|
IFS=$'\n'
|
||||||
|
blockable_list=($(sort -t'|' -k2 -rn <<<"${blockable_list[*]}"))
|
||||||
|
IFS="$old_IFS"
|
||||||
|
|
||||||
# Display IPs
|
# Display IPs
|
||||||
local idx=1
|
local idx=1
|
||||||
for entry in "${blockable_list[@]}"; do
|
for entry in "${blockable_list[@]}"; do
|
||||||
IFS='|' read -r ip score hits attacks <<< "$entry"
|
IFS='|' read -r ip score hits attacks <<< "$entry" || true
|
||||||
local level=$(get_threat_level "$score")
|
local level=$(get_threat_level "$score")
|
||||||
local color=$(get_threat_color "$level")
|
local color=$(get_threat_color "$level")
|
||||||
|
|
||||||
|
|||||||
@@ -1599,7 +1599,7 @@ STANDALONE_EOF
|
|||||||
|
|
||||||
# Escape special characters for sed (handle /, \, &, |, $)
|
# Escape special characters for sed (handle /, \, &, |, $)
|
||||||
# CRITICAL FIX: Must escape the delimiter (|) as well since we use it in the sed command
|
# CRITICAL FIX: Must escape the delimiter (|) as well since we use it in the sed command
|
||||||
local escaped_paths=$(printf '%s\n' "$paths_declaration" | sed -e 's/[\/&|]/\\&/g')
|
escaped_paths=$(printf '%s\n' "$paths_declaration" | sed -e 's/[\/&|]/\\&/g')
|
||||||
|
|
||||||
if ! sed -i "s|PLACEHOLDER_SCAN_PATHS|$escaped_paths|" "$session_dir/scan.sh"; then
|
if ! sed -i "s|PLACEHOLDER_SCAN_PATHS|$escaped_paths|" "$session_dir/scan.sh"; then
|
||||||
echo -e "${RED}ERROR: Failed to generate standalone scanner script${NC}"
|
echo -e "${RED}ERROR: Failed to generate standalone scanner script${NC}"
|
||||||
|
|||||||
Reference in New Issue
Block a user