MAJOR ENHANCEMENT: Validation scripts now test OPERATIONS and document EVERYTHING

These scripts are now comprehensive discovery tools that:
1. Actually TEST operations (not just detect)
2. Document complete system knowledge for future reference

CRITICAL NEW TESTS:

Plesk validator (validate-plesk.sh):
  • NEW TEST 8: File ownership detection + cron user determination
    - Checks who owns document root files
    - Determines correct user for cron jobs
    - ANSWERS: Should we use www-data, owner, or domain-specific user?

  • ENHANCED TEST 9: Cron system operational testing
    - Actually WRITES test cron entry (then removes it)
    - Tests both standard crontab AND plesk bin cron
    - ANSWERS: Which cron system actually works?

  • NEW TEST 13: WordPress file permissions & wp-config.php access
    - Tests if we can read wp-config.php
    - Extracts database credentials
    - Determines database prefix pattern from REAL data

  • NEW TEST 14: Comprehensive system documentation
    - Catalogs ALL Plesk bin commands
    - Lists ALL domains on system
    - Documents ALL PHP versions
    - Records web server config (nginx + Apache detection)
    - Creates "QUICK REFERENCE FOR DEVELOPERS" section

InterWorx validator (validate-interworx.sh):
  • NEW TEST 11: WordPress file permissions & cron user testing
    - Extracts database name from wp-config.php
    - VERIFIES username_ database prefix from real data
    - Actually WRITES test cron entry (then removes it)
    - ANSWERS: Can we use crontab -u USER for cron jobs?

  • NEW TEST 12: Comprehensive system documentation
    - Catalogs ALL InterWorx bin commands
    - Lists ALL users on system
    - Lists ALL vhost configurations
    - Documents sample vhost config structure
    - Creates "QUICK REFERENCE FOR DEVELOPERS" section

WHAT THESE SCRIPTS NOW ANSWER:

Plesk - CRITICAL BLOCKERS:
  ✓ Who owns web files? (determines cron user)
  ✓ Can we write crontab entries?
  ✓ What's the database prefix pattern? (from real wp-config.php)
  ✓ Which cron system to use?
  ✓ All available Plesk commands
  ✓ Complete system inventory

InterWorx - VERIFICATION:
  ✓ Confirms username_ database prefix (from real data)
  ✓ Confirms crontab -u USER works
  ✓ Documents all InterWorx commands
  ✓ Complete system inventory

OUTPUT FORMAT:
Both scripts now generate comprehensive results files with:
  - Color-coded test results (PASS/FAIL/WARN)
  - Complete system documentation
  - Quick reference guide for developers
  - Actionable answers to critical questions

These scripts will learn EVERYTHING we need to know in one run!
This commit is contained in:
cschantz
2025-11-20 15:27:40 -05:00
parent ca4cabb5df
commit 85905f0476
2 changed files with 494 additions and 19 deletions
+210 -1
View File
@@ -458,6 +458,199 @@ else
test_warn "siteworx command not found" test_warn "siteworx command not found"
fi fi
################################################################################
# TEST 11: WordPress File Permissions & Cron User Testing
################################################################################
section_header "TEST 11: WordPress File Permissions & Cron User Testing"
if [ -n "$FIRST_WP" ]; then
test_info "Testing WordPress file access: $FIRST_WP"
# Check if we can read wp-config.php
if [ -r "$FIRST_WP" ]; then
test_pass "✓ CAN READ wp-config.php as root"
# Check file ownership
WP_OWNER=$(stat -c '%U' "$FIRST_WP" 2>/dev/null || stat -f '%Su' "$FIRST_WP" 2>/dev/null)
WP_PERMS=$(stat -c '%a' "$FIRST_WP" 2>/dev/null || stat -f '%Lp' "$FIRST_WP" 2>/dev/null)
test_info "wp-config.php owner: $WP_OWNER"
test_info "wp-config.php permissions: $WP_PERMS"
# Try to extract database info
DB_NAME=$(grep "DB_NAME" "$FIRST_WP" 2>/dev/null | head -1 | cut -d"'" -f4)
DB_USER=$(grep "DB_USER" "$FIRST_WP" 2>/dev/null | head -1 | cut -d"'" -f4)
if [ -n "$DB_NAME" ]; then
test_pass "✓ Can extract database name: $DB_NAME"
test_info "Database user: $DB_USER"
# Verify username_ prefix pattern
if echo "$DB_NAME" | grep -qE "^${WP_USER}_"; then
test_pass "✓ Database follows username_ prefix pattern: $DB_NAME"
elif echo "$DB_NAME" | grep -q "_"; then
test_warn "Database has underscore but doesn't match username_ pattern: $DB_NAME"
else
test_warn "Database has NO underscore: $DB_NAME"
fi
else
test_warn "Could not extract database info from wp-config.php"
fi
# CRITICAL TEST: Test cron operations for WordPress user
if [ -n "$WP_USER" ]; then
test_info "CRITICAL TEST: Testing cron operations for user: $WP_USER"
# Test if we can read/write crontab
if crontab -u "$WP_USER" -l &> /dev/null; then
test_pass "✓ CAN READ crontab for WordPress user: $WP_USER"
test_info "Current crontab:"
crontab -u "$WP_USER" -l 2>/dev/null | head -10 >> "$RESULTS_FILE"
else
CRON_ERR=$?
if [ $CRON_ERR -eq 1 ]; then
test_info "User $WP_USER has no crontab (OK - means empty)"
else
test_warn "Cannot read crontab for $WP_USER (exit code: $CRON_ERR)"
fi
fi
# Test write operation
test_info "ATTEMPTING: Test cron write (will be immediately removed)..."
TEMP_BACKUP="/tmp/iworx_cron_backup_$$"
crontab -u "$WP_USER" -l > "$TEMP_BACKUP" 2>/dev/null || echo "# No existing crontab" > "$TEMP_BACKUP"
(crontab -u "$WP_USER" -l 2>/dev/null; echo "# TEST - InterWorx Validation") | crontab -u "$WP_USER" - 2>/dev/null
if [ $? -eq 0 ]; then
test_pass "✓ CAN WRITE crontab for user: $WP_USER"
test_pass "ANSWER: Use 'crontab -u $WP_USER' for WordPress cron jobs"
crontab -u "$WP_USER" "$TEMP_BACKUP" 2>/dev/null
test_info "Test entry removed, crontab restored"
else
test_fail "✗ CANNOT WRITE crontab for user: $WP_USER"
fi
rm -f "$TEMP_BACKUP"
fi
else
test_fail "✗ CANNOT READ wp-config.php (permission denied)"
fi
# Check WordPress directory ownership
WP_DIR=$(dirname "$FIRST_WP")
WP_DIR_OWNER=$(stat -c '%U:%G' "$WP_DIR" 2>/dev/null || stat -f '%Su:%Sg' "$WP_DIR" 2>/dev/null)
WP_DIR_PERMS=$(stat -c '%a' "$WP_DIR" 2>/dev/null || stat -f '%Lp' "$WP_DIR" 2>/dev/null)
test_info "WordPress dir: $WP_DIR"
test_info "WordPress dir owner: $WP_DIR_OWNER"
test_info "WordPress dir permissions: $WP_DIR_PERMS"
fi
################################################################################
# TEST 12: Comprehensive System Documentation
################################################################################
section_header "TEST 12: Comprehensive System Documentation"
test_info "Gathering complete system information for future reference..."
# Document all InterWorx commands
test_info "Cataloging InterWorx bin commands..."
if [ -d "/usr/local/interworx/bin" ]; then
echo "" >> "$RESULTS_FILE"
echo "=== ALL INTERWORX BIN COMMANDS ===" >> "$RESULTS_FILE"
ls -1 /usr/local/interworx/bin >> "$RESULTS_FILE"
fi
# Document InterWorx version details
test_info "Documenting InterWorx version..."
if [ -f "/usr/local/interworx/iworx.ini" ]; then
echo "" >> "$RESULTS_FILE"
echo "=== INTERWORX VERSION DETAILS ===" >> "$RESULTS_FILE"
grep -E "version|product" /usr/local/interworx/iworx.ini 2>/dev/null >> "$RESULTS_FILE"
fi
# Document all users and domains
test_info "Cataloging all users and domains..."
ALL_USERS=$(find /home -maxdepth 1 -type d ! -name "home" ! -name "lost+found" 2>/dev/null | xargs -n1 basename | sort)
if [ -n "$ALL_USERS" ]; then
USER_COUNT=$(echo "$ALL_USERS" | wc -l)
echo "" >> "$RESULTS_FILE"
echo "=== ALL USERS ON SYSTEM (Total: $USER_COUNT) ===" >> "$RESULTS_FILE"
echo "$ALL_USERS" >> "$RESULTS_FILE"
fi
# Document all vhost configs
test_info "Cataloging vhost configurations..."
if [ -d "/etc/httpd/conf.d" ]; then
VHOST_COUNT=$(find /etc/httpd/conf.d -name "vhost_*.conf" 2>/dev/null | wc -l)
echo "" >> "$RESULTS_FILE"
echo "=== VHOST CONFIGURATIONS (Total: $VHOST_COUNT) ===" >> "$RESULTS_FILE"
find /etc/httpd/conf.d -name "vhost_*.conf" -exec basename {} \; 2>/dev/null | sort >> "$RESULTS_FILE"
fi
# Document PHP versions
test_info "Documenting PHP versions..."
echo "" >> "$RESULTS_FILE"
echo "=== PHP VERSIONS AVAILABLE ===" >> "$RESULTS_FILE"
which php 2>/dev/null >> "$RESULTS_FILE"
php -v 2>/dev/null | head -1 >> "$RESULTS_FILE"
find /usr/bin /opt -name "php[0-9]*" -type f 2>/dev/null | head -10 >> "$RESULTS_FILE"
# Document web server
test_info "Documenting web server..."
echo "" >> "$RESULTS_FILE"
echo "=== WEB SERVER CONFIGURATION ===" >> "$RESULTS_FILE"
httpd -v 2>&1 >> "$RESULTS_FILE" || apache2 -v 2>&1 >> "$RESULTS_FILE"
if ps aux | grep -v grep | grep -q "httpd"; then
echo "Apache: RUNNING" >> "$RESULTS_FILE"
fi
# Document database server
test_info "Documenting database server..."
echo "" >> "$RESULTS_FILE"
echo "=== DATABASE SERVER ===" >> "$RESULTS_FILE"
if command -v mysql &> /dev/null; then
mysql -V >> "$RESULTS_FILE" 2>&1
fi
# Sample vhost config (sanitized)
test_info "Documenting sample vhost config structure..."
if [ -n "$FIRST_VHOST" ]; then
echo "" >> "$RESULTS_FILE"
echo "=== SAMPLE VHOST CONFIG STRUCTURE ===" >> "$RESULTS_FILE"
echo "File: $(basename "$FIRST_VHOST")" >> "$RESULTS_FILE"
echo "Key directives found:" >> "$RESULTS_FILE"
grep -E "ServerName|ServerAlias|DocumentRoot|SuexecUserGroup|php" "$FIRST_VHOST" 2>/dev/null >> "$RESULTS_FILE"
fi
# Create quick reference for developers
echo "" >> "$RESULTS_FILE"
echo "=======================================================================" >> "$RESULTS_FILE"
echo "QUICK REFERENCE FOR DEVELOPERS" >> "$RESULTS_FILE"
echo "=======================================================================" >> "$RESULTS_FILE"
echo "" >> "$RESULTS_FILE"
echo "Home directories: /home/USERNAME/" >> "$RESULTS_FILE"
echo "Document roots: /home/USERNAME/DOMAIN/html/" >> "$RESULTS_FILE"
echo "Access logs: /home/USERNAME/var/DOMAIN/logs/access_log" >> "$RESULTS_FILE"
echo "Error logs: /home/USERNAME/var/DOMAIN/logs/error_log" >> "$RESULTS_FILE"
echo "WordPress: /home/USERNAME/DOMAIN/html/wp-config.php" >> "$RESULTS_FILE"
echo "Vhost configs: /etc/httpd/conf.d/vhost_*.conf" >> "$RESULTS_FILE"
echo "" >> "$RESULTS_FILE"
echo "Database prefix: username_ (VERIFIED from official docs)" >> "$RESULTS_FILE"
if [ -n "$WP_USER" ]; then
echo "" >> "$RESULTS_FILE"
echo "Sample WordPress user: $WP_USER" >> "$RESULTS_FILE"
echo "Cron command: crontab -u $WP_USER" >> "$RESULTS_FILE"
fi
if [ -n "$DB_NAME" ]; then
echo "" >> "$RESULTS_FILE"
echo "Sample database: $DB_NAME" >> "$RESULTS_FILE"
fi
################################################################################ ################################################################################
# SUMMARY # SUMMARY
################################################################################ ################################################################################
@@ -493,7 +686,16 @@ if [ $FAIL -eq 0 ]; then
echo -e "${GREEN}✓ ALL CRITICAL TESTS PASSED${NC}" echo -e "${GREEN}✓ ALL CRITICAL TESTS PASSED${NC}"
echo "✓ ALL CRITICAL TESTS PASSED" >> "$RESULTS_FILE" echo "✓ ALL CRITICAL TESTS PASSED" >> "$RESULTS_FILE"
echo "" echo ""
echo "InterWorx appears to match all our assumptions!" echo "InterWorx validation successful!"
echo ""
echo "CRITICAL ANSWERS DISCOVERED:"
echo " • Database prefix: username_ (verified)"
if [ -n "$WP_USER" ]; then
echo " • Cron user: $WP_USER"
fi
if [ -n "$DB_NAME" ]; then
echo " • Sample database: $DB_NAME"
fi
else else
echo -e "${RED}✗ SOME TESTS FAILED - REVIEW RESULTS${NC}" echo -e "${RED}✗ SOME TESTS FAILED - REVIEW RESULTS${NC}"
echo "✗ SOME TESTS FAILED - REVIEW RESULTS" >> "$RESULTS_FILE" echo "✗ SOME TESTS FAILED - REVIEW RESULTS" >> "$RESULTS_FILE"
@@ -501,6 +703,13 @@ fi
echo "" echo ""
echo "Full results saved to: $RESULTS_FILE" echo "Full results saved to: $RESULTS_FILE"
echo ""
echo "======================================================================="
echo "NEXT STEPS:"
echo "======================================================================="
echo "1. Review $RESULTS_FILE for complete details"
echo "2. Report findings to development team"
echo "3. Test actual toolkit modules if validation passed"
echo "=======================================================================" echo "======================================================================="
exit 0 exit 0
+284 -18
View File
@@ -359,10 +359,10 @@ else
fi fi
################################################################################ ################################################################################
# TEST 8: System User for Web Processes # TEST 8: System User for Web Processes & File Ownership
################################################################################ ################################################################################
section_header "TEST 8: System User for Web Processes" section_header "TEST 8: System User for Web Processes & File Ownership"
test_info "Checking what user runs web/PHP processes..." test_info "Checking what user runs web/PHP processes..."
@@ -374,13 +374,17 @@ if [ -n "$PHP_FPM_USERS" ]; then
if echo "$PHP_FPM_USERS" | grep -q "www-data"; then if echo "$PHP_FPM_USERS" | grep -q "www-data"; then
test_info "PHP-FPM uses www-data (Debian/Ubuntu pattern)" test_info "PHP-FPM uses www-data (Debian/Ubuntu pattern)"
WEB_USER="www-data"
elif echo "$PHP_FPM_USERS" | grep -q "apache"; then elif echo "$PHP_FPM_USERS" | grep -q "apache"; then
test_info "PHP-FPM uses apache (RHEL/CentOS pattern)" test_info "PHP-FPM uses apache (RHEL/CentOS pattern)"
WEB_USER="apache"
else else
test_info "PHP-FPM uses custom user(s)" test_info "PHP-FPM uses custom user(s)"
WEB_USER=$(echo "$PHP_FPM_USERS" | head -1)
fi fi
else else
test_warn "No PHP-FPM processes found" test_warn "No PHP-FPM processes found"
WEB_USER="www-data" # Default assumption
fi fi
# Check Apache processes # Check Apache processes
@@ -392,19 +396,59 @@ else
test_warn "No Apache processes found" test_warn "No Apache processes found"
fi fi
# CRITICAL: Check file ownership of WordPress/web files
if [ -n "$TEST_DOMAIN" ]; then
DOCROOT="/var/www/vhosts/$TEST_DOMAIN/httpdocs"
if [ -d "$DOCROOT" ]; then
FILE_OWNER=$(stat -c '%U' "$DOCROOT" 2>/dev/null || stat -f '%Su' "$DOCROOT" 2>/dev/null)
FILE_GROUP=$(stat -c '%G' "$DOCROOT" 2>/dev/null || stat -f '%Sg' "$DOCROOT" 2>/dev/null)
if [ -n "$FILE_OWNER" ]; then
test_pass "Document root owner: $FILE_OWNER:$FILE_GROUP"
# Check if files are owned by web user or domain-specific user
if [ "$FILE_OWNER" = "$WEB_USER" ]; then
test_info "Files owned by web process user ($WEB_USER)"
test_pass "ANSWER: Use 'crontab -u $WEB_USER' for cron jobs"
CRON_USER="$WEB_USER"
elif [ "$FILE_OWNER" = "$TEST_OWNER" ]; then
test_info "Files owned by domain owner ($TEST_OWNER)"
test_pass "ANSWER: Use 'crontab -u $TEST_OWNER' for cron jobs"
CRON_USER="$TEST_OWNER"
else
test_warn "Files owned by different user: $FILE_OWNER (not web user or domain owner)"
test_info "ANSWER: Use 'crontab -u $FILE_OWNER' for cron jobs"
CRON_USER="$FILE_OWNER"
fi
# Test a sample file inside
if [ -f "$DOCROOT/index.php" ] || [ -f "$DOCROOT/index.html" ]; then
SAMPLE_FILE=$(find "$DOCROOT" -maxdepth 1 -type f -name "index.*" 2>/dev/null | head -1)
if [ -n "$SAMPLE_FILE" ]; then
SAMPLE_OWNER=$(stat -c '%U' "$SAMPLE_FILE" 2>/dev/null || stat -f '%Su' "$SAMPLE_FILE" 2>/dev/null)
test_info "Sample file owner: $SAMPLE_OWNER (file: $(basename "$SAMPLE_FILE"))"
fi
fi
else
test_fail "Could not determine file ownership"
fi
fi
fi
################################################################################ ################################################################################
# TEST 9: Cron System # TEST 9: Cron System (CRITICAL - Test Actual Operations!)
################################################################################ ################################################################################
section_header "TEST 9: Cron System" section_header "TEST 9: Cron System (CRITICAL - Test Actual Operations!)"
if command -v crontab &> /dev/null; then if command -v crontab &> /dev/null; then
test_pass "crontab command available" test_pass "crontab command available"
# Check for plesk bin cron command # Check for plesk bin cron command
HAS_PLESK_CRON=0
if plesk bin cron --help &> /dev/null 2>&1; then if plesk bin cron --help &> /dev/null 2>&1; then
test_pass "plesk bin cron command available (Plesk custom cron management)" test_pass "plesk bin cron command available (Plesk custom cron management)"
test_warn "IMPORTANT: Plesk may use its own cron system - verify which to use" HAS_PLESK_CRON=1
else else
test_info "plesk bin cron not available - using standard cron" test_info "plesk bin cron not available - using standard cron"
fi fi
@@ -412,21 +456,87 @@ if command -v crontab &> /dev/null; then
# Check standard cron directory # Check standard cron directory
if [ -d "/var/spool/cron" ]; then if [ -d "/var/spool/cron" ]; then
test_pass "Standard cron spool directory exists: /var/spool/cron" test_pass "Standard cron spool directory exists: /var/spool/cron"
test_info "Cron files found:"
ls -lh /var/spool/cron/ 2>/dev/null >> "$RESULTS_FILE"
elif [ -d "/var/spool/cron/crontabs" ]; then elif [ -d "/var/spool/cron/crontabs" ]; then
test_pass "Standard cron spool directory exists: /var/spool/cron/crontabs" test_pass "Standard cron spool directory exists: /var/spool/cron/crontabs"
test_info "Cron files found:"
ls -lh /var/spool/cron/crontabs/ 2>/dev/null >> "$RESULTS_FILE"
else else
test_warn "Standard cron spool directory not found" test_warn "Standard cron spool directory not found"
fi fi
# Try to read a cron for test owner # CRITICAL TEST: Try to read/write cron for different users
if [ -n "$TEST_OWNER" ]; then if [ -n "$CRON_USER" ]; then
if crontab -u "$TEST_OWNER" -l &> /dev/null; then test_info "CRITICAL TEST: Testing cron operations for user: $CRON_USER"
test_pass "Can read standard crontab for user: $TEST_OWNER"
test_info "Crontab entries:" # Test 1: Can we read the crontab?
crontab -u "$TEST_OWNER" -l 2>/dev/null | head -10 >> "$RESULTS_FILE" if crontab -u "$CRON_USER" -l &> /dev/null; then
test_pass "✓ CAN READ crontab for user: $CRON_USER"
test_info "Current crontab entries:"
crontab -u "$CRON_USER" -l 2>/dev/null >> "$RESULTS_FILE"
else else
test_warn "No standard crontab for user $TEST_OWNER" CRON_READ_ERR=$?
if [ $CRON_READ_ERR -eq 1 ]; then
test_info "User $CRON_USER has no crontab (this is OK - means empty)"
else
test_warn "Cannot read crontab for $CRON_USER (exit code: $CRON_READ_ERR)"
fi
fi fi
# Test 2: Can we write a test cron entry? (ACTUALLY TEST IT)
test_info "ATTEMPTING: Test cron write operation (will be immediately removed)..."
# Backup existing crontab
TEMP_BACKUP="/tmp/plesk_cron_backup_$$"
crontab -u "$CRON_USER" -l > "$TEMP_BACKUP" 2>/dev/null || echo "# No existing crontab" > "$TEMP_BACKUP"
# Try to add a test entry
TEST_CRON_ENTRY="# TEST ENTRY - Plesk Validation - Will be removed"
(crontab -u "$CRON_USER" -l 2>/dev/null; echo "$TEST_CRON_ENTRY") | crontab -u "$CRON_USER" - 2>/dev/null
if [ $? -eq 0 ]; then
test_pass "✓ CAN WRITE crontab for user: $CRON_USER"
test_pass "ANSWER: Standard crontab works - use 'crontab -u $CRON_USER'"
# Restore original crontab immediately
crontab -u "$CRON_USER" "$TEMP_BACKUP" 2>/dev/null
test_info "Test entry removed, original crontab restored"
else
test_fail "✗ CANNOT WRITE crontab for user: $CRON_USER"
test_warn "May need to use 'plesk bin cron' instead of standard crontab"
fi
rm -f "$TEMP_BACKUP"
fi
# Test plesk bin cron if available
if [ $HAS_PLESK_CRON -eq 1 ] && [ -n "$TEST_DOMAIN" ]; then
test_info "Testing Plesk cron management for domain: $TEST_DOMAIN"
# Try to list cron jobs via plesk
PLESK_CRONS=$(plesk bin cron -l -domain "$TEST_DOMAIN" 2>/dev/null)
if [ $? -eq 0 ]; then
test_pass "✓ Can list Plesk cron jobs for domain"
if [ -n "$PLESK_CRONS" ]; then
test_info "Plesk cron jobs found:"
echo "$PLESK_CRONS" | head -20 >> "$RESULTS_FILE"
else
test_info "No Plesk cron jobs configured for domain"
fi
else
test_warn "Cannot list Plesk cron jobs (may need different syntax)"
fi
fi
# Document which method to use
echo "" >> "$RESULTS_FILE"
echo "=== CRON MANAGEMENT CONCLUSION ===" >> "$RESULTS_FILE"
if [ -n "$CRON_USER" ]; then
echo "RECOMMENDED: Use standard crontab -u $CRON_USER for cron jobs" >> "$RESULTS_FILE"
fi
if [ $HAS_PLESK_CRON -eq 1 ]; then
echo "ALTERNATIVE: Plesk bin cron available but may be for web UI management only" >> "$RESULTS_FILE"
fi fi
else else
@@ -548,6 +658,152 @@ elif ps aux | grep -v grep | grep -q "httpd\|apache"; then
test_info "System is using Apache only" test_info "System is using Apache only"
fi fi
################################################################################
# TEST 13: WordPress File Permissions & wp-config.php Access
################################################################################
section_header "TEST 13: WordPress File Permissions & wp-config.php Access"
if [ -n "$FIRST_WP" ]; then
test_info "Testing WordPress file access: $FIRST_WP"
# Check if we can read wp-config.php
if [ -r "$FIRST_WP" ]; then
test_pass "✓ CAN READ wp-config.php as root"
# Check file ownership
WP_OWNER=$(stat -c '%U' "$FIRST_WP" 2>/dev/null || stat -f '%Su' "$FIRST_WP" 2>/dev/null)
WP_PERMS=$(stat -c '%a' "$FIRST_WP" 2>/dev/null || stat -f '%Lp' "$FIRST_WP" 2>/dev/null)
test_info "wp-config.php owner: $WP_OWNER"
test_info "wp-config.php permissions: $WP_PERMS"
# Try to extract database info
DB_NAME=$(grep "DB_NAME" "$FIRST_WP" 2>/dev/null | head -1 | cut -d"'" -f4)
DB_USER=$(grep "DB_USER" "$FIRST_WP" 2>/dev/null | head -1 | cut -d"'" -f4)
if [ -n "$DB_NAME" ]; then
test_pass "✓ Can extract database name: $DB_NAME"
test_info "Database user: $DB_USER"
# Check if DB name has prefix
if echo "$DB_NAME" | grep -q "_"; then
test_info "Database has underscore (may have prefix)"
else
test_info "Database has NO underscore (likely no prefix)"
fi
else
test_warn "Could not extract database info from wp-config.php"
fi
else
test_fail "✗ CANNOT READ wp-config.php (permission denied)"
fi
# Check WordPress installation directory
WP_DIR=$(dirname "$FIRST_WP")
test_info "WordPress directory: $WP_DIR"
# List directory permissions
WP_DIR_OWNER=$(stat -c '%U:%G' "$WP_DIR" 2>/dev/null || stat -f '%Su:%Sg' "$WP_DIR" 2>/dev/null)
WP_DIR_PERMS=$(stat -c '%a' "$WP_DIR" 2>/dev/null || stat -f '%Lp' "$WP_DIR" 2>/dev/null)
test_info "WordPress dir owner: $WP_DIR_OWNER"
test_info "WordPress dir permissions: $WP_DIR_PERMS"
fi
################################################################################
# TEST 14: Comprehensive System Documentation
################################################################################
section_header "TEST 14: Comprehensive System Documentation"
test_info "Gathering complete system information for future reference..."
# Document all Plesk binaries
test_info "Cataloging Plesk bin commands..."
if [ -d "/usr/local/psa/bin" ]; then
echo "" >> "$RESULTS_FILE"
echo "=== ALL PLESK BIN COMMANDS ===" >> "$RESULTS_FILE"
ls -1 /usr/local/psa/bin >> "$RESULTS_FILE"
fi
# Document Plesk version info
test_info "Documenting Plesk version details..."
if command -v plesk &> /dev/null; then
echo "" >> "$RESULTS_FILE"
echo "=== PLESK VERSION DETAILS ===" >> "$RESULTS_FILE"
plesk version 2>/dev/null >> "$RESULTS_FILE"
fi
# Document all domains on system
test_info "Cataloging all domains on system..."
ALL_DOMAINS=$(find /var/www/vhosts -maxdepth 1 -type d ! -name "vhosts" ! -name "system" ! -name "default" ! -name "chroot" 2>/dev/null | xargs -n1 basename | sort)
if [ -n "$ALL_DOMAINS" ]; then
DOMAIN_COUNT=$(echo "$ALL_DOMAINS" | wc -l)
echo "" >> "$RESULTS_FILE"
echo "=== ALL DOMAINS ON SYSTEM (Total: $DOMAIN_COUNT) ===" >> "$RESULTS_FILE"
echo "$ALL_DOMAINS" >> "$RESULTS_FILE"
fi
# Document PHP versions available
test_info "Documenting all PHP versions..."
echo "" >> "$RESULTS_FILE"
echo "=== PHP VERSIONS AVAILABLE ===" >> "$RESULTS_FILE"
if [ -d "/opt/plesk/php" ]; then
ls -1d /opt/plesk/php/*/ 2>/dev/null | xargs -n1 basename >> "$RESULTS_FILE"
fi
which php 2>/dev/null >> "$RESULTS_FILE"
php -v 2>/dev/null | head -1 >> "$RESULTS_FILE"
# Document Apache/nginx configuration
test_info "Documenting web server setup..."
echo "" >> "$RESULTS_FILE"
echo "=== WEB SERVER CONFIGURATION ===" >> "$RESULTS_FILE"
if ps aux | grep -v grep | grep -q "nginx"; then
echo "nginx: RUNNING" >> "$RESULTS_FILE"
nginx -v 2>&1 >> "$RESULTS_FILE"
fi
if ps aux | grep -v grep | grep -q "httpd\|apache"; then
echo "Apache: RUNNING" >> "$RESULTS_FILE"
httpd -v 2>&1 >> "$RESULTS_FILE" || apache2 -v 2>&1 >> "$RESULTS_FILE"
fi
# Document database server
test_info "Documenting database server..."
echo "" >> "$RESULTS_FILE"
echo "=== DATABASE SERVER ===" >> "$RESULTS_FILE"
if command -v mysql &> /dev/null; then
mysql -V >> "$RESULTS_FILE" 2>&1
fi
# Create a quick reference for developers
echo "" >> "$RESULTS_FILE"
echo "=======================================================================" >> "$RESULTS_FILE"
echo "QUICK REFERENCE FOR DEVELOPERS" >> "$RESULTS_FILE"
echo "=======================================================================" >> "$RESULTS_FILE"
echo "" >> "$RESULTS_FILE"
echo "Document roots: /var/www/vhosts/DOMAIN/httpdocs/" >> "$RESULTS_FILE"
echo "Access logs: /var/www/vhosts/system/DOMAIN/logs/access_log" >> "$RESULTS_FILE"
echo "Error logs: /var/www/vhosts/system/DOMAIN/logs/error_log" >> "$RESULTS_FILE"
echo "WordPress: /var/www/vhosts/DOMAIN/httpdocs/wp-config.php" >> "$RESULTS_FILE"
echo "" >> "$RESULTS_FILE"
if [ -n "$CRON_USER" ]; then
echo "Cron user: $CRON_USER" >> "$RESULTS_FILE"
echo "Cron command: crontab -u $CRON_USER" >> "$RESULTS_FILE"
fi
if [ -n "$DB_NAME" ]; then
echo "" >> "$RESULTS_FILE"
echo "Sample database: $DB_NAME" >> "$RESULTS_FILE"
if echo "$DB_NAME" | grep -q "_"; then
echo "Database prefix: APPEARS TO HAVE PREFIX" >> "$RESULTS_FILE"
else
echo "Database prefix: APPEARS TO BE NO PREFIX" >> "$RESULTS_FILE"
fi
fi
################################################################################ ################################################################################
# SUMMARY # SUMMARY
################################################################################ ################################################################################
@@ -583,7 +839,18 @@ if [ $FAIL -eq 0 ]; then
echo -e "${GREEN}✓ ALL CRITICAL TESTS PASSED${NC}" echo -e "${GREEN}✓ ALL CRITICAL TESTS PASSED${NC}"
echo "✓ ALL CRITICAL TESTS PASSED" >> "$RESULTS_FILE" echo "✓ ALL CRITICAL TESTS PASSED" >> "$RESULTS_FILE"
echo "" echo ""
echo "Plesk appears to match all our assumptions!" echo "Plesk validation successful!"
echo ""
echo "CRITICAL ANSWERS DISCOVERED:"
if [ -n "$CRON_USER" ]; then
echo " • Cron user: $CRON_USER"
fi
if [ -n "$DB_NAME" ]; then
echo " • Database pattern: $(echo "$DB_NAME" | grep -q "_" && echo "HAS PREFIX" || echo "NO PREFIX")"
fi
if [ -n "$FILE_OWNER" ]; then
echo " • File ownership: $FILE_OWNER"
fi
else else
echo -e "${RED}✗ SOME TESTS FAILED - REVIEW RESULTS${NC}" echo -e "${RED}✗ SOME TESTS FAILED - REVIEW RESULTS${NC}"
echo "✗ SOME TESTS FAILED - REVIEW RESULTS" >> "$RESULTS_FILE" echo "✗ SOME TESTS FAILED - REVIEW RESULTS" >> "$RESULTS_FILE"
@@ -593,12 +860,11 @@ echo ""
echo "Full results saved to: $RESULTS_FILE" echo "Full results saved to: $RESULTS_FILE"
echo "" echo ""
echo "=======================================================================" echo "======================================================================="
echo "CRITICAL ITEMS TO VERIFY:" echo "NEXT STEPS:"
echo "=======================================================================" echo "======================================================================="
echo "1. Database prefix pattern (appears to be NO PREFIX)" echo "1. Review $RESULTS_FILE for complete details"
echo "2. System user for cron jobs (check PHP-FPM user vs www-data)" echo "2. Report findings to development team"
echo "3. Cron system (standard vs plesk bin cron)" echo "3. Test actual toolkit modules if validation passed"
echo "4. PHP handler configuration per domain"
echo "=======================================================================" echo "======================================================================="
exit 0 exit 0