Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| db093d7b9b | |||
| 79978c7d43 | |||
| 172a115175 |
+23
-2
@@ -325,11 +325,19 @@ staggered_timing:
|
||||
|
||||
wp-config_modification:
|
||||
function: disable_wpcron_in_config()
|
||||
location: Line 2 after <?php tag
|
||||
location: Before "/* That's all, stop editing! */" comment (proper WordPress convention)
|
||||
fallback: After <?php tag if "stop editing" not found
|
||||
adds: define('DISABLE_WP_CRON', true);
|
||||
safety: Backup created, verification, rollback on failure
|
||||
safety: Removes existing entries first, backup created, verification, rollback on failure
|
||||
format: User crontabs (crontab -u $user) not system crontab
|
||||
|
||||
domain_lookup_method:
|
||||
# Fixed 2025-11-10 - Two-step lookup process
|
||||
method_1: Check main_domain in /var/cpanel/userdata/*/main files (YAML: main_domain:)
|
||||
method_2: Fallback to search domain-specific files for servername (YAML: servername:)
|
||||
skip_files: "*.cache, */main, */cache, */cache.json"
|
||||
rationale: cPanel stores main_domain in main files, servername in domain-specific files
|
||||
|
||||
cron_job_format: |
|
||||
0,15,30,45 * * * * cd /home/user/public_html && /usr/bin/php -q wp-cron.php >/dev/null 2>&1
|
||||
|
||||
@@ -345,6 +353,19 @@ options:
|
||||
0: Return to menu (cancel)
|
||||
|
||||
[RECENT_COMMITS]
|
||||
# Latest changes (2025-11-10)
|
||||
|
||||
commit: 172a115
|
||||
date: 2025-11-10
|
||||
title: Fix domain lookup in WordPress Cron Manager
|
||||
files: modules/website/wordpress/wordpress-cron-manager.sh
|
||||
changes:
|
||||
- Fixed broken domain lookup (was only searching /var/cpanel/userdata/*/main for servername:)
|
||||
- Added two-step lookup: main_domain in main files, then servername in domain files
|
||||
- Applied fix to options 2, 5, 6 (all domain lookup locations)
|
||||
- Skip cache files during search
|
||||
testing: Verified with pickledperil.com - lookup now works correctly
|
||||
|
||||
# Latest changes (2025-11-07)
|
||||
|
||||
commit: 56776a1
|
||||
|
||||
@@ -352,6 +352,9 @@ parse_logs() {
|
||||
|
||||
# Parse all domain logs (excluding -bytes_log, .offset, and error_log files)
|
||||
# cPanel creates files like: domain.com, domain.com-ssl_log
|
||||
local file_count=0
|
||||
local progress_interval=50
|
||||
echo ""
|
||||
find "$LOG_DIR" -type f ! -name "*-bytes_log" ! -name "*.offset" ! -name "*error_log" "${find_opts[@]}" 2>/dev/null | while read -r logfile; do
|
||||
# Skip empty files
|
||||
[ -s "$logfile" ] || continue
|
||||
@@ -365,6 +368,12 @@ parse_logs() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# Show progress every N files
|
||||
file_count=$((file_count + 1))
|
||||
if [ $((file_count % progress_interval)) -eq 0 ]; then
|
||||
echo -ne "\r Parsed $file_count log files... (current: $domain)"
|
||||
fi
|
||||
|
||||
# Parse Apache Combined Log Format with error handling
|
||||
# Format: IP - - [timestamp] "METHOD URL PROTOCOL" STATUS SIZE "REFERRER" "USER-AGENT"
|
||||
awk -v domain="$domain" '
|
||||
@@ -411,6 +420,9 @@ parse_logs() {
|
||||
}' "$logfile" >> "$TEMP_DIR/parsed_logs.txt" 2>/dev/null
|
||||
done
|
||||
|
||||
# Clear the progress line
|
||||
echo -ne "\r\033[K"
|
||||
|
||||
if [ ! -s "$TEMP_DIR/parsed_logs.txt" ]; then
|
||||
print_alert "No log entries were parsed. Check log format or permissions."
|
||||
return 1
|
||||
|
||||
@@ -221,8 +221,30 @@ case "$choice" in
|
||||
echo "Searching for WordPress installation for $domain..."
|
||||
|
||||
# Try to find via cPanel user data
|
||||
# Search both main_domain (in main files) and servername (in domain files)
|
||||
wp_config=""
|
||||
|
||||
# Method 1: Check main_domain in /var/cpanel/userdata/*/main files
|
||||
for userdata_file in /var/cpanel/userdata/*/main; do
|
||||
if grep -q "^main_domain: $domain" "$userdata_file" 2>/dev/null; then
|
||||
user=$(basename "$(dirname "$userdata_file")")
|
||||
potential_config="/home/$user/public_html/wp-config.php"
|
||||
if [ -f "$potential_config" ]; then
|
||||
wp_config="$potential_config"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Method 2: If not found, search all domain-specific files for servername
|
||||
if [ -z "$wp_config" ]; then
|
||||
for userdata_file in /var/cpanel/userdata/*/*; do
|
||||
# Skip cache files and main files
|
||||
[[ "$userdata_file" == *.cache ]] && continue
|
||||
[[ "$userdata_file" == */main ]] && continue
|
||||
[[ "$userdata_file" == */cache ]] && continue
|
||||
[[ "$userdata_file" == */cache.json ]] && continue
|
||||
|
||||
if grep -q "^servername: $domain" "$userdata_file" 2>/dev/null; then
|
||||
user=$(basename "$(dirname "$userdata_file")")
|
||||
potential_config="/home/$user/public_html/wp-config.php"
|
||||
@@ -232,6 +254,7 @@ case "$choice" in
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -z "$wp_config" ]; then
|
||||
print_error "WordPress installation not found for $domain"
|
||||
@@ -463,7 +486,27 @@ case "$choice" in
|
||||
|
||||
# Find WordPress for domain
|
||||
wp_config=""
|
||||
|
||||
# Method 1: Check main_domain in main files
|
||||
for userdata_file in /var/cpanel/userdata/*/main; do
|
||||
if grep -q "^main_domain: $domain" "$userdata_file" 2>/dev/null; then
|
||||
user=$(basename "$(dirname "$userdata_file")")
|
||||
potential_config="/home/$user/public_html/wp-config.php"
|
||||
if [ -f "$potential_config" ]; then
|
||||
wp_config="$potential_config"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Method 2: Search domain-specific files for servername
|
||||
if [ -z "$wp_config" ]; then
|
||||
for userdata_file in /var/cpanel/userdata/*/*; do
|
||||
[[ "$userdata_file" == *.cache ]] && continue
|
||||
[[ "$userdata_file" == */main ]] && continue
|
||||
[[ "$userdata_file" == */cache ]] && continue
|
||||
[[ "$userdata_file" == */cache.json ]] && continue
|
||||
|
||||
if grep -q "^servername: $domain" "$userdata_file" 2>/dev/null; then
|
||||
user=$(basename "$(dirname "$userdata_file")")
|
||||
potential_config="/home/$user/public_html/wp-config.php"
|
||||
@@ -473,6 +516,7 @@ case "$choice" in
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -z "$wp_config" ]; then
|
||||
print_error "WordPress not found for $domain"
|
||||
@@ -573,7 +617,27 @@ case "$choice" in
|
||||
|
||||
# Find WordPress installation
|
||||
wp_config=""
|
||||
|
||||
# Method 1: Check main_domain in main files
|
||||
for userdata_file in /var/cpanel/userdata/*/main; do
|
||||
if grep -q "^main_domain: $domain" "$userdata_file" 2>/dev/null; then
|
||||
user=$(basename "$(dirname "$userdata_file")")
|
||||
potential_config="/home/$user/public_html/wp-config.php"
|
||||
if [ -f "$potential_config" ]; then
|
||||
wp_config="$potential_config"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Method 2: Search domain-specific files for servername
|
||||
if [ -z "$wp_config" ]; then
|
||||
for userdata_file in /var/cpanel/userdata/*/*; do
|
||||
[[ "$userdata_file" == *.cache ]] && continue
|
||||
[[ "$userdata_file" == */main ]] && continue
|
||||
[[ "$userdata_file" == */cache ]] && continue
|
||||
[[ "$userdata_file" == */cache.json ]] && continue
|
||||
|
||||
if grep -q "^servername: $domain" "$userdata_file" 2>/dev/null; then
|
||||
user=$(basename "$(dirname "$userdata_file")")
|
||||
potential_config="/home/$user/public_html/wp-config.php"
|
||||
@@ -583,6 +647,7 @@ case "$choice" in
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -z "$wp_config" ]; then
|
||||
print_error "WordPress installation not found for $domain"
|
||||
|
||||
Reference in New Issue
Block a user