3435e7f0d1
FIXES (7 issues resolved): 1. CRITICAL: Fix infinite recursion in extract_user_from_path() - Changed from recursive calls to direct path parsing with awk - User extraction now works correctly for cpanel/interworx 2. CRITICAL: Fix sed commands failing with unescaped delimiters - Changed all sed delimiters from '/' to '#' for safe pattern matching - Fixes wp-config.php modification failures 3. HIGH: Fix cron time collision with 15+ sites - Increased CRON_OFFSET modulo from 15 to 60 - Simplified cron pattern to single minute per hour - Prevents multiple sites running simultaneously 4. HIGH: Fix CRON_OFFSET lost in piped loops - Converted echo pipes to here-strings (<<< syntax) - Each site now gets unique staggered cron time 5. HIGH: Fix unquoted paths in cron commands - Added quotes around $site_path variables - Paths with spaces and special characters now work 6. MEDIUM: Add safe crontab operation functions - Created safe_add_cron_job() with error checking - Created safe_remove_cron_jobs() with validation - Prevents accidental crontab deletion 7. MEDIUM: Improve error handling throughout - Added error checking before crontab operations - Better error messages when operations fail - Safer defaults (no silent failures) All changes maintain backward compatibility and improve reliability. Script is now production-ready. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>