feat: v2.5.0 - Complete Technology & Security Update
Features: - PHP 8.4 support (from 8.3) - WordPress 7.0 (auto-update via WP-CLI) - Modern TLS 1.3 cipher suites (2026 best practices) - Fail2Ban security integration (5 jails: SSH, Nginx, WordPress, recidive) - Auto-update cron job for WordPress (weekly Minor updates) - Debian 14 Forky support (testing) - Ubuntu 25.04 support - Python 3.12 in GitHub Actions Security: - Fail2Ban with SSH brute force protection (24h ban) - WordPress wp-login.php protection (2h ban) - Nginx bot scanner protection - Recidive jail for repeat offenders (1 week ban) - Modern TLS ciphers (AEAD only) - HSTS 2 years for preload Documentation: - docs/autoupdate.md - WordPress auto-update guide - docs/fail2ban.md - Fail2Ban configuration guide - docs/troubleshooting.md - Updated with php_version variable Breaking changes: - PHP 8.4 is now the default (requires Ubuntu 20.04+ or Debian 11+)
This commit is contained in:
116
scripts/wp-update.sh
Executable file
116
scripts/wp-update.sh
Executable file
@@ -0,0 +1,116 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# WordPress Auto-Update Script
|
||||
# Usage: ./wp-update.sh [--minor|--major|--force] [--backup]
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
WORDPRESS_PATH="${WORDPRESS_PATH:-/var/www/html}"
|
||||
BACKUP_PATH="${BACKUP_PATH:-/var/backups/wordpress}"
|
||||
LOG_FILE="${LOG_FILE:-/var/log/wp-update.log}"
|
||||
|
||||
MODE="minor"
|
||||
DO_BACKUP=true
|
||||
|
||||
log() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
error_exit() {
|
||||
log "ERROR: $1"
|
||||
wp maintenance-mode deactivate 2>/dev/null || true
|
||||
exit 1
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--minor)
|
||||
MODE="minor"
|
||||
shift
|
||||
;;
|
||||
--major)
|
||||
MODE="major"
|
||||
shift
|
||||
;;
|
||||
--force)
|
||||
MODE="force"
|
||||
shift
|
||||
;;
|
||||
--no-backup)
|
||||
DO_BACKUP=false
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [--minor|--major|--force] [--no-backup]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
log "========================================"
|
||||
log "WordPress Update Started (Mode: $MODE)"
|
||||
log "========================================"
|
||||
|
||||
cd "$WORDPRESS_PATH"
|
||||
|
||||
if [ ! -f "wp-config.php" ]; then
|
||||
error_exit "WordPress not found at $WORDPRESS_PATH"
|
||||
fi
|
||||
|
||||
if $DO_BACKUP; then
|
||||
log "Creating database backup..."
|
||||
|
||||
BACKUP_DIR="$BACKUP_PATH/$(date +%Y%m%d-%H%M%S)"
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
if wp db export "$BACKUP_DIR/wp-db.sql"; then
|
||||
log "Database backup saved to $BACKUP_DIR/wp-db.sql"
|
||||
else
|
||||
error_exit "Database backup failed"
|
||||
fi
|
||||
|
||||
log "Creating file backup..."
|
||||
tar -czf "$BACKUP_DIR/wp-files.tar.gz" -C "$(dirname "$WORDPRESS_PATH")" "$(basename "$WORDPRESS_PATH")" 2>/dev/null || true
|
||||
log "File backup saved to $BACKUP_DIR/wp-files.tar.gz"
|
||||
fi
|
||||
|
||||
log "Activating maintenance mode..."
|
||||
wp maintenance-mode activate || error_exit "Failed to activate maintenance mode"
|
||||
|
||||
log "Checking for WordPress updates..."
|
||||
if [ "$MODE" = "major" ]; then
|
||||
wp core update || log "No major update available or update failed"
|
||||
elif [ "$MODE" = "force" ]; then
|
||||
wp core update --force || log "Update failed"
|
||||
else
|
||||
wp core update --minor || log "No minor update available"
|
||||
fi
|
||||
|
||||
log "Running database updates..."
|
||||
wp core update-db || log "No database update needed"
|
||||
|
||||
log "Updating plugins..."
|
||||
wp plugin update --all || log "Plugin update completed with warnings"
|
||||
|
||||
log "Updating themes..."
|
||||
wp theme update --all || log "Theme update completed with warnings"
|
||||
|
||||
log "Verifying WordPress installation..."
|
||||
wp core verify-checksums || log "Checksum verification completed with warnings"
|
||||
|
||||
log "Deactivating maintenance mode..."
|
||||
wp maintenance-mode deactivate || true
|
||||
|
||||
log "========================================"
|
||||
log "WordPress Update Completed Successfully"
|
||||
log "========================================"
|
||||
|
||||
wp plugin list --status=active --format=table 2>/dev/null | tee -a "$LOG_FILE"
|
||||
|
||||
echo ""
|
||||
log "Updated WordPress version:"
|
||||
wp core version
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user