Compare commits
3 Commits
6809a4e68a
...
296113db99
| Author | SHA1 | Date | |
|---|---|---|---|
| 296113db99 | |||
| 5d1cc93aee | |||
| 7fb7c230b9 |
@@ -8,8 +8,9 @@
|
|||||||
# Source dependencies
|
# Source dependencies
|
||||||
if [ -z "$TOOLKIT_BASE_DIR" ]; then
|
if [ -z "$TOOLKIT_BASE_DIR" ]; then
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$SCRIPT_DIR/common-functions.sh"
|
|
||||||
source "$SCRIPT_DIR/system-detect.sh"
|
[ -f "$SCRIPT_DIR/common-functions.sh" ] && source "$SCRIPT_DIR/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; return 1; }
|
||||||
|
[ -f "$SCRIPT_DIR/system-detect.sh" ] && source "$SCRIPT_DIR/system-detect.sh" || { echo "ERROR: system-detect.sh not found" >&2; return 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Source control panel helpers if available
|
# Source control panel helpers if available
|
||||||
|
|||||||
@@ -6,6 +6,12 @@
|
|||||||
# Shared functions for email troubleshooting modules
|
# Shared functions for email troubleshooting modules
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
# Source system detection (for detect_control_panel function)
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
if [ -f "$SCRIPT_DIR/system-detect.sh" ]; then
|
||||||
|
source "$SCRIPT_DIR/system-detect.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
# Detect MTA (Mail Transfer Agent)
|
# Detect MTA (Mail Transfer Agent)
|
||||||
detect_mta() {
|
detect_mta() {
|
||||||
if command -v exim &>/dev/null; then
|
if command -v exim &>/dev/null; then
|
||||||
|
|||||||
+9
-10
@@ -8,9 +8,10 @@
|
|||||||
# Source dependencies
|
# Source dependencies
|
||||||
if [ -z "$TOOLKIT_BASE_DIR" ]; then
|
if [ -z "$TOOLKIT_BASE_DIR" ]; then
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$SCRIPT_DIR/common-functions.sh"
|
|
||||||
source "$SCRIPT_DIR/system-detect.sh"
|
[ -f "$SCRIPT_DIR/common-functions.sh" ] && source "$SCRIPT_DIR/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; return 1; }
|
||||||
source "$SCRIPT_DIR/user-manager.sh"
|
[ -f "$SCRIPT_DIR/system-detect.sh" ] && source "$SCRIPT_DIR/system-detect.sh" || { echo "ERROR: system-detect.sh not found" >&2; return 1; }
|
||||||
|
[ -f "$SCRIPT_DIR/user-manager.sh" ] && source "$SCRIPT_DIR/user-manager.sh" || { echo "ERROR: user-manager.sh not found" >&2; return 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
@@ -133,9 +134,8 @@ map_database_to_user_domain() {
|
|||||||
# Build map for all databases
|
# Build map for all databases
|
||||||
print_info "Building database to user/domain mapping..."
|
print_info "Building database to user/domain mapping..."
|
||||||
|
|
||||||
local all_dbs=$(mysql -Ns -e "SHOW DATABASES" 2>/dev/null | grep -v "^information_schema$\|^mysql$\|^performance_schema$\|^sys$")
|
# Use while read to safely iterate over database names (handles spaces in names)
|
||||||
|
mysql -Ns -e "SHOW DATABASES" 2>/dev/null | grep -v "^information_schema$\|^mysql$\|^performance_schema$\|^sys$" | while IFS= read -r db; do
|
||||||
for db in $all_dbs; do
|
|
||||||
# Extract potential username from database name
|
# Extract potential username from database name
|
||||||
# Format: username_dbname
|
# Format: username_dbname
|
||||||
local potential_user=$(echo "$db" | cut -d_ -f1)
|
local potential_user=$(echo "$db" | cut -d_ -f1)
|
||||||
@@ -359,11 +359,10 @@ analyze_queries_for_problems() {
|
|||||||
# Extract database
|
# Extract database
|
||||||
local db_name=$(extract_database_from_query "$query")
|
local db_name=$(extract_database_from_query "$query")
|
||||||
|
|
||||||
# Extract tables
|
# Extract tables and safely iterate (handles spaces in table names)
|
||||||
local tables=$(extract_tables_from_query "$query")
|
extract_tables_from_query "$query" | while IFS= read -r table; do
|
||||||
|
[ -z "$table" ] && continue # Skip empty lines
|
||||||
|
|
||||||
# Identify plugins
|
|
||||||
for table in $tables; do
|
|
||||||
local plugin=$(identify_plugin_from_table "$table")
|
local plugin=$(identify_plugin_from_table "$table")
|
||||||
local owner=$(get_database_owner "$db_name")
|
local owner=$(get_database_owner "$db_name")
|
||||||
local domain=$(get_database_domain "$db_name")
|
local domain=$(get_database_domain "$db_name")
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
# Source common functions if not already loaded
|
# Source common functions if not already loaded
|
||||||
if [ -z "$TOOLKIT_BASE_DIR" ]; then
|
if [ -z "$TOOLKIT_BASE_DIR" ]; then
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$SCRIPT_DIR/common-functions.sh"
|
[ -f "$SCRIPT_DIR/common-functions.sh" ] && source "$SCRIPT_DIR/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; return 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|||||||
+4
-3
@@ -9,9 +9,10 @@
|
|||||||
# Source dependencies
|
# Source dependencies
|
||||||
if [ -z "$TOOLKIT_BASE_DIR" ]; then
|
if [ -z "$TOOLKIT_BASE_DIR" ]; then
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$SCRIPT_DIR/common-functions.sh"
|
|
||||||
source "$SCRIPT_DIR/system-detect.sh"
|
[ -f "$SCRIPT_DIR/common-functions.sh" ] && source "$SCRIPT_DIR/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; return 1; }
|
||||||
source "$SCRIPT_DIR/user-manager.sh"
|
[ -f "$SCRIPT_DIR/system-detect.sh" ] && source "$SCRIPT_DIR/system-detect.sh" || { echo "ERROR: system-detect.sh not found" >&2; return 1; }
|
||||||
|
[ -f "$SCRIPT_DIR/user-manager.sh" ] && source "$SCRIPT_DIR/user-manager.sh" || { echo "ERROR: user-manager.sh not found" >&2; return 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Reference database location
|
# Reference database location
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
# Source common functions if not already loaded
|
# Source common functions if not already loaded
|
||||||
if [ -z "$TOOLKIT_BASE_DIR" ]; then
|
if [ -z "$TOOLKIT_BASE_DIR" ]; then
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$SCRIPT_DIR/common-functions.sh"
|
[ -f "$SCRIPT_DIR/common-functions.sh" ] && source "$SCRIPT_DIR/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; return 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Global variables (session-only) - only initialize if not already set
|
# Global variables (session-only) - only initialize if not already set
|
||||||
|
|||||||
+3
-2
@@ -8,8 +8,9 @@
|
|||||||
# Source dependencies
|
# Source dependencies
|
||||||
if [ -z "$TOOLKIT_BASE_DIR" ]; then
|
if [ -z "$TOOLKIT_BASE_DIR" ]; then
|
||||||
_LIB_SRCDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
_LIB_SRCDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$_LIB_SRCDIR/common-functions.sh"
|
|
||||||
source "$_LIB_SRCDIR/system-detect.sh"
|
[ -f "$_LIB_SRCDIR/common-functions.sh" ] && source "$_LIB_SRCDIR/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; return 1; }
|
||||||
|
[ -f "$_LIB_SRCDIR/system-detect.sh" ] && source "$_LIB_SRCDIR/system-detect.sh" || { echo "ERROR: system-detect.sh not found" >&2; return 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Initialize temp session directory if not set
|
# Initialize temp session directory if not set
|
||||||
|
|||||||
@@ -709,7 +709,7 @@ if [ "$greylist" -gt 0 ] && [ "$delivered" -eq 0 ]; then
|
|||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$check_type" != "2" ] && [ $account_found -eq 0 ]; then
|
if [ "${check_type:-1}" != "2" ] && [ "${account_found:-0}" -eq 0 ]; then
|
||||||
echo "Email account not found:"
|
echo "Email account not found:"
|
||||||
echo " 1. Verify the email address is spelled correctly"
|
echo " 1. Verify the email address is spelled correctly"
|
||||||
echo " 2. Check if domain DNS points to this server"
|
echo " 2. Check if domain DNS points to this server"
|
||||||
|
|||||||
@@ -172,8 +172,8 @@ fi
|
|||||||
|
|
||||||
# Session/lock files
|
# Session/lock files
|
||||||
for pattern in /var/run/server-toolkit* /var/lock/server-toolkit*; do
|
for pattern in /var/run/server-toolkit* /var/lock/server-toolkit*; do
|
||||||
if ls $pattern 2>/dev/null | grep -q .; then
|
if ls "$pattern" 2>/dev/null | grep -q .; then
|
||||||
rm -f $pattern 2>/dev/null
|
rm -f "$pattern" 2>/dev/null
|
||||||
echo -e " ${GREEN}✓${NC} Removed: Session/lock files"
|
echo -e " ${GREEN}✓${NC} Removed: Session/lock files"
|
||||||
((cleaned_count++))
|
((cleaned_count++))
|
||||||
break
|
break
|
||||||
@@ -189,9 +189,9 @@ remove_logs="${remove_logs:-no}"
|
|||||||
|
|
||||||
if [ "$remove_logs" = "yes" ]; then
|
if [ "$remove_logs" = "yes" ]; then
|
||||||
for pattern in /var/log/server-toolkit*.log; do
|
for pattern in /var/log/server-toolkit*.log; do
|
||||||
if ls $pattern 2>/dev/null | grep -q .; then
|
if ls "$pattern" 2>/dev/null | grep -q .; then
|
||||||
count=$(ls $pattern 2>/dev/null | wc -l)
|
count=$(ls "$pattern" 2>/dev/null | wc -l)
|
||||||
rm -f $pattern 2>/dev/null
|
rm -f "$pattern" 2>/dev/null
|
||||||
echo -e " ${GREEN}✓${NC} Removed: $count log file(s)"
|
echo -e " ${GREEN}✓${NC} Removed: $count log file(s)"
|
||||||
((cleaned_count++))
|
((cleaned_count++))
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ if command -v ipset &>/dev/null; then
|
|||||||
IPSET_CREATE_OUTPUT=$(ipset create "$IPSET_NAME" hash:ip timeout 3600 maxelem 65536 2>&1)
|
IPSET_CREATE_OUTPUT=$(ipset create "$IPSET_NAME" hash:ip timeout 3600 maxelem 65536 2>&1)
|
||||||
IPSET_CREATE_EXIT=$?
|
IPSET_CREATE_EXIT=$?
|
||||||
|
|
||||||
if [ $IPSET_CREATE_EXIT -eq 0 ]; then
|
if [ "${IPSET_CREATE_EXIT:-1}" -eq 0 ]; then
|
||||||
IPSET_AVAILABLE=1
|
IPSET_AVAILABLE=1
|
||||||
IPSET_SUPPORTS_TIMEOUT=1
|
IPSET_SUPPORTS_TIMEOUT=1
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ if command -v ipset &>/dev/null; then
|
|||||||
IPTABLES_OUTPUT=$(iptables -I INPUT -m set --match-set "$IPSET_NAME" src -j DROP 2>&1)
|
IPTABLES_OUTPUT=$(iptables -I INPUT -m set --match-set "$IPSET_NAME" src -j DROP 2>&1)
|
||||||
IPTABLES_EXIT=$?
|
IPTABLES_EXIT=$?
|
||||||
|
|
||||||
if [ $IPTABLES_EXIT -ne 0 ]; then
|
if [ "${IPTABLES_EXIT:-1}" -ne 0 ]; then
|
||||||
# iptables rule failed - clean up ipset and report error
|
# iptables rule failed - clean up ipset and report error
|
||||||
ipset destroy "$IPSET_NAME" 2>/dev/null
|
ipset destroy "$IPSET_NAME" 2>/dev/null
|
||||||
IPSET_AVAILABLE=0
|
IPSET_AVAILABLE=0
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ if command -v ipset &>/dev/null; then
|
|||||||
IPSET_CREATE_OUTPUT=$(ipset create "$IPSET_NAME" hash:ip timeout 3600 maxelem 65536 2>&1)
|
IPSET_CREATE_OUTPUT=$(ipset create "$IPSET_NAME" hash:ip timeout 3600 maxelem 65536 2>&1)
|
||||||
IPSET_CREATE_EXIT=$?
|
IPSET_CREATE_EXIT=$?
|
||||||
|
|
||||||
if [ $IPSET_CREATE_EXIT -eq 0 ]; then
|
if [ "${IPSET_CREATE_EXIT:-1}" -eq 0 ]; then
|
||||||
IPSET_AVAILABLE=1
|
IPSET_AVAILABLE=1
|
||||||
IPSET_SUPPORTS_TIMEOUT=1
|
IPSET_SUPPORTS_TIMEOUT=1
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ if command -v ipset &>/dev/null; then
|
|||||||
IPTABLES_OUTPUT=$(iptables -I INPUT -m set --match-set "$IPSET_NAME" src -j DROP 2>&1)
|
IPTABLES_OUTPUT=$(iptables -I INPUT -m set --match-set "$IPSET_NAME" src -j DROP 2>&1)
|
||||||
IPTABLES_EXIT=$?
|
IPTABLES_EXIT=$?
|
||||||
|
|
||||||
if [ $IPTABLES_EXIT -ne 0 ]; then
|
if [ "${IPTABLES_EXIT:-1}" -ne 0 ]; then
|
||||||
# iptables rule failed - clean up ipset and report error
|
# iptables rule failed - clean up ipset and report error
|
||||||
ipset destroy "$IPSET_NAME" 2>/dev/null
|
ipset destroy "$IPSET_NAME" 2>/dev/null
|
||||||
IPSET_AVAILABLE=0
|
IPSET_AVAILABLE=0
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ install_all_scanners() {
|
|||||||
cd maldetect-* 2>/dev/null
|
cd maldetect-* 2>/dev/null
|
||||||
./install.sh &>/dev/null
|
./install.sh &>/dev/null
|
||||||
cd /tmp
|
cd /tmp
|
||||||
rm -rf maldetect-*
|
rm -rf "maldetect-"*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_maldet_installed; then
|
if is_maldet_installed; then
|
||||||
@@ -853,7 +853,7 @@ for scanner in "${AVAILABLE_SCANNERS[@]}"; do
|
|||||||
imunify-antivirus malware on-demand start --path="$path" &>> "$LOG_DIR/imunify.log"
|
imunify-antivirus malware on-demand start --path="$path" &>> "$LOG_DIR/imunify.log"
|
||||||
START_EXIT=$?
|
START_EXIT=$?
|
||||||
|
|
||||||
if [ $START_EXIT -ne 0 ]; then
|
if [ "${START_EXIT:-1}" -ne 0 ]; then
|
||||||
log_message "ERROR: ImunifyAV scan failed to start for $path (exit code: $START_EXIT)"
|
log_message "ERROR: ImunifyAV scan failed to start for $path (exit code: $START_EXIT)"
|
||||||
echo " ✗ Scan failed to start for $path (check logs)"
|
echo " ✗ Scan failed to start for $path (check logs)"
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -9,10 +9,11 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||||
source "$SCRIPT_DIR/lib/common-functions.sh"
|
|
||||||
source "$SCRIPT_DIR/lib/system-detect.sh"
|
[ -f "$SCRIPT_DIR/lib/common-functions.sh" ] && source "$SCRIPT_DIR/lib/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; exit 1; }
|
||||||
source "$SCRIPT_DIR/lib/user-manager.sh"
|
[ -f "$SCRIPT_DIR/lib/system-detect.sh" ] && source "$SCRIPT_DIR/lib/system-detect.sh" || { echo "ERROR: system-detect.sh not found" >&2; exit 1; }
|
||||||
source "$SCRIPT_DIR/lib/ip-reputation.sh"
|
[ -f "$SCRIPT_DIR/lib/user-manager.sh" ] && source "$SCRIPT_DIR/lib/user-manager.sh" || { echo "ERROR: user-manager.sh not found" >&2; exit 1; }
|
||||||
|
[ -f "$SCRIPT_DIR/lib/ip-reputation.sh" ] && source "$SCRIPT_DIR/lib/ip-reputation.sh" || { echo "ERROR: ip-reputation.sh not found" >&2; exit 1; }
|
||||||
|
|
||||||
# Configuration - Use system-detected paths
|
# Configuration - Use system-detected paths
|
||||||
APACHE_ERROR_LOG="/var/log/apache2/error_log" # Will be auto-detected
|
APACHE_ERROR_LOG="/var/log/apache2/error_log" # Will be auto-detected
|
||||||
|
|||||||
@@ -12,8 +12,9 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
|
||||||
source "$SCRIPT_DIR/lib/common-functions.sh"
|
|
||||||
source "$SCRIPT_DIR/lib/system-detect.sh"
|
[ -f "$SCRIPT_DIR/lib/common-functions.sh" ] && source "$SCRIPT_DIR/lib/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; exit 1; }
|
||||||
|
[ -f "$SCRIPT_DIR/lib/system-detect.sh" ] && source "$SCRIPT_DIR/lib/system-detect.sh" || { echo "ERROR: system-detect.sh not found" >&2; exit 1; }
|
||||||
|
|
||||||
if [ "$EUID" -ne 0 ]; then
|
if [ "$EUID" -ne 0 ]; then
|
||||||
print_error "This script must be run as root"
|
print_error "This script must be run as root"
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ echo " ✓ Download artifacts removed"
|
|||||||
|
|
||||||
# Remove toolkit temp files
|
# Remove toolkit temp files
|
||||||
echo "→ Removing temporary files..."
|
echo "→ Removing temporary files..."
|
||||||
rm -rf /tmp/live-monitor-* 2>/dev/null
|
rm -rf /tmp/"live-monitor-"* 2>/dev/null
|
||||||
rm -rf /tmp/server-toolkit-* 2>/dev/null
|
rm -rf /tmp/"server-toolkit-"* 2>/dev/null
|
||||||
echo " ✓ Temp files removed"
|
echo " ✓ Temp files removed"
|
||||||
|
|
||||||
# Clean last log and audit trails
|
# Clean last log and audit trails
|
||||||
|
|||||||
Reference in New Issue
Block a user