From 85f39364a435c2834220b61ab9c06dd01c7ddc62 Mon Sep 17 00:00:00 2001
From: Peca
Date: Sat, 7 Jun 2025 20:47:57 +0200
Subject: [PATCH 221/304] v-commander: stop setting a root password
---
bin/v-commander | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/bin/v-commander b/bin/v-commander
index 834fb38b..f04b3a17 100644
--- a/bin/v-commander
+++ b/bin/v-commander
@@ -101,7 +101,7 @@ myhelp() {
echo "m def = install php-memcached if needed"
echo "check fc = check if FreshClam is up"
echo "-----------------------------"
- echo "enable-ssh-root-password-login = Allow root password authentication via SSH and set the root password to match the password for the admin account"
+ echo "enable-ssh-root-password-login = Allow root password authentication via SSH"
echo "id_rsa = generate id_rsa and id_rsa.pub if it does not exist and show id_rsa.pub"
echo "-----------------------------"
}
@@ -535,18 +535,11 @@ do
echo "--- New settings ---"
grep '^PermitRoot' /etc/ssh/sshd_config
echo "--------------------"
- root_password=$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | head -c 32)
- hashed_root_password=$(openssl passwd -6 "$root_password")
- sed -i "s#^root:.*#root:$hashed_root_password#" /etc/shadow
- echo "Root password is now a new random password."
- echo "New root password: $root_password"
- echo "--------------------"
- grep '^root:' /etc/shadow
- grep '^admin:' /etc/shadow
- echo "--------------------"
echo "Port 22 opened in Firewall for all IP addresses."
/usr/local/vesta/bin/v-unsuspend-firewall-rule "11"
echo "--------------------"
+ echo "Type 'passwd' in the terminal to set the root password."
+ echo "--------------------"
fi
if [ "$answer" = 'r' ] || [ "$answer" = 'R' ]; then
From 6d752d93f589a0d357a130f4eab2b3de7956fa26 Mon Sep 17 00:00:00 2001
From: Peca
Date: Sun, 8 Jun 2025 07:53:20 +0200
Subject: [PATCH 222/304] Adding v-cd-www alias to root bash profile
---
install/vst-install-debian.sh | 6 +++++-
src/deb/vesta/postinst | 7 +++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/install/vst-install-debian.sh b/install/vst-install-debian.sh
index ef4bc374..18a25f10 100755
--- a/install/vst-install-debian.sh
+++ b/install/vst-install-debian.sh
@@ -2089,13 +2089,17 @@ if [ "$release" -gt 9 ]; then
fi
echo "ALLOW_BACKUP_ANYTIME='yes'" >> $VESTA/conf/vesta.conf
echo "NOTIFY_ADMIN_FULL_BACKUP='$email'" >> $VESTA/conf/vesta.conf
+echo "== Adding FileManager license to vesta.conf"
echo "FILEMANAGER_KEY='FREEFM'" >> $VESTA/conf/vesta.conf
echo "================================================================"
# Removing old PHP sessions files
cron=$(crontab -l | { cat; echo "10 2 * * 6 sudo find /home/*/tmp/ -type f -mtime +5 -exec rm {} \;"; } | crontab -)
-echo "alias v-cd-www='source /usr/local/vesta/bin/v-change-dir-www'" >> /root/.bash_profile
+if [ -f "/root/.bash_profile" ]; then
+ echo "== Adding v-cd-www alias to root bash profile"
+ echo "alias v-cd-www='source /usr/local/vesta/bin/v-change-dir-www'" >> /root/.bash_profile
+fi
#----------------------------------------------------------#
# myVesta Access Info #
diff --git a/src/deb/vesta/postinst b/src/deb/vesta/postinst
index 107bd6f6..68252789 100755
--- a/src/deb/vesta/postinst
+++ b/src/deb/vesta/postinst
@@ -30,6 +30,13 @@ if ! grep -q "FILEMANAGER_KEY='FREEFM'" /usr/local/vesta/conf/vesta.conf; then
echo "FILEMANAGER_KEY='FREEFM'" >> /usr/local/vesta/conf/vesta.conf
fi
+if [ -f "/root/.bash_profile" ]; then
+ if ! grep -q "v-cd-www" /root/.bash_profile; then
+ echo "== Adding v-cd-www alias to root bash profile"
+ echo "alias v-cd-www='source /usr/local/vesta/bin/v-change-dir-www'" >> /root/.bash_profile
+ fi
+fi
+
# Adding myVesta rules to SpamAssassin
if [ -d "/etc/spamassassin" ]; then
spamassassin_modified=0
From 413787070aec1eff85ad198c2a5aa0dad9dbaddb Mon Sep 17 00:00:00 2001
From: Peca
Date: Sun, 8 Jun 2025 08:08:27 +0200
Subject: [PATCH 223/304] Skip prompt to continue in vst-install-debian.sh if
all required variables are set
---
install/vst-install-debian.sh | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/install/vst-install-debian.sh b/install/vst-install-debian.sh
index 18a25f10..f6de9e70 100755
--- a/install/vst-install-debian.sh
+++ b/install/vst-install-debian.sh
@@ -491,10 +491,16 @@ echo -e "\n\n"
# Asking for confirmation to proceed
if [ "$interactive" = 'yes' ]; then
- read -p 'Would you like to continue [y/n]: ' answer
- if [ "$answer" != 'y' ] && [ "$answer" != 'Y' ]; then
- echo 'Goodbye'
- exit 1
+ prompt_to_continue=1;
+ if [ ! -z "$email" ] && [ ! -z "$secret_url" ] && [ ! -z "$port" ] && [ ! -z "$servername" ]; then
+ prompt_to_continue=0;
+ fi
+ if [ $prompt_to_continue -eq 1 ]; then
+ read -p 'Would you like to continue [y/n]: ' answer
+ if [ "$answer" != 'y' ] && [ "$answer" != 'Y' ]; then
+ echo 'Goodbye'
+ exit 1
+ fi
fi
# Asking for contact email
@@ -2081,7 +2087,6 @@ if [ "$port" != "8083" ]; then
$VESTA/bin/v-change-vesta-port $port
fi
-echo "=== Set URL for phpmyadmin"
echo "DB_PMA_URL='https://$servername/phpmyadmin/'" >> $VESTA/conf/vesta.conf
if [ "$release" -gt 9 ]; then
echo "=== Set max_length_of_MySQL_username=80"
@@ -2089,15 +2094,15 @@ if [ "$release" -gt 9 ]; then
fi
echo "ALLOW_BACKUP_ANYTIME='yes'" >> $VESTA/conf/vesta.conf
echo "NOTIFY_ADMIN_FULL_BACKUP='$email'" >> $VESTA/conf/vesta.conf
-echo "== Adding FileManager license to vesta.conf"
+echo "=== Adding FileManager license to vesta.conf"
echo "FILEMANAGER_KEY='FREEFM'" >> $VESTA/conf/vesta.conf
-echo "================================================================"
# Removing old PHP sessions files
-cron=$(crontab -l | { cat; echo "10 2 * * 6 sudo find /home/*/tmp/ -type f -mtime +5 -exec rm {} \;"; } | crontab -)
+touch /var/spool/cron/crontabs/root
+echo "10 2 * * 6 sudo find /home/*/tmp/ -type f -mtime +5 -exec rm {} \;" >> /var/spool/cron/crontabs/root
if [ -f "/root/.bash_profile" ]; then
- echo "== Adding v-cd-www alias to root bash profile"
+ echo "=== Adding v-cd-www alias to root bash profile"
echo "alias v-cd-www='source /usr/local/vesta/bin/v-change-dir-www'" >> /root/.bash_profile
fi
From c5d0619a6b2f8ff2fadfc92be5a6d7ed8dbb35b1 Mon Sep 17 00:00:00 2001
From: Peca
Date: Sun, 8 Jun 2025 14:46:58 +0200
Subject: [PATCH 224/304] Check for SSL certificate existence before deleting
web domain SSL in v-install-unsigned-ssl
---
bin/v-install-unsigned-ssl | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/bin/v-install-unsigned-ssl b/bin/v-install-unsigned-ssl
index 8df023c9..9ac2f188 100644
--- a/bin/v-install-unsigned-ssl
+++ b/bin/v-install-unsigned-ssl
@@ -52,7 +52,9 @@ fi
# Action #
#----------------------------------------------------------#
-/usr/local/vesta/bin/v-delete-web-domain-ssl "$user" "$domain"
+if [ -f "/home/$user/conf/web/ssl.$domain.crt" ]; then
+ /usr/local/vesta/bin/v-delete-web-domain-ssl "$user" "$domain"
+fi
release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
From 2fe4ce2ae4535ffb0bbd673294bed67b04b4c05c Mon Sep 17 00:00:00 2001
From: Peca
Date: Mon, 16 Jun 2025 15:49:34 +0200
Subject: [PATCH 225/304] v-change-db-password-to-wordpress
---
bin/v-change-db-password-to-all-wordpress | 43 ++++++++++
bin/v-change-db-password-to-wordpress | 100 ++++++++++++++++++++++
2 files changed, 143 insertions(+)
create mode 100644 bin/v-change-db-password-to-all-wordpress
create mode 100644 bin/v-change-db-password-to-wordpress
diff --git a/bin/v-change-db-password-to-all-wordpress b/bin/v-change-db-password-to-all-wordpress
new file mode 100644
index 00000000..b31edb80
--- /dev/null
+++ b/bin/v-change-db-password-to-all-wordpress
@@ -0,0 +1,43 @@
+#!/bin/bash
+# info: change db password to all wordpress databases
+# options:
+#
+# The command is used for changing db password to all wordpress databases on the server.
+
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+# Importing system variables
+source /etc/profile
+
+# Includes
+source $VESTA/func/main.sh
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
+ if [ ! -f "/usr/local/vesta/data/users/$user/user.conf" ]; then
+ continue;
+ fi
+
+ for domain in $(/usr/local/vesta/bin/v-list-web-domains $user plain |cut -f 1); do
+ if [ -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
+ /usr/local/vesta/bin/v-change-db-password-to-wordpress $domain
+ echo "--------------------------------"
+ fi
+ done
+
+done
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$ARGUMENTS"
+
+exit
diff --git a/bin/v-change-db-password-to-wordpress b/bin/v-change-db-password-to-wordpress
new file mode 100644
index 00000000..d7ce1782
--- /dev/null
+++ b/bin/v-change-db-password-to-wordpress
@@ -0,0 +1,100 @@
+#!/bin/bash
+# info: change db password to wordpress database
+# options:
+#
+# The command is used for changing db password to wordpress database.
+
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+whoami=$(whoami)
+if [ "$whoami" != "root" ]; then
+ echo "You must be root to execute this script"
+ exit 1
+fi
+
+# Importing system environment
+source /etc/profile
+
+# Argument definition
+domain=$1
+
+user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
+USER=$user
+
+if [ -z "$user" ]; then
+ echo "ERROR: Domain $domain not found"
+ exit 1;
+fi
+
+if [ ! -d "/home/$user" ]; then
+ echo "ERROR: User $user doesn't exist";
+ exit 1;
+fi
+
+# Includes
+source /usr/local/vesta/func/main.sh
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'DOMAIN'
+is_format_valid 'domain'
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+
+if [ ! -d "/home/$user/web/$domain/public_html" ]; then
+ echo "ERROR: Domain doesn't exist";
+ exit 1;
+fi
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+if [ -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
+ echo "=== Domain: $domain"
+ wp_config_path="/home/$user/web/$domain/public_html/wp-config.php"
+ if grep -q $'\r' $wp_config_path; then
+ echo "=== removing CRLF from wp-config.php"
+ tr -d '\r' < $wp_config_path > /tmp/wp-config.php && mv /tmp/wp-config.php $wp_config_path
+ chown $user:$user $wp_config_path
+ fi
+ db_name=$(grep "DB_NAME" $wp_config_path | grep -oP "define\s*\(\s*'DB_NAME'\s*,\s*'\K[^']+")
+ new_password=$(generate_password)
+ echo "DB name: $db_name"
+ echo "New DB password: $new_password"
+ # echo "executing: /usr/local/vesta/bin/v-change-database-password \"$user\" \"$db_name\" \"$new_password\""
+ /usr/local/vesta/bin/v-change-database-password "$user" "$db_name" "$new_password"
+ if [ $? -ne 0 ]; then
+ echo "*************** ERROR: Failed to change database password ***************"
+ exit 1;
+ fi
+ line="define('DB_PASSWORD', '$new_password');"
+ chattr -i $wp_config_path
+ sed -i "s/.*define(.*DB_PASSWORD'.*/$line/" $wp_config_path
+ new_password_line=$(grep "DB_PASSWORD" $wp_config_path)
+ echo "New DB password line: $new_password_line"
+ if [ "$new_password_line" != "$line" ]; then
+ echo "*************** ERROR: line in wp-config.php is not what we expected ***************"
+ echo "Expected: $line"
+ echo "Actual : $new_password_line"
+ echo "*************** ERROR: Please check wp-config.php manually ***************"
+ exit 1;
+ fi
+else
+ echo "ERROR: WP-config.php not found"
+ exit 1;
+fi
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$ARGUMENTS"
+
+exit
From 819450ca5c1de0646037f8734a103a1870ea39ea Mon Sep 17 00:00:00 2001
From: isscbta <53144593+isscbta@users.noreply.github.com>
Date: Mon, 16 Jun 2025 17:23:28 +0200
Subject: [PATCH 226/304] Create v-fix-wp-core
---
bin/v-fix-wp-core | 90 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
create mode 100644 bin/v-fix-wp-core
diff --git a/bin/v-fix-wp-core b/bin/v-fix-wp-core
new file mode 100644
index 00000000..5bef3232
--- /dev/null
+++ b/bin/v-fix-wp-core
@@ -0,0 +1,90 @@
+#!/bin/bash
+# info: fix compromised wp-admin and wp-includes
+# options: DOMAIN [CACHE_DIR]
+#
+# Replaces wp-admin and wp-includes with clean copies that match
+# the WordPress core version detected on the site.
+#
+# Example:
+# v-fix-wp-core example.com
+# v-fix-wp-core example.com /srv/wp-cache
+
+#----------------------------------------------------------#
+# Variable & Function #
+#----------------------------------------------------------#
+
+# Arguments
+DOMAIN="$1"
+CACHE_DIR="${2-/srv/wp-cache}" # default cache location
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/conf/vesta.conf
+
+#----------------------------------------------------------#
+# Verifications #
+#----------------------------------------------------------#
+check_args '1' "$#" 'DOMAIN [CACHE_DIR]'
+is_format_valid 'domain'
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+TMP_DIR="$(mktemp -d /tmp/wpfix.XXXXXX)" # temp workspace
+trap 'rm -rf "$TMP_DIR"' EXIT
+
+# 1etermine WP version
+WP_VERSION="$(v-run-wp-cli "$DOMAIN" core version | tr -d '[:space:]')"
+check_result $? "cannot detect WP version" > /dev/null
+if [ -z "$WP_VERSION" ]; then
+ check_result 1 "empty WP version string"
+fi
+echo "Detected WordPress version $WP_VERSION"
+
+# 2ind site owner and path
+USER="$(v-search-domain-owner "$DOMAIN")"
+check_result $? "cannot find domain owner" > /dev/null
+SITE_PATH="/home/$USER/web/$DOMAIN/public_html"
+if [ ! -d "$SITE_PATH" ]; then
+ check_result 1 "site path $SITE_PATH does not exist"
+fi
+
+# ensure cached core is present
+CACHE_PATH="$CACHE_DIR/$WP_VERSION"
+if [ ! -d "$CACHE_PATH/wp-admin" ] || [ ! -d "$CACHE_PATH/wp-includes" ]; then
+ echo "Cache for $WP_VERSION missing, downloading ZIP..."
+
+ mkdir -p "$CACHE_PATH"
+ ZIP_URL="https://wordpress.org/wordpress-${WP_VERSION}.zip"
+ ZIP_FILE="$TMP_DIR/wp.zip"
+
+ curl -fSL "$ZIP_URL" -o "$ZIP_FILE"
+ check_result $? "download failed" > /dev/null
+
+ unzip -q "$ZIP_FILE" -d "$TMP_DIR"
+ check_result $? "unzip failed" > /dev/null
+
+ mv "$TMP_DIR/wordpress/wp-admin" "$CACHE_PATH/"
+ mv "$TMP_DIR/wordpress/wp-includes" "$CACHE_PATH/"
+fi
+
+# backup current core folders
+TIMESTAMP="$(date +%Y%m%d%H%M%S)"
+BACKUP_DIR="$SITE_PATH/backup-core-$TIMESTAMP"
+mkdir -p "$BACKUP_DIR"
+mv "$SITE_PATH/wp-admin" "$BACKUP_DIR/"
+mv "$SITE_PATH/wp-includes" "$BACKUP_DIR/"
+check_result $? "backup failed" > /dev/null
+echo "Old core folders moved to $BACKUP_DIR"
+
+# deploy clean core
+rsync -a --delete "$CACHE_PATH/wp-admin/" "$SITE_PATH/wp-admin/"
+rsync -a --delete "$CACHE_PATH/wp-includes/" "$SITE_PATH/wp-includes/"
+check_result $? "rsync failed" > /dev/null
+
+# fix permissions
+v-fix-website-permissions $DOMAIN
+
+echo "Done, wp-admin and wp-includes replaced for $DOMAIN"
+exit
From 4f871db1fc52dd1e357ddb2d7e5566c2f916072c Mon Sep 17 00:00:00 2001
From: isscbta <53144593+isscbta@users.noreply.github.com>
Date: Mon, 16 Jun 2025 17:28:34 +0200
Subject: [PATCH 227/304] Update v-fix-wp-core
---
bin/v-fix-wp-core | 2 ++
1 file changed, 2 insertions(+)
diff --git a/bin/v-fix-wp-core b/bin/v-fix-wp-core
index 5bef3232..67d91f40 100644
--- a/bin/v-fix-wp-core
+++ b/bin/v-fix-wp-core
@@ -75,6 +75,7 @@ BACKUP_DIR="$SITE_PATH/backup-core-$TIMESTAMP"
mkdir -p "$BACKUP_DIR"
mv "$SITE_PATH/wp-admin" "$BACKUP_DIR/"
mv "$SITE_PATH/wp-includes" "$BACKUP_DIR/"
+chown -R www-data:www-data "$BACKUP_DIR"
check_result $? "backup failed" > /dev/null
echo "Old core folders moved to $BACKUP_DIR"
@@ -85,6 +86,7 @@ check_result $? "rsync failed" > /dev/null
# fix permissions
v-fix-website-permissions $DOMAIN
+chown -R www-data:www-data "$BACKUP_DIR"
echo "Done, wp-admin and wp-includes replaced for $DOMAIN"
exit
From 59053e2ffd745754350609d4eb797cd8ea6121ca Mon Sep 17 00:00:00 2001
From: isscbta <53144593+isscbta@users.noreply.github.com>
Date: Tue, 17 Jun 2025 00:07:17 +0200
Subject: [PATCH 228/304] Update v-fix-wp-core
---
bin/v-fix-wp-core | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/bin/v-fix-wp-core b/bin/v-fix-wp-core
index 67d91f40..e852da4d 100644
--- a/bin/v-fix-wp-core
+++ b/bin/v-fix-wp-core
@@ -67,6 +67,7 @@ if [ ! -d "$CACHE_PATH/wp-admin" ] || [ ! -d "$CACHE_PATH/wp-includes" ]; then
mv "$TMP_DIR/wordpress/wp-admin" "$CACHE_PATH/"
mv "$TMP_DIR/wordpress/wp-includes" "$CACHE_PATH/"
+ cp "$TMP_DIR/wordpress"/*.php "$CACHE_PATH/"
fi
# backup current core folders
@@ -75,6 +76,12 @@ BACKUP_DIR="$SITE_PATH/backup-core-$TIMESTAMP"
mkdir -p "$BACKUP_DIR"
mv "$SITE_PATH/wp-admin" "$BACKUP_DIR/"
mv "$SITE_PATH/wp-includes" "$BACKUP_DIR/"
+
+for f in "$SITE_PATH"/*.php; do
+ [[ $(basename "$f") == "wp-config.php" ]] && continue
+ mv "$f" "$BACKUP_DIR/"
+done
+
chown -R www-data:www-data "$BACKUP_DIR"
check_result $? "backup failed" > /dev/null
echo "Old core folders moved to $BACKUP_DIR"
@@ -84,6 +91,12 @@ rsync -a --delete "$CACHE_PATH/wp-admin/" "$SITE_PATH/wp-admin/"
rsync -a --delete "$CACHE_PATH/wp-includes/" "$SITE_PATH/wp-includes/"
check_result $? "rsync failed" > /dev/null
+for corephp in "$CACHE_PATH"/*.php; do
+ base=$(basename "$corephp")
+ [ "$base" = "wp-config.php" ] && continue
+ rsync -a "$corephp" "$SITE_PATH/$base"
+done
+
# fix permissions
v-fix-website-permissions $DOMAIN
chown -R www-data:www-data "$BACKUP_DIR"
From e8cbaa742f454bdc0e1b2552100e9e43098d8fec Mon Sep 17 00:00:00 2001
From: isscbta <53144593+isscbta@users.noreply.github.com>
Date: Tue, 17 Jun 2025 00:23:04 +0200
Subject: [PATCH 229/304] Create v-change-wp-admins-pass
---
bin/v-change-wp-admins-pass | 115 ++++++++++++++++++++++++++++++++++++
1 file changed, 115 insertions(+)
create mode 100644 bin/v-change-wp-admins-pass
diff --git a/bin/v-change-wp-admins-pass b/bin/v-change-wp-admins-pass
new file mode 100644
index 00000000..0b55082d
--- /dev/null
+++ b/bin/v-change-wp-admins-pass
@@ -0,0 +1,115 @@
+#!/bin/bash
+# info: interactively change WordPress admin passwords for a given domain
+# options: DOMAIN
+
+# -------------------------------------------------------- #
+# variables and checks #
+# -------------------------------------------------------- #
+
+if [ "$(whoami)" != "root" ]; then
+ echo "You must be root to run this command."
+ exit 1
+fi
+
+source /etc/profile
+
+domain="$1"
+if [ -z "$domain" ]; then
+ echo "Usage: v-change-wp-admin-pass DOMAIN"
+ exit 1
+fi
+
+user=$(/usr/local/vesta/bin/v-search-domain-owner "$domain")
+if [ -z "$user" ]; then
+ echo "Domain $domain does not exist."
+ exit 1
+fi
+
+wp_path="/home/$user/web/$domain/public_html"
+if [ ! -f "$wp_path/wp-config.php" ]; then
+ echo "WordPress is not installed on this domain."
+ exit 1
+fi
+
+# make sure WP-CLI exists
+if ! command -v wp >/dev/null 2>&1; then
+ echo "WP-CLI is not installed, installing..."
+ wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
+ chmod +x /usr/local/bin/wp
+fi
+
+# detect PHP for this domain
+phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$domain")
+if command -v "php$phpver" >/dev/null 2>&1; then
+ php_bin=$(command -v "php$phpver")
+else
+ php_bin=$(command -v php)
+fi
+[ -z "$php_bin" ] && { echo "Could not find a PHP binary."; exit 1; }
+
+# WP-CLI wrapper (array keeps spaces intact)
+wp_run=(sudo -u "$user" "$php_bin" /usr/local/bin/wp --skip-plugins --skip-themes)
+
+# simple random 10-char generator (letters and digits)
+gen_pass() {
+ tr -dc 'A-Za-z0-9' /dev/null | tail -n +2)
+
+if [ -z "$admin_list" ]; then
+ echo "No administrator accounts found."
+ exit 0
+fi
+
+printf "%-6s %-20s %s\n" "ID" "Username" "Email"
+echo "$admin_list" | while IFS=',' read -r id login email; do
+ printf "%-6s %-20s %s\n" "$id" "$login" "$email"
+done
+
+echo
+echo "You will be asked for each admin whether you want to change the password."
+
+# interactive loop
+while IFS=',' read -r id login email; do
+ [ -n "$email" ] && prompt_target="$login <$email>" || prompt_target="$login"
+
+ while true; do
+ read -r -p "Change the password for $prompt_target? (y/n) " yn < /dev/tty
+ case "$yn" in
+ [Yy]* )
+ new_pass=$(gen_pass)
+ if "${wp_run[@]}" user update "$id" --user_pass="$new_pass" --quiet; then
+ echo "Password for $prompt_target has been changed to: $new_pass"
+ else
+ echo "Failed to change password for $prompt_target."
+ fi
+ break
+ ;;
+ [Nn]* )
+ echo "Skipping $prompt_target."
+ break
+ ;;
+ * )
+ echo "Please answer y or n."
+ ;;
+ esac
+ done
+done <<< "$admin_list"
+
+echo
+echo "Done."
+exit 0
From aa2f5e4fbb59a7f0c19ae3c50b7856cc3ff2ac4d Mon Sep 17 00:00:00 2001
From: isscbta <53144593+isscbta@users.noreply.github.com>
Date: Tue, 17 Jun 2025 00:40:10 +0200
Subject: [PATCH 230/304] Update v-fix-wp-core
---
bin/v-fix-wp-core | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/bin/v-fix-wp-core b/bin/v-fix-wp-core
index e852da4d..8bf3277b 100644
--- a/bin/v-fix-wp-core
+++ b/bin/v-fix-wp-core
@@ -35,7 +35,7 @@ TMP_DIR="$(mktemp -d /tmp/wpfix.XXXXXX)" # temp workspace
trap 'rm -rf "$TMP_DIR"' EXIT
# 1etermine WP version
-WP_VERSION="$(v-run-wp-cli "$DOMAIN" core version | tr -d '[:space:]')"
+WP_VERSION="$(/usr/local/vesta/bin/v-run-wp-cli "$DOMAIN" core version | tr -d '[:space:]')"
check_result $? "cannot detect WP version" > /dev/null
if [ -z "$WP_VERSION" ]; then
check_result 1 "empty WP version string"
@@ -43,7 +43,7 @@ fi
echo "Detected WordPress version $WP_VERSION"
# 2ind site owner and path
-USER="$(v-search-domain-owner "$DOMAIN")"
+USER="$(/usr/local/vesta/bin/v-search-domain-owner "$DOMAIN")"
check_result $? "cannot find domain owner" > /dev/null
SITE_PATH="/home/$USER/web/$DOMAIN/public_html"
if [ ! -d "$SITE_PATH" ]; then
@@ -98,7 +98,7 @@ for corephp in "$CACHE_PATH"/*.php; do
done
# fix permissions
-v-fix-website-permissions $DOMAIN
+/usr/local/vesta/bin/v-fix-website-permissions $DOMAIN
chown -R www-data:www-data "$BACKUP_DIR"
echo "Done, wp-admin and wp-includes replaced for $DOMAIN"
From a8e39817fcb8c9d30dc02cb85fa2f22634030987 Mon Sep 17 00:00:00 2001
From: isscbta <53144593+isscbta@users.noreply.github.com>
Date: Tue, 17 Jun 2025 00:40:47 +0200
Subject: [PATCH 231/304] Create v-desinfect-wp
---
bin/v-desinfect-wp | 89 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
create mode 100644 bin/v-desinfect-wp
diff --git a/bin/v-desinfect-wp b/bin/v-desinfect-wp
new file mode 100644
index 00000000..e1ddc65d
--- /dev/null
+++ b/bin/v-desinfect-wp
@@ -0,0 +1,89 @@
+#!/bin/bash
+# info: disinfect a WordPress site with several maintenance commands
+# options: DOMAIN
+
+# -------------------------------------------------------- #
+# variables and checks #
+# -------------------------------------------------------- #
+
+if [ "$(whoami)" != "root" ]; then
+ echo "You must be root to run this command."
+ exit 1
+fi
+
+# make sure all Vesta helper scripts are reachable
+export PATH="/usr/local/vesta/bin:$PATH"
+source /etc/profile
+
+domain="$1"
+if [ -z "$domain" ]; then
+ echo "Usage: v-desinfect-wp DOMAIN"
+ exit 1
+fi
+
+user=$(/usr/local/vesta/bin/v-search-domain-owner "$domain")
+if [ -z "$user" ]; then
+ echo "Domain $domain does not exist."
+ exit 1
+fi
+
+# choose the correct admin-password script (with or without the “s”)
+if [ -x /usr/local/vesta/bin/v-change-wp-admin-pass ]; then
+ admin_pass_script="/usr/local/vesta/bin/v-change-wp-admin-pass"
+elif [ -x /usr/local/vesta/bin/v-change-wp-admins-pass ]; then
+ admin_pass_script="/usr/local/vesta/bin/v-change-wp-admins-pass"
+else
+ admin_pass_script=""
+fi
+
+# absolute paths to maintenance scripts, in desired order
+declare -a tasks=(
+ "/usr/local/vesta/bin/v-change-db-password-to-wordpress"
+ "/usr/local/vesta/bin/v-fix-wp-core"
+ "/usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
+)
+
+# append the admin script if we found one
+[ -n "$admin_pass_script" ] && tasks+=("$admin_pass_script")
+
+# -------------------------------------------------------- #
+# execution strategy #
+# -------------------------------------------------------- #
+
+echo
+read -r -p "Run all maintenance steps automatically? (y/n) " run_all < /dev/tty
+
+if [[ "$run_all" =~ ^[Yy]$ ]]; then
+ echo "Running all maintenance steps for $domain"
+ automatic=true
+else
+ echo
+ echo "Selective mode. You will be asked for each step."
+ automatic=false
+fi
+
+for cmd in "${tasks[@]}"; do
+ if [ ! -x "$cmd" ]; then
+ echo "Command $cmd not found or not executable, skipping."
+ continue
+ fi
+
+ if [ "$automatic" = false ]; then
+ while true; do
+ read -r -p "Run $(basename "$cmd") for $domain? (y/n) " yn < /dev/tty
+ case "$yn" in
+ [Yy]* ) break ;;
+ [Nn]* ) echo "Skipping $(basename "$cmd")."; continue 2 ;;
+ * ) echo "Please answer y or n." ;;
+ esac
+ done
+ fi
+
+ echo
+ echo "=== $(basename "$cmd") $domain ==="
+ "$cmd" "$domain"
+done
+
+echo
+echo "Done."
+exit 0
From 8a4b66a135bf956c6acc6ec62430a5b2ebe5b772 Mon Sep 17 00:00:00 2001
From: isscbta <53144593+isscbta@users.noreply.github.com>
Date: Tue, 17 Jun 2025 00:42:19 +0200
Subject: [PATCH 232/304] Update v-fix-wp-core
---
bin/v-fix-wp-core | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bin/v-fix-wp-core b/bin/v-fix-wp-core
index 8bf3277b..4240b0ab 100644
--- a/bin/v-fix-wp-core
+++ b/bin/v-fix-wp-core
@@ -101,5 +101,5 @@ done
/usr/local/vesta/bin/v-fix-website-permissions $DOMAIN
chown -R www-data:www-data "$BACKUP_DIR"
-echo "Done, wp-admin and wp-includes replaced for $DOMAIN"
+echo "Done, core WP files, wp-admin and wp-includes replaced for $DOMAIN"
exit
From 12dc1a57182fc3c63e7c79ccace891949eb02070 Mon Sep 17 00:00:00 2001
From: isscbta <53144593+isscbta@users.noreply.github.com>
Date: Tue, 17 Jun 2025 00:49:27 +0200
Subject: [PATCH 233/304] Update v-change-wp-admins-pass
---
bin/v-change-wp-admins-pass | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/bin/v-change-wp-admins-pass b/bin/v-change-wp-admins-pass
index 0b55082d..9351e4a1 100644
--- a/bin/v-change-wp-admins-pass
+++ b/bin/v-change-wp-admins-pass
@@ -31,7 +31,7 @@ if [ ! -f "$wp_path/wp-config.php" ]; then
exit 1
fi
-# make sure WP-CLI exists
+# ensure WP-CLI exists
if ! command -v wp >/dev/null 2>&1; then
echo "WP-CLI is not installed, installing..."
wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
@@ -50,7 +50,7 @@ fi
# WP-CLI wrapper (array keeps spaces intact)
wp_run=(sudo -u "$user" "$php_bin" /usr/local/bin/wp --skip-plugins --skip-themes)
-# simple random 10-char generator (letters and digits)
+# random 10-character password generator (letters and digits)
gen_pass() {
tr -dc 'A-Za-z0-9'
Date: Tue, 17 Jun 2025 01:20:05 +0200
Subject: [PATCH 234/304] Update v-change-wp-admins-pass
---
bin/v-change-wp-admins-pass | 153 ++++++++++++------------------------
1 file changed, 50 insertions(+), 103 deletions(-)
diff --git a/bin/v-change-wp-admins-pass b/bin/v-change-wp-admins-pass
index 9351e4a1..f7aa5245 100644
--- a/bin/v-change-wp-admins-pass
+++ b/bin/v-change-wp-admins-pass
@@ -1,128 +1,75 @@
#!/bin/bash
-# info: interactively change WordPress admin passwords for a given domain
+# info: disinfect a WordPress site with several maintenance commands
# options: DOMAIN
-# -------------------------------------------------------- #
-# variables and checks #
-# -------------------------------------------------------- #
+#----------------------------------------------------------#
+# Variable & Function #
+#----------------------------------------------------------#
+DOMAIN="$1"
+VESTA="/usr/local/vesta"
+
+# absolute paths to maintenance scripts
+CHANGE_DB_PASS="/usr/local/vesta/bin/v-change-db-password-to-wordpress"
+FIX_CORE="/usr/local/vesta/bin/v-fix-wp-core"
+WF_SCAN="/usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
+ADMIN_PASS="/usr/local/vesta/bin/v-change-wp-admins-pass"
+
+TASKS=(
+ "$CHANGE_DB_PASS"
+ "$FIX_CORE"
+ "$WF_SCAN"
+ "$ADMIN_PASS"
+)
+
+#----------------------------------------------------------#
+# Verifications #
+#----------------------------------------------------------#
if [ "$(whoami)" != "root" ]; then
echo "You must be root to run this command."
exit 1
fi
-source /etc/profile
-
-domain="$1"
-if [ -z "$domain" ]; then
- echo "Usage: v-change-wp-admin-pass DOMAIN"
+if [ -z "$DOMAIN" ]; then
+ echo "Usage: v-desinfect-wp DOMAIN"
exit 1
fi
-user=$(/usr/local/vesta/bin/v-search-domain-owner "$domain")
-if [ -z "$user" ]; then
- echo "Domain $domain does not exist."
+if ! "$VESTA/bin/v-search-domain-owner" "$DOMAIN" >/dev/null 2>&1; then
+ echo "Domain $DOMAIN does not exist."
exit 1
fi
-wp_path="/home/$user/web/$domain/public_html"
-if [ ! -f "$wp_path/wp-config.php" ]; then
- echo "WordPress is not installed on this domain."
- exit 1
-fi
-
-# ensure WP-CLI exists
-if ! command -v wp >/dev/null 2>&1; then
- echo "WP-CLI is not installed, installing..."
- wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
- chmod +x /usr/local/bin/wp
-fi
-
-# detect PHP for this domain
-phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$domain")
-if command -v "php$phpver" >/dev/null 2>&1; then
- php_bin=$(command -v "php$phpver")
-else
- php_bin=$(command -v php)
-fi
-[ -z "$php_bin" ] && { echo "Could not find a PHP binary."; exit 1; }
-
-# WP-CLI wrapper (array keeps spaces intact)
-wp_run=(sudo -u "$user" "$php_bin" /usr/local/bin/wp --skip-plugins --skip-themes)
-
-# random 10-character password generator (letters and digits)
-gen_pass() {
- tr -dc 'A-Za-z0-9' /dev/null | tail -n +2)
+for CMD in "${TASKS[@]}"; do
+ if [ ! -x "$CMD" ]; then
+ echo "Command $CMD not found or not executable, skipping."
+ continue
+ fi
-if [ -z "$admin_list" ]; then
- echo "No administrator accounts found."
- exit 0
-fi
+ if [ "$AUTOMATIC" = false ]; then
+ while true; do
+ read -r -p "Run $(basename "$CMD") for $DOMAIN? (y/n) " YN < /dev/tty
+ case "$YN" in
+ [Yy]* ) break ;;
+ [Nn]* ) echo "Skipping $(basename "$CMD")."; continue 2 ;;
+ * ) echo "Please answer y or n." ;;
+ esac
+ done
+ fi
-printf "%-6s %-20s %s\n" "ID" "Username" "Email"
-echo "$admin_list" | while IFS=',' read -r id login email; do
- printf "%-6s %-20s %s\n" "$id" "$login" "$email"
+ echo
+ echo "=== $(basename "$CMD") $DOMAIN ==="
+ "$CMD" "$DOMAIN"
done
-echo
-echo "You will be asked for each admin whether you want to change the password."
-
-# interactive loop
-while IFS=',' read -r id login email; do
- [ -n "$email" ] && prompt_target="$login <$email>" || prompt_target="$login"
-
- while true; do
- read -r -p "Change the password for $prompt_target? (y/n) " yn < /dev/tty
- case "$yn" in
- [Yy]* )
- new_pass=$(gen_pass)
- if "${wp_run[@]}" user update "$id" --user_pass="$new_pass" --quiet; then
- echo "Password for $prompt_target has been changed to: $new_pass"
- else
- echo "Failed to change password for $prompt_target."
- fi
- break
- ;;
- [Nn]* )
- echo "Skipping $prompt_target."
- break
- ;;
- * )
- echo "Please answer y or n."
- ;;
- esac
- done
-done <<< "$admin_list"
-
-# -------------------------------------------------------- #
-# flush cache and refresh all security salts #
-# -------------------------------------------------------- #
-
-echo
-echo "Flushing cache and refreshing salts..."
-
-"${wp_run[@]}" cache flush
-"${wp_run[@]}" config shuffle-salts WP_CACHE_KEY_SALT --force
-"${wp_run[@]}" config shuffle-salts
-
-echo "Cache flushed and salts refreshed."
-
echo
echo "Done."
exit 0
From 31413a8f7301ed055c0df73feeb4185f6890dfce Mon Sep 17 00:00:00 2001
From: isscbta <53144593+isscbta@users.noreply.github.com>
Date: Tue, 17 Jun 2025 01:56:02 +0200
Subject: [PATCH 235/304] Update v-change-wp-admins-pass
---
bin/v-change-wp-admins-pass | 152 ++++++++++++++++++++++++------------
1 file changed, 104 insertions(+), 48 deletions(-)
diff --git a/bin/v-change-wp-admins-pass b/bin/v-change-wp-admins-pass
index f7aa5245..0249efb7 100644
--- a/bin/v-change-wp-admins-pass
+++ b/bin/v-change-wp-admins-pass
@@ -1,75 +1,131 @@
#!/bin/bash
-# info: disinfect a WordPress site with several maintenance commands
+# info: interactively delete or change WordPress admin passwords for a given domain
# options: DOMAIN
+#
+# d → delete user (with content reassignment)
+# c → change password (random 10-char alnum)
+# s → skip
#----------------------------------------------------------#
# Variable & Function #
#----------------------------------------------------------#
+[ "$(whoami)" != "root" ] && { echo "You must be root to run this command."; exit 1; }
+source /etc/profile
+
DOMAIN="$1"
-VESTA="/usr/local/vesta"
+[ -z "$DOMAIN" ] && { echo "Usage: v-change-wp-admins-pass DOMAIN"; exit 1; }
-# absolute paths to maintenance scripts
-CHANGE_DB_PASS="/usr/local/vesta/bin/v-change-db-password-to-wordpress"
-FIX_CORE="/usr/local/vesta/bin/v-fix-wp-core"
-WF_SCAN="/usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
-ADMIN_PASS="/usr/local/vesta/bin/v-change-wp-admins-pass"
+USER="$(/usr/local/vesta/bin/v-search-domain-owner "$DOMAIN")"
+[ -z "$USER" ] && { echo "Domain $DOMAIN does not exist."; exit 1; }
-TASKS=(
- "$CHANGE_DB_PASS"
- "$FIX_CORE"
- "$WF_SCAN"
- "$ADMIN_PASS"
-)
+WP_PATH="/home/$USER/web/$DOMAIN/public_html"
+[ ! -f "$WP_PATH/wp-config.php" ] && { echo "WordPress is not installed on this domain."; exit 1; }
-#----------------------------------------------------------#
-# Verifications #
-#----------------------------------------------------------#
-if [ "$(whoami)" != "root" ]; then
- echo "You must be root to run this command."
- exit 1
+# ensure WP-CLI binary
+if ! command -v wp >/dev/null 2>&1; then
+ echo "WP-CLI is not installed, installing..."
+ wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
+ chmod +x /usr/local/bin/wp
fi
-if [ -z "$DOMAIN" ]; then
- echo "Usage: v-desinfect-wp DOMAIN"
- exit 1
-fi
+PHPVER=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$DOMAIN")
+PHP_BIN=$(command -v "php$PHPVER" 2>/dev/null || command -v php)
+[ -z "$PHP_BIN" ] && { echo "Could not find a PHP binary."; exit 1; }
-if ! "$VESTA/bin/v-search-domain-owner" "$DOMAIN" >/dev/null 2>&1; then
- echo "Domain $DOMAIN does not exist."
- exit 1
-fi
+# WP-CLI wrapper
+WP_RUN=(sudo -u "$USER" "$PHP_BIN" /usr/local/bin/wp --skip-plugins --skip-themes)
+
+# random 10-char password
+gen_pass() { tr -dc 'A-Za-z0-9' /dev/null | tail -n +2)
+[ -z "$ADMIN_LIST_CSV" ] && { echo "No administrator accounts found."; exit 0; }
- if [ "$AUTOMATIC" = false ]; then
- while true; do
- read -r -p "Run $(basename "$CMD") for $DOMAIN? (y/n) " YN < /dev/tty
- case "$YN" in
- [Yy]* ) break ;;
- [Nn]* ) echo "Skipping $(basename "$CMD")."; continue 2 ;;
- * ) echo "Please answer y or n." ;;
- esac
- done
- fi
-
- echo
- echo "=== $(basename "$CMD") $DOMAIN ==="
- "$CMD" "$DOMAIN"
+printf "%-6s %-20s %s\n" "ID" "Username" "Email"
+echo "$ADMIN_LIST_CSV" | while IFS=',' read -r PID PLOGIN PEMAIL; do
+ printf "%-6s %-20s %s\n" "$PID" "$PLOGIN" "$PEMAIL"
done
+echo
+echo "For each admin choose: (d) delete, (c) change password, (s) skip."
+
+# interactive loop
+echo "$ADMIN_LIST_CSV" | while IFS=',' read -r ID LOGIN EMAIL; do
+ [ -n "$EMAIL" ] && TARGET="$LOGIN <$EMAIL>" || TARGET="$LOGIN"
+ while true; do
+ read -r -p "Action for $TARGET [d/c/s]? " ACT < /dev/tty
+ case "$ACT" in
+ [Dd]* )
+ read -r -p "Really DELETE $TARGET? (y/n) " CONF < /dev/tty
+ if [[ "$CONF" =~ ^[Yy]$ ]]; then
+ # build an array of OTHER admin usernames
+ mapfile -t OTHER_USERS < <(echo "$ADMIN_LIST_CSV" | awk -F',' -v cur="$ID" '$1!=cur {print $2}')
+ if [ "${#OTHER_USERS[@]}" -eq 0 ]; then
+ echo "Cannot delete the only administrator account."
+ break
+ fi
+ DEFAULT_USER="${OTHER_USERS[0]}"
+ echo "Available admin usernames for reassignment: ${OTHER_USERS[*]}"
+ while true; do
+ read -r -p "Reassign content to which username? [default $DEFAULT_USER] " REASSIGN < /dev/tty
+ REASSIGN=${REASSIGN:-$DEFAULT_USER}
+ if printf '%s\n' "${OTHER_USERS[@]}" | grep -qx "$REASSIGN"; then
+ break
+ else
+ echo "Invalid username. Please choose one of: ${OTHER_USERS[*]}"
+ fi
+ done
+ # delete by username, reassign by username
+ "${WP_RUN[@]}" user delete "$LOGIN" --reassign="$REASSIGN" --yes >/dev/null 2>&1
+ echo "$TARGET deleted (content reassigned to $REASSIGN)."
+ else
+ echo "Deletion cancelled."
+ fi
+ break
+ ;;
+ [Cc]* )
+ NEW_PASS=$(gen_pass)
+ if "${WP_RUN[@]}" user update "$LOGIN" --user_pass="$NEW_PASS" --quiet; then
+ echo "Password for $TARGET changed to: $NEW_PASS"
+ else
+ echo "Failed to change password for $TARGET."
+ fi
+ break
+ ;;
+ [Ss]* )
+ echo "Skipping $TARGET."
+ break
+ ;;
+ * ) echo "Please answer d, c, or s." ;;
+ esac
+ done
+done
+
+#----------------------------------------------------------#
+# flush cache and refresh all security salts #
+#----------------------------------------------------------#
+
+echo
+echo "Flushing cache and refreshing salts..."
+
+"${WP_RUN[@]}" cache flush
+"${WP_RUN[@]}" config shuffle-salts WP_CACHE_KEY_SALT --force
+"${WP_RUN[@]}" config shuffle-salts
+
+echo "Cache flushed and salts refreshed."
+
echo
echo "Done."
exit 0
From 596bce582f627d14b5ff0f0422773e7a894b4f2f Mon Sep 17 00:00:00 2001
From: Peca
Date: Tue, 17 Jun 2025 11:43:48 +0200
Subject: [PATCH 236/304] Jailing v-run-wp-cli
---
bin/v-run-wp-cli | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/bin/v-run-wp-cli b/bin/v-run-wp-cli
index 672832ab..ebe654f6 100644
--- a/bin/v-run-wp-cli
+++ b/bin/v-run-wp-cli
@@ -63,6 +63,9 @@ if [ ! -d "/home/$user/web/$domain/public_html" ]; then
exit 1;
fi
+mkdir -p /home/$user/.wp-cli
+chown $user:$user /home/$user/.wp-cli
+
phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$domain")
#----------------------------------------------------------#
@@ -70,7 +73,11 @@ phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$domain")
#----------------------------------------------------------#
cd /home/$USER/web/$domain/public_html
-sudo -u $USER /usr/bin/php$phpver /usr/local/bin/wp $wp_command
+sudo -u $USER /usr/bin/php$phpver -d disable_functions=pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,exec,system,passthru,shell_exec,proc_open,popen -d open_basedir=/home/$user/web/$domain:/home/$user/.wp-cli:/home/$user/tmp:/usr/local/bin /usr/local/bin/wp --path=/home/$user/web/$domain/public_html/ $wp_command 2>/home/$user/web/$domain/wp-cli-error.log
+
+echo "WP CLI: Done."
+echo "To see Warning/Error log: "
+echo "cat /home/$user/web/$domain/wp-cli-error.log"
#----------------------------------------------------------#
# Vesta #
From d1c48504adcf33fe068d065997f189d354399ff6 Mon Sep 17 00:00:00 2001
From: Peca
Date: Tue, 17 Jun 2025 14:02:31 +0200
Subject: [PATCH 237/304] v-run-wp-cli
---
bin/v-run-wp-cli | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/bin/v-run-wp-cli b/bin/v-run-wp-cli
index ebe654f6..9325d47d 100644
--- a/bin/v-run-wp-cli
+++ b/bin/v-run-wp-cli
@@ -75,9 +75,9 @@ phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$domain")
cd /home/$USER/web/$domain/public_html
sudo -u $USER /usr/bin/php$phpver -d disable_functions=pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,exec,system,passthru,shell_exec,proc_open,popen -d open_basedir=/home/$user/web/$domain:/home/$user/.wp-cli:/home/$user/tmp:/usr/local/bin /usr/local/bin/wp --path=/home/$user/web/$domain/public_html/ $wp_command 2>/home/$user/web/$domain/wp-cli-error.log
-echo "WP CLI: Done."
-echo "To see Warning/Error log: "
-echo "cat /home/$user/web/$domain/wp-cli-error.log"
+# echo "WP CLI: Done."
+# echo "To see Warning/Error log: "
+# echo "cat /home/$user/web/$domain/wp-cli-error.log"
#----------------------------------------------------------#
# Vesta #
From c8f9601a356df33ba8c13b24ac178352b6e91931 Mon Sep 17 00:00:00 2001
From: Peca
Date: Tue, 17 Jun 2025 15:56:56 +0200
Subject: [PATCH 238/304] v-fix-wp-core: BACKUP_DIR="$QUARANTINE_DIR/$DOMAIN/
---
bin/v-fix-wp-core | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/bin/v-fix-wp-core b/bin/v-fix-wp-core
index 4240b0ab..1dd87b71 100644
--- a/bin/v-fix-wp-core
+++ b/bin/v-fix-wp-core
@@ -17,6 +17,8 @@
DOMAIN="$1"
CACHE_DIR="${2-/srv/wp-cache}" # default cache location
+QUARANTINE_DIR="/srv/wp-quarantine"
+
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
@@ -72,7 +74,7 @@ fi
# backup current core folders
TIMESTAMP="$(date +%Y%m%d%H%M%S)"
-BACKUP_DIR="$SITE_PATH/backup-core-$TIMESTAMP"
+BACKUP_DIR="$QUARANTINE_DIR/$DOMAIN/backup-core-$TIMESTAMP"
mkdir -p "$BACKUP_DIR"
mv "$SITE_PATH/wp-admin" "$BACKUP_DIR/"
mv "$SITE_PATH/wp-includes" "$BACKUP_DIR/"
From b13b25602c1901cea81a37ed64516bd64f8f41fe Mon Sep 17 00:00:00 2001
From: Peca
Date: Tue, 17 Jun 2025 19:29:58 +0200
Subject: [PATCH 239/304] Use wp-cli from git repo if available
---
bin/v-run-wp-cli | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/bin/v-run-wp-cli b/bin/v-run-wp-cli
index 9325d47d..31730f63 100644
--- a/bin/v-run-wp-cli
+++ b/bin/v-run-wp-cli
@@ -58,6 +58,12 @@ if ! command -v wp &> /dev/null; then
echo "WP CLI installed successfully."
fi
+wpcli="/usr/local/bin/wp"
+
+if [ -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ wpcli="/usr/local/bin/wp-cli/php/boot-fs.php"
+fi
+
if [ ! -d "/home/$user/web/$domain/public_html" ]; then
# echo "Domain doesn't exist";
exit 1;
@@ -73,7 +79,7 @@ phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$domain")
#----------------------------------------------------------#
cd /home/$USER/web/$domain/public_html
-sudo -u $USER /usr/bin/php$phpver -d disable_functions=pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,exec,system,passthru,shell_exec,proc_open,popen -d open_basedir=/home/$user/web/$domain:/home/$user/.wp-cli:/home/$user/tmp:/usr/local/bin /usr/local/bin/wp --path=/home/$user/web/$domain/public_html/ $wp_command 2>/home/$user/web/$domain/wp-cli-error.log
+sudo -u $USER /usr/bin/php$phpver -d disable_functions=pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,exec,system,passthru,shell_exec,proc_open,popen -d open_basedir=/home/$user/web/$domain:/home/$user/.wp-cli:/home/$user/tmp:/usr/local/bin $wpcli --path=/home/$user/web/$domain/public_html/ $wp_command 2>/home/$user/web/$domain/wp-cli-error.log
# echo "WP CLI: Done."
# echo "To see Warning/Error log: "
From e46c7e4e60e3a225777de5c89ad527b4e0c8afd5 Mon Sep 17 00:00:00 2001
From: Peca
Date: Tue, 17 Jun 2025 22:22:16 +0200
Subject: [PATCH 240/304] v-get-wp-cli and terminal $COLUMNS fix
---
bin/v-get-wp-cli | 44 ++++++++++++++++++++++++++++++++++++++++++++
bin/v-run-wp-cli | 15 +++++++++------
2 files changed, 53 insertions(+), 6 deletions(-)
create mode 100644 bin/v-get-wp-cli
diff --git a/bin/v-get-wp-cli b/bin/v-get-wp-cli
new file mode 100644
index 00000000..c097a024
--- /dev/null
+++ b/bin/v-get-wp-cli
@@ -0,0 +1,44 @@
+#!/bin/bash
+# info: Download WP CLI
+# options: NONE
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+whoami=$(whoami)
+if [ "$whoami" != "root" ]; then
+ echo "You must be root to execute this script"
+ exit 1
+fi
+
+# Importing system environment
+source /etc/profile
+
+if [ ! -f "/usr/local/bin/composer" ]; then
+ echo "= Composer is not installed. Installing..."
+ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
+ php composer-setup.php --install-dir=/usr/local/bin --filename=composer
+ php -r "unlink('composer-setup.php');"
+ echo "= Composer installed successfully."
+fi
+
+if [ -d "/usr/local/bin/wp-cli" ]; then
+ echo "= Removing old WP CLI..."
+ rm -rf /usr/local/bin/wp-cli
+fi
+
+cd /usr/local/bin
+git clone https://github.com/wp-cli/wp-cli.git
+
+chown -R www-data:www-data wp-cli
+
+cd wp-cli/
+sudo -H -u www-data composer install
+
+# Fix terminal columns issue for WP CLI
+/usr/local/vesta/bin/v-sed '$columns = 80;' "if (file_exists('/usr/local/bin/wp-cli/COLUMNS')) \$columns=intval(file_get_contents('/usr/local/bin/wp-cli/COLUMNS')); else \$columns = 80;" '/usr/local/bin/wp-cli/vendor/wp-cli/php-cli-tools/lib/cli/Shell.php'
+
+echo "= WP CLI installed successfully."
+
+exit 0;
\ No newline at end of file
diff --git a/bin/v-run-wp-cli b/bin/v-run-wp-cli
index 31730f63..1a0e2adc 100644
--- a/bin/v-run-wp-cli
+++ b/bin/v-run-wp-cli
@@ -62,11 +62,8 @@ wpcli="/usr/local/bin/wp"
if [ -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
wpcli="/usr/local/bin/wp-cli/php/boot-fs.php"
-fi
-
-if [ ! -d "/home/$user/web/$domain/public_html" ]; then
- # echo "Domain doesn't exist";
- exit 1;
+ COLUMNS=$(/usr/bin/env stty size 2>/dev/null | awk '{print $2}')
+ echo $COLUMNS > /usr/local/bin/wp-cli/COLUMNS
fi
mkdir -p /home/$user/.wp-cli
@@ -81,6 +78,12 @@ phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$domain")
cd /home/$USER/web/$domain/public_html
sudo -u $USER /usr/bin/php$phpver -d disable_functions=pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,exec,system,passthru,shell_exec,proc_open,popen -d open_basedir=/home/$user/web/$domain:/home/$user/.wp-cli:/home/$user/tmp:/usr/local/bin $wpcli --path=/home/$user/web/$domain/public_html/ $wp_command 2>/home/$user/web/$domain/wp-cli-error.log
+return_code=$?
+
+if [ -f "/usr/local/bin/wp-cli/COLUMNS" ]; then
+ rm /usr/local/bin/wp-cli/COLUMNS
+fi
+
# echo "WP CLI: Done."
# echo "To see Warning/Error log: "
# echo "cat /home/$user/web/$domain/wp-cli-error.log"
@@ -89,4 +92,4 @@ sudo -u $USER /usr/bin/php$phpver -d disable_functions=pcntl_alarm,pcntl_fork,pc
# Vesta #
#----------------------------------------------------------#
-exit 0;
+exit $return_code;
From 2e2b4b2f58544c57aeaf2b0cfd6256af3d288195 Mon Sep 17 00:00:00 2001
From: Peca
Date: Thu, 19 Jun 2025 15:57:50 +0200
Subject: [PATCH 241/304] v-backup-user-now skip LA limit
---
bin/v-backup-user | 3 +++
bin/v-backup-user-now | 1 +
2 files changed, 4 insertions(+)
diff --git a/bin/v-backup-user b/bin/v-backup-user
index 0db5d376..f6629c9e 100755
--- a/bin/v-backup-user
+++ b/bin/v-backup-user
@@ -22,6 +22,9 @@ source $VESTA/func/domain.sh
source $VESTA/func/db.sh
source $VESTA/conf/vesta.conf
+if [ ! -z "$NOW" ]; then
+ BACKUP_LA_LIMIT=50
+fi
#----------------------------------------------------------#
# Verifications #
diff --git a/bin/v-backup-user-now b/bin/v-backup-user-now
index 3a20b4ce..10eecd87 100644
--- a/bin/v-backup-user-now
+++ b/bin/v-backup-user-now
@@ -1,5 +1,6 @@
#!/bin/bash
export ALLOW_BACKUP_ANYTIME='yes'
+export NOW='yes'
nice -n 19 ionice -c 3 /usr/local/vesta/bin/v-backup-user $1
From 761da8150b869df8392d2644a9a9e23a32a0cace Mon Sep 17 00:00:00 2001
From: Peca
Date: Fri, 20 Jun 2025 17:54:04 +0200
Subject: [PATCH 242/304] Visual improvements for v-change-wp-admins-pass
---
bin/v-change-wp-admins-pass | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/bin/v-change-wp-admins-pass b/bin/v-change-wp-admins-pass
index 0249efb7..44870b58 100644
--- a/bin/v-change-wp-admins-pass
+++ b/bin/v-change-wp-admins-pass
@@ -65,11 +65,12 @@ echo "For each admin choose: (d) delete, (c) change password, (s) skip."
echo "$ADMIN_LIST_CSV" | while IFS=',' read -r ID LOGIN EMAIL; do
[ -n "$EMAIL" ] && TARGET="$LOGIN <$EMAIL>" || TARGET="$LOGIN"
while true; do
- read -r -p "Action for $TARGET [d/c/s]? " ACT < /dev/tty
+ echo "-------------------------------------"
+ read -r -p "Action for \"$TARGET\" [d/c/s]? " ACT < /dev/tty
case "$ACT" in
[Dd]* )
- read -r -p "Really DELETE $TARGET? (y/n) " CONF < /dev/tty
- if [[ "$CONF" =~ ^[Yy]$ ]]; then
+ read -r -p "Really DELETE \"$TARGET\" ? ('y' or ENTER for yes / 'n' for no) " CONF < /dev/tty
+ if [[ ! "$CONF" =~ ^[Nn]$ ]]; then
# build an array of OTHER admin usernames
mapfile -t OTHER_USERS < <(echo "$ADMIN_LIST_CSV" | awk -F',' -v cur="$ID" '$1!=cur {print $2}')
if [ "${#OTHER_USERS[@]}" -eq 0 ]; then
From 294c8ba516a3242d444b19c0156b874c9eb77027 Mon Sep 17 00:00:00 2001
From: Peca
Date: Sat, 21 Jun 2025 15:57:21 +0200
Subject: [PATCH 243/304] Setting chmod 600 for all php files
---
...hange-database-password-for-all-wordpress} | 2 +-
... v-change-database-password-for-wordpress} | 11 +++--
...ns-pass => v-change-wordpress-admins-pass} | 16 +++++---
bin/{v-desinfect-wp => v-desinfect-wordpress} | 18 ++------
bin/v-fix-user-permissions | 1 +
bin/v-fix-website-permissions | 26 ++++++++++--
...v-fix-website-permissions-for-all-websites | 41 +++++++++++++++++++
bin/{v-fix-wp-core => v-fix-wordpress-core} | 0
bin/v-unlock-wordpress | 2 +
9 files changed, 90 insertions(+), 27 deletions(-)
rename bin/{v-change-db-password-to-all-wordpress => v-change-database-password-for-all-wordpress} (93%)
rename bin/{v-change-db-password-to-wordpress => v-change-database-password-for-wordpress} (92%)
rename bin/{v-change-wp-admins-pass => v-change-wordpress-admins-pass} (93%)
rename bin/{v-desinfect-wp => v-desinfect-wordpress} (77%)
create mode 100644 bin/v-fix-website-permissions-for-all-websites
rename bin/{v-fix-wp-core => v-fix-wordpress-core} (100%)
diff --git a/bin/v-change-db-password-to-all-wordpress b/bin/v-change-database-password-for-all-wordpress
similarity index 93%
rename from bin/v-change-db-password-to-all-wordpress
rename to bin/v-change-database-password-for-all-wordpress
index b31edb80..ad922cc2 100644
--- a/bin/v-change-db-password-to-all-wordpress
+++ b/bin/v-change-database-password-for-all-wordpress
@@ -26,7 +26,7 @@ for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
for domain in $(/usr/local/vesta/bin/v-list-web-domains $user plain |cut -f 1); do
if [ -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
- /usr/local/vesta/bin/v-change-db-password-to-wordpress $domain
+ /usr/local/vesta/bin/v-change-database-password-for-wordpress $domain $user
echo "--------------------------------"
fi
done
diff --git a/bin/v-change-db-password-to-wordpress b/bin/v-change-database-password-for-wordpress
similarity index 92%
rename from bin/v-change-db-password-to-wordpress
rename to bin/v-change-database-password-for-wordpress
index d7ce1782..e318edde 100644
--- a/bin/v-change-db-password-to-wordpress
+++ b/bin/v-change-database-password-for-wordpress
@@ -1,8 +1,8 @@
#!/bin/bash
-# info: change db password to wordpress database
+# info: change database password for wordpress
# options:
#
-# The command is used for changing db password to wordpress database.
+# The command is used for changing database password for wordpress.
#----------------------------------------------------------#
@@ -21,7 +21,12 @@ source /etc/profile
# Argument definition
domain=$1
-user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
+# Check if number of arguments is 2
+if [ $# -eq 2 ]; then
+ user=$2
+else
+ user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
+fi
USER=$user
if [ -z "$user" ]; then
diff --git a/bin/v-change-wp-admins-pass b/bin/v-change-wordpress-admins-pass
similarity index 93%
rename from bin/v-change-wp-admins-pass
rename to bin/v-change-wordpress-admins-pass
index 44870b58..9028cd10 100644
--- a/bin/v-change-wp-admins-pass
+++ b/bin/v-change-wordpress-admins-pass
@@ -59,14 +59,14 @@ echo "$ADMIN_LIST_CSV" | while IFS=',' read -r PID PLOGIN PEMAIL; do
done
echo
-echo "For each admin choose: (d) delete, (c) change password, (s) skip."
+echo "For each admin choose: (d) delete, (c) change password, (s) skip, (x) exit."
# interactive loop
-echo "$ADMIN_LIST_CSV" | while IFS=',' read -r ID LOGIN EMAIL; do
+while IFS=',' read -r ID LOGIN EMAIL; do
[ -n "$EMAIL" ] && TARGET="$LOGIN <$EMAIL>" || TARGET="$LOGIN"
while true; do
echo "-------------------------------------"
- read -r -p "Action for \"$TARGET\" [d/c/s]? " ACT < /dev/tty
+ read -r -p "Action for \"$TARGET\" [d/c/s/x]? " ACT < /dev/tty
case "$ACT" in
[Dd]* )
read -r -p "Really DELETE \"$TARGET\" ? ('y' or ENTER for yes / 'n' for no) " CONF < /dev/tty
@@ -109,15 +109,20 @@ echo "$ADMIN_LIST_CSV" | while IFS=',' read -r ID LOGIN EMAIL; do
echo "Skipping $TARGET."
break
;;
- * ) echo "Please answer d, c, or s." ;;
+ [Xx]* )
+ echo "Exiting."
+ exit 0
+ ;;
+ * ) echo "Please answer d, c, s, or x." ;;
esac
done
-done
+done <<< "$ADMIN_LIST_CSV"
#----------------------------------------------------------#
# flush cache and refresh all security salts #
#----------------------------------------------------------#
+echo "-------------------------------------"
echo
echo "Flushing cache and refreshing salts..."
@@ -129,4 +134,5 @@ echo "Cache flushed and salts refreshed."
echo
echo "Done."
+
exit 0
diff --git a/bin/v-desinfect-wp b/bin/v-desinfect-wordpress
similarity index 77%
rename from bin/v-desinfect-wp
rename to bin/v-desinfect-wordpress
index e1ddc65d..4de2f779 100644
--- a/bin/v-desinfect-wp
+++ b/bin/v-desinfect-wordpress
@@ -27,25 +27,15 @@ if [ -z "$user" ]; then
exit 1
fi
-# choose the correct admin-password script (with or without the “s”)
-if [ -x /usr/local/vesta/bin/v-change-wp-admin-pass ]; then
- admin_pass_script="/usr/local/vesta/bin/v-change-wp-admin-pass"
-elif [ -x /usr/local/vesta/bin/v-change-wp-admins-pass ]; then
- admin_pass_script="/usr/local/vesta/bin/v-change-wp-admins-pass"
-else
- admin_pass_script=""
-fi
-
# absolute paths to maintenance scripts, in desired order
declare -a tasks=(
- "/usr/local/vesta/bin/v-change-db-password-to-wordpress"
- "/usr/local/vesta/bin/v-fix-wp-core"
+ "/usr/local/vesta/bin/v-change-database-password-for-wordpress"
+ "/usr/local/vesta/bin/v-change-wordpress-admins-pass"
+ "/usr/local/vesta/bin/v-fix-wordpress-core"
"/usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
+ "INTERACTIVE=1 /usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
)
-# append the admin script if we found one
-[ -n "$admin_pass_script" ] && tasks+=("$admin_pass_script")
-
# -------------------------------------------------------- #
# execution strategy #
# -------------------------------------------------------- #
diff --git a/bin/v-fix-user-permissions b/bin/v-fix-user-permissions
index e55b5e0f..991ada62 100644
--- a/bin/v-fix-user-permissions
+++ b/bin/v-fix-user-permissions
@@ -52,6 +52,7 @@ find /home/$user/conf/ -type d -exec chown root:root {} \;
find /home/$user/web/*/public_html/ -type d -exec chmod 755 {} +
find /home/$user/web/*/public_html/ -type f -exec chmod 644 {} +
find /home/$user/web/*/public_html/ -exec chown $user:$user {} \;
+find /home/$user/web/*/ -name "*.php" -type f -exec chmod 600 {} +
echo "Done, permissions fixed for user: $user"
diff --git a/bin/v-fix-website-permissions b/bin/v-fix-website-permissions
index a63954eb..c79fe443 100644
--- a/bin/v-fix-website-permissions
+++ b/bin/v-fix-website-permissions
@@ -18,7 +18,13 @@ source /etc/profile
# Argument definition
domain=$1
-user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
+# Check if number of arguments is 2
+if [ $# -eq 2 ]; then
+ user=$2
+else
+ user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
+fi
+USER=$user
# Includes
source /usr/local/vesta/func/main.sh
@@ -27,8 +33,6 @@ if [ -z "$user" ]; then
check_result $E_NOTEXIST "domain $domain doesn't exist"
fi
-USER=$user
-
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
@@ -54,14 +58,28 @@ fi
# Going to domain directory
cd /home/$USER/web/$domain
+# Ownership check
+if [ -f "public_html/index.php" ]; then
+ owner=$(stat -c '%U' "public_html/index.php")
+ if [ "$owner" = "root" ] || [ "$owner" = "www-data" ]; then
+ echo "Skipping permission fix for $domain, because v-lock-wordpress is used (index.php is owned by $owner)"
+ exit 1
+ fi
+fi
+
+
echo "Updating permissions for /home/$USER/web/$domain/public_html/"
find public_html/ -type d -exec chmod 755 {} +
find public_html/ -type f -exec chmod 644 {} +
chown -R $USER:$USER public_html/
+# Setting chmod 600 for all php files
+echo "= Setting chmod 600 for all php files"
+find -name "*.php" -type f -exec chmod 600 {} +
+
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
echo "Permissions for $domain have been successfully updated."
-exit
+exit 0
diff --git a/bin/v-fix-website-permissions-for-all-websites b/bin/v-fix-website-permissions-for-all-websites
new file mode 100644
index 00000000..9b1501bd
--- /dev/null
+++ b/bin/v-fix-website-permissions-for-all-websites
@@ -0,0 +1,41 @@
+#!/bin/bash
+# info: fix website permissions for all websites
+# options:
+#
+# The command is used for fixing website permissions for all websites on the server.
+
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+# Importing system variables
+source /etc/profile
+
+# Includes
+source $VESTA/func/main.sh
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
+ if [ ! -f "/usr/local/vesta/data/users/$user/user.conf" ]; then
+ continue;
+ fi
+
+ for domain in $(/usr/local/vesta/bin/v-list-web-domains $user plain |cut -f 1); do
+ /usr/local/vesta/bin/v-fix-website-permissions $domain $user
+ echo "--------------------------------"
+ done
+
+done
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$ARGUMENTS"
+
+exit
diff --git a/bin/v-fix-wp-core b/bin/v-fix-wordpress-core
similarity index 100%
rename from bin/v-fix-wp-core
rename to bin/v-fix-wordpress-core
diff --git a/bin/v-unlock-wordpress b/bin/v-unlock-wordpress
index 1e2cccc6..4a2c42c3 100644
--- a/bin/v-unlock-wordpress
+++ b/bin/v-unlock-wordpress
@@ -58,6 +58,8 @@ chown -R $user:$user public_html/
rm public_html/wp-content/uploads/.htaccess
+/usr/local/vesta/bin/v-fix-website-permissions $domain
+
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
From 97e5fc06772b9dec38f9989ac5eff7c91e5c6674 Mon Sep 17 00:00:00 2001
From: Peca
Date: Sat, 21 Jun 2025 17:26:32 +0200
Subject: [PATCH 244/304] v-change-database-password-for-all-wordpress: Using
existing password for $db_user
---
...change-database-password-for-all-wordpress | 5 +++++
bin/v-change-database-password-for-wordpress | 22 +++++++++++++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/bin/v-change-database-password-for-all-wordpress b/bin/v-change-database-password-for-all-wordpress
index ad922cc2..e129497c 100644
--- a/bin/v-change-database-password-for-all-wordpress
+++ b/bin/v-change-database-password-for-all-wordpress
@@ -19,6 +19,8 @@ source $VESTA/func/main.sh
# Action #
#----------------------------------------------------------#
+touch /root/remember-db-user-pass.txt
+
for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
if [ ! -f "/usr/local/vesta/data/users/$user/user.conf" ]; then
continue;
@@ -33,6 +35,9 @@ for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
done
+# cat /root/remember-db-user-pass.txt
+rm /root/remember-db-user-pass.txt
+
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
diff --git a/bin/v-change-database-password-for-wordpress b/bin/v-change-database-password-for-wordpress
index e318edde..dd7a3a91 100644
--- a/bin/v-change-database-password-for-wordpress
+++ b/bin/v-change-database-password-for-wordpress
@@ -69,10 +69,28 @@ if [ -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
chown $user:$user $wp_config_path
fi
db_name=$(grep "DB_NAME" $wp_config_path | grep -oP "define\s*\(\s*'DB_NAME'\s*,\s*'\K[^']+")
- new_password=$(generate_password)
+ db_user=$(grep "DB_USER" $wp_config_path | grep -oP "define\s*\(\s*'DB_USER'\s*,\s*'\K[^']+")
+ new_password=''
+ found_existing_password=0
+ if [ -f "/root/remember-db-user-pass.txt" ]; then
+ db_user_pass=$(grep "$db_user:" /root/remember-db-user-pass.txt)
+ if [ -n "$db_user_pass" ]; then
+ new_password=$(echo "$db_user_pass" | cut -d':' -f2)
+ echo "= Using existing password for $db_user"
+ found_existing_password=1
+ fi
+ fi
+
+ if [ -z "$new_password" ]; then
+ new_password=$(generate_password)
+ fi
+
echo "DB name: $db_name"
+ echo "DB user: $db_user"
echo "New DB password: $new_password"
- # echo "executing: /usr/local/vesta/bin/v-change-database-password \"$user\" \"$db_name\" \"$new_password\""
+ if [ $found_existing_password -eq 0 ] && [ -f "/root/remember-db-user-pass.txt" ]; then
+ echo "$db_user:$new_password" >> /root/remember-db-user-pass.txt
+ fi
/usr/local/vesta/bin/v-change-database-password "$user" "$db_name" "$new_password"
if [ $? -ne 0 ]; then
echo "*************** ERROR: Failed to change database password ***************"
From fd6eb44bae7fa3852f7465084a57a1d485fca533 Mon Sep 17 00:00:00 2001
From: Peca
Date: Sun, 22 Jun 2025 22:45:19 +0200
Subject: [PATCH 245/304] .gitignore: exclude data, conf, log
---
.gitignore | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.gitignore b/.gitignore
index 6701a887..fe0574ad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,6 @@
*.gz
.vscode
.DS_Store
+data
+conf
+log
\ No newline at end of file
From d37473b5e86b4f890b276d2d2f7df19e3e131a8c Mon Sep 17 00:00:00 2001
From: Peca
Date: Sun, 22 Jun 2025 23:53:53 +0200
Subject: [PATCH 246/304] Using v-wp-cli in v-change-wordpress-admin-passwords
---
...ins-pass => v-change-wordpress-admin-passwords} | 14 ++------------
bin/v-desinfect-wordpress | 2 +-
2 files changed, 3 insertions(+), 13 deletions(-)
rename bin/{v-change-wordpress-admins-pass => v-change-wordpress-admin-passwords} (89%)
diff --git a/bin/v-change-wordpress-admins-pass b/bin/v-change-wordpress-admin-passwords
similarity index 89%
rename from bin/v-change-wordpress-admins-pass
rename to bin/v-change-wordpress-admin-passwords
index 9028cd10..5a6a4e3f 100644
--- a/bin/v-change-wordpress-admins-pass
+++ b/bin/v-change-wordpress-admin-passwords
@@ -5,6 +5,7 @@
# d → delete user (with content reassignment)
# c → change password (random 10-char alnum)
# s → skip
+# x → exit
#----------------------------------------------------------#
# Variable & Function #
@@ -22,19 +23,8 @@ USER="$(/usr/local/vesta/bin/v-search-domain-owner "$DOMAIN")"
WP_PATH="/home/$USER/web/$DOMAIN/public_html"
[ ! -f "$WP_PATH/wp-config.php" ] && { echo "WordPress is not installed on this domain."; exit 1; }
-# ensure WP-CLI binary
-if ! command -v wp >/dev/null 2>&1; then
- echo "WP-CLI is not installed, installing..."
- wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
- chmod +x /usr/local/bin/wp
-fi
-
-PHPVER=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$DOMAIN")
-PHP_BIN=$(command -v "php$PHPVER" 2>/dev/null || command -v php)
-[ -z "$PHP_BIN" ] && { echo "Could not find a PHP binary."; exit 1; }
-
# WP-CLI wrapper
-WP_RUN=(sudo -u "$USER" "$PHP_BIN" /usr/local/bin/wp --skip-plugins --skip-themes)
+WP_RUN=(/usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes)
# random 10-char password
gen_pass() { tr -dc 'A-Za-z0-9'
Date: Mon, 23 Jun 2025 15:55:28 +0200
Subject: [PATCH 247/304] v-change-wordpress-admin-passwords: default = y
---
bin/v-change-wordpress-admin-passwords | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bin/v-change-wordpress-admin-passwords b/bin/v-change-wordpress-admin-passwords
index 5a6a4e3f..c51c9270 100644
--- a/bin/v-change-wordpress-admin-passwords
+++ b/bin/v-change-wordpress-admin-passwords
@@ -59,7 +59,7 @@ while IFS=',' read -r ID LOGIN EMAIL; do
read -r -p "Action for \"$TARGET\" [d/c/s/x]? " ACT < /dev/tty
case "$ACT" in
[Dd]* )
- read -r -p "Really DELETE \"$TARGET\" ? ('y' or ENTER for yes / 'n' for no) " CONF < /dev/tty
+ read -r -p "Really DELETE \"$TARGET\" ? (y/n, default: y) " CONF < /dev/tty
if [[ ! "$CONF" =~ ^[Nn]$ ]]; then
# build an array of OTHER admin usernames
mapfile -t OTHER_USERS < <(echo "$ADMIN_LIST_CSV" | awk -F',' -v cur="$ID" '$1!=cur {print $2}')
From 09465e5fba65dbff78f89cbc39991ff669c42983 Mon Sep 17 00:00:00 2001
From: Peca
Date: Mon, 23 Jun 2025 21:53:55 +0200
Subject: [PATCH 248/304] v-change-database-password-for-all-wordpress: first
optional argument to specify a $user
---
bin/v-change-database-password-for-all-wordpress | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/bin/v-change-database-password-for-all-wordpress b/bin/v-change-database-password-for-all-wordpress
index e129497c..2741e960 100644
--- a/bin/v-change-database-password-for-all-wordpress
+++ b/bin/v-change-database-password-for-all-wordpress
@@ -15,6 +15,11 @@ source /etc/profile
# Includes
source $VESTA/func/main.sh
+only_user='';
+if [ ! -z "$1" ]; then
+ only_user=$1
+fi
+
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
@@ -26,6 +31,12 @@ for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
continue;
fi
+ if [ ! -z "$only_user" ]; then
+ if [ "$only_user" != "$user" ]; then
+ continue;
+ fi
+ fi
+
for domain in $(/usr/local/vesta/bin/v-list-web-domains $user plain |cut -f 1); do
if [ -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
/usr/local/vesta/bin/v-change-database-password-for-wordpress $domain $user
@@ -33,6 +44,10 @@ for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
fi
done
+ if [ ! -z "$only_user" ]; then
+ break;
+ fi
+
done
# cat /root/remember-db-user-pass.txt
From f77f8e8b784e6a138d90a61cdbf7e7ea5f83eff3 Mon Sep 17 00:00:00 2001
From: Peca
Date: Tue, 24 Jun 2025 15:37:21 +0200
Subject: [PATCH 249/304] $SKIP_OWNERSHIP_CHECK in v-fix-website-permissions,
v-fix-wordpress-core
---
bin/v-fix-website-permissions | 2 +-
bin/v-fix-wordpress-core | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/bin/v-fix-website-permissions b/bin/v-fix-website-permissions
index c79fe443..0131b7c8 100644
--- a/bin/v-fix-website-permissions
+++ b/bin/v-fix-website-permissions
@@ -59,7 +59,7 @@ fi
cd /home/$USER/web/$domain
# Ownership check
-if [ -f "public_html/index.php" ]; then
+if [ -z "$SKIP_OWNERSHIP_CHECK" ] && [ -f "public_html/index.php" ]; then
owner=$(stat -c '%U' "public_html/index.php")
if [ "$owner" = "root" ] || [ "$owner" = "www-data" ]; then
echo "Skipping permission fix for $domain, because v-lock-wordpress is used (index.php is owned by $owner)"
diff --git a/bin/v-fix-wordpress-core b/bin/v-fix-wordpress-core
index 1dd87b71..2549017b 100644
--- a/bin/v-fix-wordpress-core
+++ b/bin/v-fix-wordpress-core
@@ -84,7 +84,7 @@ for f in "$SITE_PATH"/*.php; do
mv "$f" "$BACKUP_DIR/"
done
-chown -R www-data:www-data "$BACKUP_DIR"
+# chown -R www-data:www-data "$BACKUP_DIR"
check_result $? "backup failed" > /dev/null
echo "Old core folders moved to $BACKUP_DIR"
@@ -100,8 +100,8 @@ for corephp in "$CACHE_PATH"/*.php; do
done
# fix permissions
-/usr/local/vesta/bin/v-fix-website-permissions $DOMAIN
-chown -R www-data:www-data "$BACKUP_DIR"
+SKIP_OWNERSHIP_CHECK=1 /usr/local/vesta/bin/v-fix-website-permissions $DOMAIN
+# chown -R www-data:www-data "$BACKUP_DIR"
echo "Done, core WP files, wp-admin and wp-includes replaced for $DOMAIN"
exit
From 451c9944b90f4d48ffb10e9788e827f6dd768a0b Mon Sep 17 00:00:00 2001
From: Peca
Date: Wed, 25 Jun 2025 17:32:23 +0200
Subject: [PATCH 250/304] v-fix-wordpress-core: move .user.ini
---
bin/v-fix-wordpress-core | 3 +++
1 file changed, 3 insertions(+)
diff --git a/bin/v-fix-wordpress-core b/bin/v-fix-wordpress-core
index 2549017b..7a511747 100644
--- a/bin/v-fix-wordpress-core
+++ b/bin/v-fix-wordpress-core
@@ -83,6 +83,9 @@ for f in "$SITE_PATH"/*.php; do
[[ $(basename "$f") == "wp-config.php" ]] && continue
mv "$f" "$BACKUP_DIR/"
done
+if [ -f "$SITE_PATH/.user.ini" ]; then
+ mv "$SITE_PATH/.user.ini" "$BACKUP_DIR/"
+fi
# chown -R www-data:www-data "$BACKUP_DIR"
check_result $? "backup failed" > /dev/null
From e8b5b5a836662d2c07f2d0fc3cf704d585a504bc Mon Sep 17 00:00:00 2001
From: Peca
Date: Thu, 26 Jun 2025 18:05:11 +0200
Subject: [PATCH 251/304] v-update-document-errors-files
---
bin/v-update-document-errors-files | 48 ++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
create mode 100644 bin/v-update-document-errors-files
diff --git a/bin/v-update-document-errors-files b/bin/v-update-document-errors-files
new file mode 100644
index 00000000..c044a80a
--- /dev/null
+++ b/bin/v-update-document-errors-files
@@ -0,0 +1,48 @@
+#!/bin/bash
+# info: fix website permissions for all websites
+# options:
+#
+# The command is used for fixing website permissions for all websites on the server.
+
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+# Importing system variables
+source /etc/profile
+
+# Includes
+source $VESTA/func/main.sh
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
+ if [ ! -f "/usr/local/vesta/data/users/$user/user.conf" ]; then
+ continue;
+ fi
+
+ for domain in $(/usr/local/vesta/bin/v-list-web-domains $user plain |cut -f 1); do
+ cp /usr/local/vesta/data/templates/web/skel/document_errors/403.html /home/$user/web/$domain/document_errors/403.html
+ cp /usr/local/vesta/data/templates/web/skel/document_errors/404.html /home/$user/web/$domain/document_errors/404.html
+ cp /usr/local/vesta/data/templates/web/skel/document_errors/50x.html /home/$user/web/$domain/document_errors/50x.html
+ sed -i "s/%domain%/$domain/g" /home/$user/web/$domain/document_errors/403.html
+ sed -i "s/%domain%/$domain/g" /home/$user/web/$domain/document_errors/404.html
+ sed -i "s/%domain%/$domain/g" /home/$user/web/$domain/document_errors/50x.html
+ chown $user:$user /home/$user/web/$domain/document_errors/*
+ chmod 644 /home/$user/web/$domain/document_errors/*
+ done
+
+done
+
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$ARGUMENTS"
+
+exit
From 6cce5ecadda43c4ac94a1a094ed67111ff8fde0d Mon Sep 17 00:00:00 2001
From: Peca
Date: Thu, 26 Jun 2025 22:26:14 +0200
Subject: [PATCH 252/304] chmod .env files to 600
---
bin/v-fix-website-permissions | 1 +
1 file changed, 1 insertion(+)
diff --git a/bin/v-fix-website-permissions b/bin/v-fix-website-permissions
index 0131b7c8..7dd36a62 100644
--- a/bin/v-fix-website-permissions
+++ b/bin/v-fix-website-permissions
@@ -76,6 +76,7 @@ chown -R $USER:$USER public_html/
# Setting chmod 600 for all php files
echo "= Setting chmod 600 for all php files"
find -name "*.php" -type f -exec chmod 600 {} +
+find -name ".env" -type f -exec chmod 600 {} +
#----------------------------------------------------------#
# Vesta #
From 1567383b4923b9f2ac567223e5ccfdd9e2f996a8 Mon Sep 17 00:00:00 2001
From: Peca
Date: Sat, 28 Jun 2025 16:49:18 +0200
Subject: [PATCH 253/304] v-run-wp-cli: Parameter 'PHP' to force specified PHP
version
---
bin/v-run-wp-cli | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/bin/v-run-wp-cli b/bin/v-run-wp-cli
index 1a0e2adc..d03afc6a 100644
--- a/bin/v-run-wp-cli
+++ b/bin/v-run-wp-cli
@@ -69,7 +69,11 @@ fi
mkdir -p /home/$user/.wp-cli
chown $user:$user /home/$user/.wp-cli
-phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$domain")
+if [ -z "$PHP" ]; then
+ phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$domain")
+else
+ phpver=$PHP
+fi
#----------------------------------------------------------#
# Action #
From 2fd60fc29d7ca08dc0bbe03b8b09e1ed0053e972 Mon Sep 17 00:00:00 2001
From: Peca
Date: Sun, 29 Jun 2025 17:16:50 +0200
Subject: [PATCH 254/304] VERBOSE_MODE in v-run-wp-cli
---
bin/v-run-wp-cli | 3 +++
func/main.sh | 3 +++
2 files changed, 6 insertions(+)
diff --git a/bin/v-run-wp-cli b/bin/v-run-wp-cli
index d03afc6a..ef4f6e10 100644
--- a/bin/v-run-wp-cli
+++ b/bin/v-run-wp-cli
@@ -36,10 +36,13 @@ fi
# Verifications #
#----------------------------------------------------------#
+VERBOSE_MODE=1
+
check_args '2' "$#" 'DOMAIN WP_CLI_COMMAND'
is_format_valid 'domain'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
+is_object_unsuspended 'web' 'DOMAIN' "$domain"
if [ ! -d "/home/$user" ]; then
# echo "User doesn't exist";
diff --git a/func/main.sh b/func/main.sh
index 03773920..27c4dcbe 100644
--- a/func/main.sh
+++ b/func/main.sh
@@ -254,6 +254,9 @@ is_object_unsuspended() {
spnd=$(grep "$2='$3'" $USER_DATA/$1.conf |grep "SUSPENDED='yes'")
fi
if [ ! -z "$spnd" ]; then
+ if [ ! -z "$VERBOSE_MODE" ]; then
+ echo "Error: $(basename $1) $3 is suspended"
+ fi
check_result $E_SUSPENDED "$(basename $1) $3 is suspended"
fi
}
From b8b75f0dde93a0304b6306c83664f97a33a3771d Mon Sep 17 00:00:00 2001
From: Peca
Date: Sun, 29 Jun 2025 00:59:18 +0200
Subject: [PATCH 255/304] v-change-wordpress-admin-passwords
---
bin/v-change-wordpress-admin-passwords | 46 ++++++++++++++++++++++----
1 file changed, 39 insertions(+), 7 deletions(-)
diff --git a/bin/v-change-wordpress-admin-passwords b/bin/v-change-wordpress-admin-passwords
index c51c9270..89122a2d 100644
--- a/bin/v-change-wordpress-admin-passwords
+++ b/bin/v-change-wordpress-admin-passwords
@@ -25,6 +25,13 @@ WP_PATH="/home/$USER/web/$DOMAIN/public_html"
# WP-CLI wrapper
WP_RUN=(/usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes)
+return_code=$?
+
+if [ $return_code -ne 0 ]; then
+ echo "WP-CLI error:"
+ cat /home/$USER/web/$DOMAIN/wp-cli-error.log
+ exit $return_code
+fi
# random 10-char password
gen_pass() { tr -dc 'A-Za-z0-9' /dev/null | tail -n +2)
+ --format=csv --skip-plugins --skip-themes 2>/dev/null | tail -n +2)
[ -z "$ADMIN_LIST_CSV" ] && { echo "No administrator accounts found."; exit 0; }
printf "%-6s %-20s %s\n" "ID" "Username" "Email"
@@ -59,7 +70,8 @@ while IFS=',' read -r ID LOGIN EMAIL; do
read -r -p "Action for \"$TARGET\" [d/c/s/x]? " ACT < /dev/tty
case "$ACT" in
[Dd]* )
- read -r -p "Really DELETE \"$TARGET\" ? (y/n, default: y) " CONF < /dev/tty
+ # read -r -p "Really DELETE \"$TARGET\" ? (y/n, default: y) " CONF < /dev/tty
+ CONF="y"
if [[ ! "$CONF" =~ ^[Nn]$ ]]; then
# build an array of OTHER admin usernames
mapfile -t OTHER_USERS < <(echo "$ADMIN_LIST_CSV" | awk -F',' -v cur="$ID" '$1!=cur {print $2}')
@@ -70,7 +82,7 @@ while IFS=',' read -r ID LOGIN EMAIL; do
DEFAULT_USER="${OTHER_USERS[0]}"
echo "Available admin usernames for reassignment: ${OTHER_USERS[*]}"
while true; do
- read -r -p "Reassign content to which username? [default $DEFAULT_USER] " REASSIGN < /dev/tty
+ read -r -p "Reassign content to which username? [default: $DEFAULT_USER] " REASSIGN < /dev/tty
REASSIGN=${REASSIGN:-$DEFAULT_USER}
if printf '%s\n' "${OTHER_USERS[@]}" | grep -qx "$REASSIGN"; then
break
@@ -79,8 +91,13 @@ while IFS=',' read -r ID LOGIN EMAIL; do
fi
done
# delete by username, reassign by username
- "${WP_RUN[@]}" user delete "$LOGIN" --reassign="$REASSIGN" --yes >/dev/null 2>&1
- echo "$TARGET deleted (content reassigned to $REASSIGN)."
+ "${WP_RUN[@]}" user delete "$LOGIN" --reassign="$REASSIGN" --yes --skip-plugins --skip-themes
+ if [ $? -eq 0 ]; then
+ echo "$TARGET deleted (content reassigned to $REASSIGN)."
+ else
+ cat /home/$USER/web/$DOMAIN/wp-cli-error.log
+ echo "Failed to delete $TARGET."
+ fi
else
echo "Deletion cancelled."
fi
@@ -88,9 +105,14 @@ while IFS=',' read -r ID LOGIN EMAIL; do
;;
[Cc]* )
NEW_PASS=$(gen_pass)
- if "${WP_RUN[@]}" user update "$LOGIN" --user_pass="$NEW_PASS" --quiet; then
- echo "Password for $TARGET changed to: $NEW_PASS"
+ "${WP_RUN[@]}" user update "$LOGIN" --user_pass="$NEW_PASS" --skip-plugins --skip-themes
+ if [ $? -eq 0 ]; then
+ echo "Password for username '$TARGET' changed to: $NEW_PASS"
+ echo "Password for username '$TARGET' changed to: $NEW_PASS" >> /home/$USER/web/$DOMAIN/wp-admin-password-change.txt
+ chown $USER:$USER /home/$USER/web/$DOMAIN/wp-admin-password-change.txt
+ chmod 600 /home/$USER/web/$DOMAIN/wp-admin-password-change.txt
else
+ cat /home/$USER/web/$DOMAIN/wp-cli-error.log
echo "Failed to change password for $TARGET."
fi
break
@@ -125,4 +147,14 @@ echo "Cache flushed and salts refreshed."
echo
echo "Done."
+if [ -f /home/$USER/web/$DOMAIN/wp-admin-password-change.txt ]; then
+ echo "-------------------------------------"
+ echo "For website $DOMAIN - new wp-admin passwords have been set."
+ echo "-------------------------------------"
+ cat /home/$USER/web/$DOMAIN/wp-admin-password-change.txt
+ echo "-------------------------------------"
+ echo ""
+ read -r -p "== Press Enter to continue..."
+fi
+
exit 0
From d20bc94866c2891ff96e669cc9143f9972a9a196 Mon Sep 17 00:00:00 2001
From: Peca
Date: Tue, 1 Jul 2025 10:03:32 +0200
Subject: [PATCH 256/304] v-fix-website-permissions: chown for .php and .env
files
---
bin/v-fix-website-permissions | 2 ++
1 file changed, 2 insertions(+)
diff --git a/bin/v-fix-website-permissions b/bin/v-fix-website-permissions
index 7dd36a62..3a73d13a 100644
--- a/bin/v-fix-website-permissions
+++ b/bin/v-fix-website-permissions
@@ -77,6 +77,8 @@ chown -R $USER:$USER public_html/
echo "= Setting chmod 600 for all php files"
find -name "*.php" -type f -exec chmod 600 {} +
find -name ".env" -type f -exec chmod 600 {} +
+find -name "*.php" -type f -exec chown $USER:$USER {} +
+find -name ".env" -type f -exec chown $USER:$USER {} +
#----------------------------------------------------------#
# Vesta #
From 54abc58c4e96c45173554dc351e94f8f11c8796d Mon Sep 17 00:00:00 2001
From: Peca
Date: Thu, 10 Jul 2025 17:49:15 +0200
Subject: [PATCH 257/304] v-change-wordpress-admin-passwords: accept integer as
id of user, support for custom php version
---
bin/v-change-wordpress-admin-passwords | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/bin/v-change-wordpress-admin-passwords b/bin/v-change-wordpress-admin-passwords
index 89122a2d..c81cbfcb 100644
--- a/bin/v-change-wordpress-admin-passwords
+++ b/bin/v-change-wordpress-admin-passwords
@@ -24,7 +24,12 @@ WP_PATH="/home/$USER/web/$DOMAIN/public_html"
[ ! -f "$WP_PATH/wp-config.php" ] && { echo "WordPress is not installed on this domain."; exit 1; }
# WP-CLI wrapper
-WP_RUN=(/usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes)
+if [ ! -z "$PHP" ]; then
+ WP_RUN=(PHP=$PHP /usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes)
+else
+ WP_RUN=(/usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes)
+fi
+
return_code=$?
if [ $return_code -ne 0 ]; then
@@ -86,9 +91,11 @@ while IFS=',' read -r ID LOGIN EMAIL; do
REASSIGN=${REASSIGN:-$DEFAULT_USER}
if printf '%s\n' "${OTHER_USERS[@]}" | grep -qx "$REASSIGN"; then
break
- else
- echo "Invalid username. Please choose one of: ${OTHER_USERS[*]}"
fi
+ if [[ "$REASSIGN" =~ ^[0-9]+$ ]]; then
+ break
+ fi
+ echo "Invalid username. Please choose one of: ${OTHER_USERS[*]}"
done
# delete by username, reassign by username
"${WP_RUN[@]}" user delete "$LOGIN" --reassign="$REASSIGN" --yes --skip-plugins --skip-themes
From acc87125f09083b5d171a5c9f7505a3c5b9a6b00 Mon Sep 17 00:00:00 2001
From: Peca
Date: Fri, 11 Jul 2025 10:34:38 +0200
Subject: [PATCH 258/304] v-change-wordpress-admin-passwords: ability to run
v-run-wp-cli on choosen PHP version
---
bin/v-change-wordpress-admin-passwords | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/bin/v-change-wordpress-admin-passwords b/bin/v-change-wordpress-admin-passwords
index c81cbfcb..1802bd9f 100644
--- a/bin/v-change-wordpress-admin-passwords
+++ b/bin/v-change-wordpress-admin-passwords
@@ -25,9 +25,9 @@ WP_PATH="/home/$USER/web/$DOMAIN/public_html"
# WP-CLI wrapper
if [ ! -z "$PHP" ]; then
- WP_RUN=(PHP=$PHP /usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes)
+ WP_RUN="PHP=$PHP /usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes"
else
- WP_RUN=(/usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes)
+ WP_RUN="/usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes"
fi
return_code=$?
@@ -54,9 +54,9 @@ if [ -f /home/$USER/web/$DOMAIN/wp-admin-password-change.txt ]; then
rm /home/$USER/web/$DOMAIN/wp-admin-password-change.txt
fi
-ADMIN_LIST_CSV=$("${WP_RUN[@]}" user list --role=administrator \
- --fields=ID,user_login,user_email \
- --format=csv --skip-plugins --skip-themes 2>/dev/null | tail -n +2)
+RUN="$WP_RUN user list --role=administrator --fields=ID,user_login,user_email --format=csv --skip-plugins --skip-themes 2>/dev/null | tail -n +2"
+ADMIN_LIST_CSV=$(eval "$RUN")
+
[ -z "$ADMIN_LIST_CSV" ] && { echo "No administrator accounts found."; exit 0; }
printf "%-6s %-20s %s\n" "ID" "Username" "Email"
@@ -98,7 +98,8 @@ while IFS=',' read -r ID LOGIN EMAIL; do
echo "Invalid username. Please choose one of: ${OTHER_USERS[*]}"
done
# delete by username, reassign by username
- "${WP_RUN[@]}" user delete "$LOGIN" --reassign="$REASSIGN" --yes --skip-plugins --skip-themes
+ RUN="$WP_RUN user delete $LOGIN --reassign=$REASSIGN --yes --skip-plugins --skip-themes"
+ eval "$RUN"
if [ $? -eq 0 ]; then
echo "$TARGET deleted (content reassigned to $REASSIGN)."
else
@@ -112,7 +113,8 @@ while IFS=',' read -r ID LOGIN EMAIL; do
;;
[Cc]* )
NEW_PASS=$(gen_pass)
- "${WP_RUN[@]}" user update "$LOGIN" --user_pass="$NEW_PASS" --skip-plugins --skip-themes
+ RUN="$WP_RUN user update $LOGIN --user_pass=$NEW_PASS --skip-plugins --skip-themes"
+ eval "$RUN"
if [ $? -eq 0 ]; then
echo "Password for username '$TARGET' changed to: $NEW_PASS"
echo "Password for username '$TARGET' changed to: $NEW_PASS" >> /home/$USER/web/$DOMAIN/wp-admin-password-change.txt
@@ -145,9 +147,12 @@ echo "-------------------------------------"
echo
echo "Flushing cache and refreshing salts..."
-"${WP_RUN[@]}" cache flush
-"${WP_RUN[@]}" config shuffle-salts WP_CACHE_KEY_SALT --force
-"${WP_RUN[@]}" config shuffle-salts
+RUN="$WP_RUN cache flush"
+eval "$RUN"
+RUN="$WP_RUN config shuffle-salts WP_CACHE_KEY_SALT --force"
+eval "$RUN"
+RUN="$WP_RUN config shuffle-salts"
+eval "$RUN"
echo "Cache flushed and salts refreshed."
From 420a978572585868477bd6a32f6b2ccb64ea21dc Mon Sep 17 00:00:00 2001
From: Peca
Date: Fri, 11 Jul 2025 11:41:28 +0200
Subject: [PATCH 259/304] v-install-wordpress: Support for IDN format domains
---
bin/v-install-wordpress | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/bin/v-install-wordpress b/bin/v-install-wordpress
index 202919d0..3f21d172 100644
--- a/bin/v-install-wordpress
+++ b/bin/v-install-wordpress
@@ -57,8 +57,17 @@ if [ -z "$database" ]; then
fi
fi
+# Convert domain to IDN if available
+if command -v idn2 >/dev/null 2>&1; then
+ database=$(idn2 "$database")
+ idn_domain=$(idn2 "$domain")
+elif command -v idn >/dev/null 2>&1; then
+ database=$(idn "$database")
+ idn_domain=$(idn "$domain")
+fi
+
if [ -z "$email" ]; then
- email="info@$domain";
+ email="info@$idn_domain";
fi
if [ ! -d "/home/$user" ]; then
From bf54a85a51fd391b8d17b1483ff54bd9dab1dbf4 Mon Sep 17 00:00:00 2001
From: Peca
Date: Fri, 11 Jul 2025 16:37:09 +0200
Subject: [PATCH 260/304] Added functions to check if a domain or user is
unsuspended in main.sh
---
func/main.sh | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/func/main.sh b/func/main.sh
index 27c4dcbe..4dfc087b 100644
--- a/func/main.sh
+++ b/func/main.sh
@@ -1236,3 +1236,26 @@ parse_object_kv_list_non_eval() {
fi
done
}
+
+# Return OK (0) if domain is unsupended
+# Parameters:
+# $1 - user
+# $2 - domain
+return_ok_if_domain_is_unsuspended() {
+ spnd=$(grep "DOMAIN='$2'" /usr/local/vesta/data/users/$1/web.conf | grep "SUSPENDED='yes'")
+ if [ ! -z "$spnd" ]; then
+ return $E_SUSPENDED
+ fi
+ return $OK
+}
+
+# Return OK (0) if user is unsupended
+# Parameters:
+# $1 - user
+return_ok_if_user_is_unsuspended() {
+ spnd=$(cat /usr/local/vesta/data/users/$1/user.conf | grep "SUSPENDED='yes'")
+ if [ ! -z "$spnd" ]; then
+ return $E_SUSPENDED
+ fi
+ return $OK
+}
From cdf10aede168cde0e17e7f418855dc8c751497e1 Mon Sep 17 00:00:00 2001
From: Peca
Date: Sat, 12 Jul 2025 14:07:08 +0200
Subject: [PATCH 261/304] v-change-wordpress-admin-passwords: enhance admin
reassignment logic to handle default user selection
---
bin/v-change-wordpress-admin-passwords | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/bin/v-change-wordpress-admin-passwords b/bin/v-change-wordpress-admin-passwords
index 1802bd9f..591ff27c 100644
--- a/bin/v-change-wordpress-admin-passwords
+++ b/bin/v-change-wordpress-admin-passwords
@@ -59,9 +59,14 @@ ADMIN_LIST_CSV=$(eval "$RUN")
[ -z "$ADMIN_LIST_CSV" ] && { echo "No administrator accounts found."; exit 0; }
+DEFAULT_USER=""
+
printf "%-6s %-20s %s\n" "ID" "Username" "Email"
echo "$ADMIN_LIST_CSV" | while IFS=',' read -r PID PLOGIN PEMAIL; do
printf "%-6s %-20s %s\n" "$PID" "$PLOGIN" "$PEMAIL"
+ if [ "$PID" = "1" ]; then
+ DEFAULT_USER="$PLOGIN"
+ fi
done
echo
@@ -84,11 +89,14 @@ while IFS=',' read -r ID LOGIN EMAIL; do
echo "Cannot delete the only administrator account."
break
fi
- DEFAULT_USER="${OTHER_USERS[0]}"
+ if [ "$DEFAULT_USER" = "" ]; then
+ DEFAULT_USER="${OTHER_USERS[0]}"
+ fi
echo "Available admin usernames for reassignment: ${OTHER_USERS[*]}"
while true; do
read -r -p "Reassign content to which username? [default: $DEFAULT_USER] " REASSIGN < /dev/tty
REASSIGN=${REASSIGN:-$DEFAULT_USER}
+ DEFAULT_USER=$REASSIGN
if printf '%s\n' "${OTHER_USERS[@]}" | grep -qx "$REASSIGN"; then
break
fi
From aa6263c0ac49f9fbfabc383d375acada9c834240 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luka=20Paunovi=C4=87?=
Date: Sun, 13 Jul 2025 00:25:07 +0200
Subject: [PATCH 262/304] Create wprocket-webp-express-force-https.stpl
WEBP Express NGINX support with Rocket-NGINX
---
.../wprocket-webp-express-force-https.stpl | 72 +++++++++++++++++++
1 file changed, 72 insertions(+)
create mode 100644 src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.stpl
diff --git a/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.stpl b/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.stpl
new file mode 100644
index 00000000..0d3eca17
--- /dev/null
+++ b/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.stpl
@@ -0,0 +1,72 @@
+server {
+ listen %ip%:%proxy_ssl_port% ssl http2;
+ server_name %domain_idn% %alias_idn%;
+
+ ssl_certificate %ssl_pem%;
+ ssl_certificate_key %ssl_key%;
+ error_log /var/log/%web_system%/domains/%domain%.error.log error;
+
+ root %sdocroot%;
+ # Rocket-Nginx configuration
+ include rocket-nginx/conf.d/default.conf;
+
+ # Serve WebP if browser supports it
+ location ~* ^/wp-content/.*\.(png|jpe?g)$ {
+ add_header Vary Accept;
+ expires 365d;
+
+ if ($http_accept !~* "webp") {
+ break;
+ }
+
+ try_files
+ /wp-content/webp-express/webp-images/doc-root/$uri.webp
+ $uri.webp
+ @webp_on_demand;
+ }
+
+ # Route .webp requests to converter if not found
+ location @webp_on_demand {
+ proxy_pass https://%ip%:%web_ssl_port%;
+ }
+
+ # Allow .webp passthrough (trigger php fallback if not found)
+ location ~* ^/wp-content/.*\.(png|jpe?g)\.webp$ {
+ try_files
+ $uri
+ @webp_realizer;
+ }
+
+ location @webp_realizer {
+ proxy_pass https://%ip%:%web_ssl_port%;
+ }
+
+ # Allow PHP access to WebP Express WOD handler
+ location ~ ^/wp-content/plugins/webp-express/wod/.*\.php$ {
+ proxy_pass https://148.113.209.199:8443;
+ }
+
+ location / {
+ proxy_pass https://%ip%:%web_ssl_port%;
+ }
+
+ location /error/ {
+ alias %home%/%user%/web/%domain%/document_errors/;
+ }
+
+ location @fallback {
+ proxy_pass https://%ip%:%web_ssl_port%;
+ }
+
+ location ~ /\.ht {return 404;}
+ location ~ /\.env {return 404;}
+ location ~ /\.svn/ {return 404;}
+ location ~ /\.git/ {return 404;}
+ location ~ /\.hg/ {return 404;}
+ location ~ /\.bzr/ {return 404;}
+
+ disable_symlinks if_not_owner from=%docroot%;
+
+ include %home%/%user%/conf/web/*nginx.%domain_idn%.conf_letsencrypt;
+ include %home%/%user%/conf/web/s%proxy_system%.%domain%.conf*;
+}
From 59db959b9a0670575f13dfb11eb8d9ebe07f3dfe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luka=20Paunovi=C4=87?=
Date: Sun, 13 Jul 2025 00:26:08 +0200
Subject: [PATCH 263/304] Update wprocket-webp-express-force-https.stpl
---
.../wprocket-webp-express-force-https.stpl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.stpl b/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.stpl
index 0d3eca17..d504a6a1 100644
--- a/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.stpl
+++ b/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.stpl
@@ -43,7 +43,7 @@ server {
# Allow PHP access to WebP Express WOD handler
location ~ ^/wp-content/plugins/webp-express/wod/.*\.php$ {
- proxy_pass https://148.113.209.199:8443;
+ proxy_pass https://%ip%:%web_ssl_port%;
}
location / {
From 7511baa62863537d4f75d60712fbe1800dcb8b57 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luka=20Paunovi=C4=87?=
Date: Sun, 13 Jul 2025 00:27:04 +0200
Subject: [PATCH 264/304] Create wprocket-webp-express-force-https.tpl
---
.../wprocket-webp-express-force-https.tpl | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.tpl
diff --git a/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.tpl b/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.tpl
new file mode 100644
index 00000000..5a463370
--- /dev/null
+++ b/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.tpl
@@ -0,0 +1,8 @@
+server {
+ listen %ip%:%proxy_port%;
+ server_name %domain_idn% %alias_idn%;
+ location / {
+ rewrite ^(.*) https://$host$1 permanent;
+ }
+include %home%/%user%/conf/web/*nginx.%domain_idn%.conf_letsencrypt;
+}
From a48621a88ec17c38753380276f63d829ed1ddc02 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luka=20Paunovi=C4=87?=
Date: Sun, 13 Jul 2025 19:00:48 +0200
Subject: [PATCH 265/304] Update wprocket-webp-express-force-https.stpl
rocket include must go bellow webp rules
---
.../wprocket-webp-express-force-https.stpl | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.stpl b/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.stpl
index d504a6a1..2a6a7671 100644
--- a/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.stpl
+++ b/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.stpl
@@ -7,8 +7,6 @@ server {
error_log /var/log/%web_system%/domains/%domain%.error.log error;
root %sdocroot%;
- # Rocket-Nginx configuration
- include rocket-nginx/conf.d/default.conf;
# Serve WebP if browser supports it
location ~* ^/wp-content/.*\.(png|jpe?g)$ {
@@ -45,7 +43,10 @@ server {
location ~ ^/wp-content/plugins/webp-express/wod/.*\.php$ {
proxy_pass https://%ip%:%web_ssl_port%;
}
-
+
+ # Rocket-Nginx configuration
+ include rocket-nginx/conf.d/default.conf;
+
location / {
proxy_pass https://%ip%:%web_ssl_port%;
}
From 29236cfb03b050df39bce02f8a113e3529d5fd3d Mon Sep 17 00:00:00 2001
From: Peca
Date: Sun, 13 Jul 2025 22:16:46 +0200
Subject: [PATCH 266/304] Enhance proxy template selection in
v-activate-rocket-nginx to include wprocket-webp-express-force-https option
and update install script to download corresponding templates.
---
bin/v-activate-rocket-nginx | 12 +++++++-----
src/deb/for-download/tools/install-rocket-nginx.sh | 2 ++
.../wprocket-webp-express-force-https.tpl | 8 ++++++++
3 files changed, 17 insertions(+), 5 deletions(-)
create mode 100644 src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.tpl
diff --git a/bin/v-activate-rocket-nginx b/bin/v-activate-rocket-nginx
index de8f6c5f..8b562c9b 100644
--- a/bin/v-activate-rocket-nginx
+++ b/bin/v-activate-rocket-nginx
@@ -75,18 +75,20 @@ fi
# Changing Proxy Template
# Check if the proxy template is already set correctly
current_template=$(/usr/local/vesta/bin/v-list-web-domain $user $domain | grep 'PROXY:' | awk '{print $2}')
-if [ "$current_template" == "wprocket-force-https" ] || [ "$current_template" == "wprocket-hosting" ]; then
+if [ "$current_template" == "wprocket-force-https" ] || [ "$current_template" == "wprocket-hosting" ] || [ "$current_template" == "wprocket-webp-express-force-https" ]; then
echo "Proxy Template is already set up correctly"
else
# Prompt the user to choose whether to force HTTPS or not
- echo "Do you want to force-https in your Proxy Template or not (y/n):"
+ echo "Do you want to use wprocket-hosting template, wprocket-force-https template or wprocket-webp-express-force-https template (h/f/w):"
read answer
# Change the proxy template based on the user's choice
- if [ "$answer" == "y" ]; then
- /usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" "wprocket-force-https"
- else
+ if [ "$answer" == "h" ]; then
/usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" "wprocket-hosting"
+ elif [ "$answer" == "f" ]; then
+ /usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" "wprocket-force-https"
+ elif [ "$answer" == "w" ]; then
+ /usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" "wprocket-webp-express-force-https"
fi
echo "Proxy Template is ready"
diff --git a/src/deb/for-download/tools/install-rocket-nginx.sh b/src/deb/for-download/tools/install-rocket-nginx.sh
index 47768b11..ca1f8b2a 100644
--- a/src/deb/for-download/tools/install-rocket-nginx.sh
+++ b/src/deb/for-download/tools/install-rocket-nginx.sh
@@ -4,6 +4,8 @@ wget -nv -O /usr/local/vesta/data/templates/web/nginx/wprocket-force-https.tpl h
wget -nv -O /usr/local/vesta/data/templates/web/nginx/wprocket-force-https.stpl https://c.myvestacp.com/tools/rocket-nginx-templates/wprocket-force-https.stpl
wget -nv -O /usr/local/vesta/data/templates/web/nginx/wprocket-hosting.tpl https://c.myvestacp.com/tools/rocket-nginx-templates/wprocket-hosting.tpl
wget -nv -O /usr/local/vesta/data/templates/web/nginx/wprocket-hosting.stpl https://c.myvestacp.com/tools/rocket-nginx-templates/wprocket-hosting.stpl
+wget -nv -O /usr/local/vesta/data/templates/web/nginx/wprocket-webp-express-force-https.tpl https://c.myvestacp.com/tools/rocket-nginx-templates/wprocket-webp-express-force-https.tpl
+wget -nv -O /usr/local/vesta/data/templates/web/nginx/wprocket-webp-express-force-https.stpl https://c.myvestacp.com/tools/rocket-nginx-templates/wprocket-webp-express-force-https.stpl
echo "Updating apt, please wait..."
apt-get update > /dev/null 2>&1
diff --git a/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.tpl b/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.tpl
new file mode 100644
index 00000000..5a463370
--- /dev/null
+++ b/src/deb/for-download/tools/rocket-nginx-templates/wprocket-webp-express-force-https.tpl
@@ -0,0 +1,8 @@
+server {
+ listen %ip%:%proxy_port%;
+ server_name %domain_idn% %alias_idn%;
+ location / {
+ rewrite ^(.*) https://$host$1 permanent;
+ }
+include %home%/%user%/conf/web/*nginx.%domain_idn%.conf_letsencrypt;
+}
From 98600537fc54e76f67633a4bb9ec8fcb952d173c Mon Sep 17 00:00:00 2001
From: Peca
Date: Mon, 14 Jul 2025 16:32:21 +0200
Subject: [PATCH 267/304] v-change-wordpress-admin-passwords: modified user
deletion and password update commands to use user ID instead of username.
---
bin/v-add-wordpress-admin | 5 +++++
bin/v-change-wordpress-admin-passwords | 16 ++++++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/bin/v-add-wordpress-admin b/bin/v-add-wordpress-admin
index 3814e51a..67f58bf4 100644
--- a/bin/v-add-wordpress-admin
+++ b/bin/v-add-wordpress-admin
@@ -12,6 +12,11 @@ if [ "$whoami" != "root" ]; then
exit 1
fi
+if [ "$#" -lt 4 ]; then
+ echo "Usage: v-add-wordpress-admin [DOMAIN] [USERNAME] [PASSWORD] [EMAIL]"
+ exit 1
+fi
+
# Importing system environment
source /etc/profile
diff --git a/bin/v-change-wordpress-admin-passwords b/bin/v-change-wordpress-admin-passwords
index 591ff27c..ba3dec2b 100644
--- a/bin/v-change-wordpress-admin-passwords
+++ b/bin/v-change-wordpress-admin-passwords
@@ -106,7 +106,7 @@ while IFS=',' read -r ID LOGIN EMAIL; do
echo "Invalid username. Please choose one of: ${OTHER_USERS[*]}"
done
# delete by username, reassign by username
- RUN="$WP_RUN user delete $LOGIN --reassign=$REASSIGN --yes --skip-plugins --skip-themes"
+ RUN="$WP_RUN user delete $ID --reassign=$REASSIGN --yes --skip-plugins --skip-themes"
eval "$RUN"
if [ $? -eq 0 ]; then
echo "$TARGET deleted (content reassigned to $REASSIGN)."
@@ -121,7 +121,7 @@ while IFS=',' read -r ID LOGIN EMAIL; do
;;
[Cc]* )
NEW_PASS=$(gen_pass)
- RUN="$WP_RUN user update $LOGIN --user_pass=$NEW_PASS --skip-plugins --skip-themes"
+ RUN="$WP_RUN user update $ID --user_pass=$NEW_PASS --skip-plugins --skip-themes"
eval "$RUN"
if [ $? -eq 0 ]; then
echo "Password for username '$TARGET' changed to: $NEW_PASS"
@@ -147,6 +147,18 @@ while IFS=',' read -r ID LOGIN EMAIL; do
done
done <<< "$ADMIN_LIST_CSV"
+if [ -f /home/$USER/web/$DOMAIN/wp-admin-password-change.txt ]; then
+ echo "-------------------------------------"
+ echo
+ read -r -p "Do you want to save the new passwords to a file /home/$USER/web/$DOMAIN/wp-admin-password-change.txt ? (y/n, default: n) " SAVE_PASSWORDS < /dev/tty
+ if [ -z "$SAVE_PASSWORDS" ]; then
+ SAVE_PASSWORDS="n"
+ fi
+ if [[ $SAVE_PASSWORDS =~ ^[Nn]$ ]]; then
+ rm /home/$USER/web/$DOMAIN/wp-admin-password-change.txt
+ fi
+fi
+
#----------------------------------------------------------#
# flush cache and refresh all security salts #
#----------------------------------------------------------#
From 1571d60b2f96c99bc386ee102b9599b6c98da87e Mon Sep 17 00:00:00 2001
From: Peca
Date: Mon, 14 Jul 2025 17:16:25 +0200
Subject: [PATCH 268/304] Update v-fix-website-permissions to allow dynamic php
file permissions based on user-defined settings
---
bin/v-fix-website-permissions | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/bin/v-fix-website-permissions b/bin/v-fix-website-permissions
index 3a73d13a..4b92df2f 100644
--- a/bin/v-fix-website-permissions
+++ b/bin/v-fix-website-permissions
@@ -73,10 +73,15 @@ find public_html/ -type d -exec chmod 755 {} +
find public_html/ -type f -exec chmod 644 {} +
chown -R $USER:$USER public_html/
+php_chmod="600"
+if [ -f "/home/$USER/web/$domain/php_chmod" ]; then
+ php_chmod=$(cat /home/$USER/web/$domain/php_chmod)
+fi
+
# Setting chmod 600 for all php files
echo "= Setting chmod 600 for all php files"
-find -name "*.php" -type f -exec chmod 600 {} +
-find -name ".env" -type f -exec chmod 600 {} +
+find -name "*.php" -type f -exec chmod $php_chmod {} +
+find -name ".env" -type f -exec chmod $php_chmod {} +
find -name "*.php" -type f -exec chown $USER:$USER {} +
find -name ".env" -type f -exec chown $USER:$USER {} +
From ca9a93982343928a696f54db2d9713348a42e04e Mon Sep 17 00:00:00 2001
From: Peca
Date: Mon, 14 Jul 2025 18:17:43 +0200
Subject: [PATCH 269/304] Refactor v-change-wordpress-admin-passwords to
streamline admin list processing by using a here-string for input
---
bin/v-change-wordpress-admin-passwords | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bin/v-change-wordpress-admin-passwords b/bin/v-change-wordpress-admin-passwords
index ba3dec2b..7c4fabdb 100644
--- a/bin/v-change-wordpress-admin-passwords
+++ b/bin/v-change-wordpress-admin-passwords
@@ -62,12 +62,12 @@ ADMIN_LIST_CSV=$(eval "$RUN")
DEFAULT_USER=""
printf "%-6s %-20s %s\n" "ID" "Username" "Email"
-echo "$ADMIN_LIST_CSV" | while IFS=',' read -r PID PLOGIN PEMAIL; do
+while IFS=',' read -r PID PLOGIN PEMAIL; do
printf "%-6s %-20s %s\n" "$PID" "$PLOGIN" "$PEMAIL"
if [ "$PID" = "1" ]; then
DEFAULT_USER="$PLOGIN"
fi
-done
+done <<< "$ADMIN_LIST_CSV"
echo
echo "For each admin choose: (d) delete, (c) change password, (s) skip, (x) exit."
From f16c7e4c3fff4aa83ee4640f9608dee16b73530b Mon Sep 17 00:00:00 2001
From: Peca
Date: Tue, 15 Jul 2025 13:12:20 +0200
Subject: [PATCH 270/304] New command:
v-delete-inactive-wordpress-plugins-and-themes
---
...lete-inactive-wordpress-plugins-and-themes | 165 ++++++++++++++++++
bin/v-desinfect-wordpress | 1 +
2 files changed, 166 insertions(+)
create mode 100644 bin/v-delete-inactive-wordpress-plugins-and-themes
diff --git a/bin/v-delete-inactive-wordpress-plugins-and-themes b/bin/v-delete-inactive-wordpress-plugins-and-themes
new file mode 100644
index 00000000..e9b1715c
--- /dev/null
+++ b/bin/v-delete-inactive-wordpress-plugins-and-themes
@@ -0,0 +1,165 @@
+#!/bin/bash
+# info: delete inactive WordPress plugins and themes
+# options: DOMAIN
+
+#----------------------------------------------------------#
+# Variable & Function #
+#----------------------------------------------------------#
+
+[ "$(whoami)" != "root" ] && { echo "You must be root to run this command."; exit 1; }
+source /etc/profile
+
+DOMAIN="$1"
+[ -z "$DOMAIN" ] && { echo "Usage: v-delete-inactive-wordpress-plugins-and-themes DOMAIN"; exit 1; }
+
+USER="$(/usr/local/vesta/bin/v-search-domain-owner "$DOMAIN")"
+[ -z "$USER" ] && { echo "Domain $DOMAIN does not exist."; exit 1; }
+
+WP_PATH="/home/$USER/web/$DOMAIN/public_html"
+[ ! -f "$WP_PATH/wp-config.php" ] && { echo "WordPress is not installed on this domain."; exit 1; }
+
+# WP-CLI wrapper
+if [ ! -z "$PHP" ]; then
+ WP_RUN="PHP=$PHP /usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes"
+else
+ WP_RUN="/usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes"
+fi
+
+quarantined=0;
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+cd "$WP_PATH" || exit 1
+echo "Inactive WordPress plugins for $DOMAIN:"
+echo "-------------------------------------"
+
+RUN="$WP_RUN plugin list --format=csv --skip-plugins --skip-themes"
+PLUGINS_LIST_CSV=$(eval "$RUN")
+return_code=$?
+
+if [ $return_code -ne 0 ]; then
+ echo "WP-CLI error:"
+ echo "return code: $return_code"
+ cat /home/$USER/web/$DOMAIN/wp-cli-error.log
+ exit $return_code
+fi
+
+PLUGINS_LIST_CSV=$(echo "$PLUGINS_LIST_CSV" | tail -n +2)
+
+DEACTIVATED_PLUGINS_LIST_CSV=""
+
+if [ ! -z "$PLUGINS_LIST_CSV" ]; then
+ printf "%-30s %-20s %-20s %-20s %-20s %-20s\n" "name" "status" "update" "version" "update_version" "auto_update"
+ while IFS=',' read -r NAME STATUS UPDATE VERSION UPDATE_VERSION AUTO_UPDATE; do
+ if [ "$STATUS" = "inactive" ]; then
+ printf "%-30s %-20s %-20s %-20s %-20s %-20s\n" "$NAME" "$STATUS" "$UPDATE" "$VERSION" "$UPDATE_VERSION" "$AUTO_UPDATE"
+ DEACTIVATED_PLUGINS_LIST_CSV="$DEACTIVATED_PLUGINS_LIST_CSV\n$NAME"
+ fi
+ done <<< "$PLUGINS_LIST_CSV"
+else
+ echo "No plugins found."
+fi
+
+if [ ! -z "$DEACTIVATED_PLUGINS_LIST_CSV" ]; then
+ echo ""
+ read -r -p "Do you want to move inactive plugins to quarantine? (y/n, default: y): " RESPONSE < /dev/tty
+ if [ "$RESPONSE" == "y" ] || [ "$RESPONSE" == "Y" ] || [ -z "$RESPONSE" ]; then
+ while IFS=',' read -r NAME STATUS UPDATE VERSION UPDATE_VERSION AUTO_UPDATE; do
+ if [ "$STATUS" = "inactive" ]; then
+ folder="/home/$USER/web/$DOMAIN/public_html/wp-content/plugins/$NAME"
+ file="/home/$USER/web/$DOMAIN/public_html/wp-content/plugins/$NAME.php"
+ if [ -d "$folder" ] || [ -f "$file" ]; then
+ destination_base_folder="/srv/wp-deactivated-plugins/$DOMAIN"
+ if [ -d "$folder" ]; then
+ source_path="$folder"
+ destination_path="$destination_base_folder/$NAME"
+ elif [ -f "$file" ]; then
+ source_path="$file"
+ destination_path="$destination_base_folder/$NAME.php"
+ fi
+ mkdir -p $destination_base_folder
+ chown $USER:$USER $destination_base_folder
+ mv $source_path $destination_path
+ if [ -d "$destination_path" ]; then
+ echo "= Folder $source_path moved to $destination_path"
+ quarantined=1;
+ fi
+ if [ -f "$destination_path" ]; then
+ echo "= File $source_path moved to $destination_path"
+ quarantined=1;
+ fi
+ else
+ echo "=== ERROR: Folder $folder or file $file not found - it does not exist?"
+ fi
+ fi
+ done <<< "$PLUGINS_LIST_CSV"
+ fi
+fi
+
+echo ""
+echo "Inactive WordPress themes for $DOMAIN:"
+echo "-------------------------------------"
+
+RUN="$WP_RUN theme list --format=csv --skip-plugins --skip-themes"
+THEMES_LIST_CSV=$(eval "$RUN")
+return_code=$?
+
+if [ $return_code -ne 0 ]; then
+ echo "WP-CLI error:"
+ echo "return code: $return_code"
+ cat /home/$USER/web/$DOMAIN/wp-cli-error.log
+ exit $return_code
+fi
+
+THEMES_LIST_CSV=$(echo "$THEMES_LIST_CSV" | tail -n +2)
+
+DEACTIVATED_THEMES_LIST_CSV=""
+
+if [ ! -z "$THEMES_LIST_CSV" ]; then
+ printf "%-30s %-20s %-20s %-20s %-20s %-20s\n" "name" "status" "update" "version" "update_version" "auto_update"
+ while IFS=',' read -r NAME STATUS UPDATE VERSION UPDATE_VERSION AUTO_UPDATE; do
+ if [ "$STATUS" = "inactive" ]; then
+ printf "%-30s %-20s %-20s %-20s %-20s %-20s\n" "$NAME" "$STATUS" "$UPDATE" "$VERSION" "$UPDATE_VERSION" "$AUTO_UPDATE"
+ DEACTIVATED_THEMES_LIST_CSV="$DEACTIVATED_THEMES_LIST_CSV\n$NAME"
+ fi
+ done <<< "$THEMES_LIST_CSV"
+else
+ echo "No themes found."
+fi
+
+if [ ! -z "$DEACTIVATED_THEMES_LIST_CSV" ]; then
+ echo ""
+ read -r -p "Do you want to move inactive themes to quarantine? (y/n, default: y): " RESPONSE < /dev/tty
+ if [ "$RESPONSE" == "y" ] || [ "$RESPONSE" == "Y" ] || [ -z "$RESPONSE" ]; then
+ while IFS=',' read -r NAME STATUS UPDATE VERSION UPDATE_VERSION AUTO_UPDATE; do
+ if [ "$STATUS" = "inactive" ]; then
+ folder="/home/$USER/web/$DOMAIN/public_html/wp-content/themes/$NAME"
+ if [ -d "$folder" ]; then
+ destination_base_folder="/srv/wp-deactivated-themes/$DOMAIN"
+ source_path="$folder"
+ destination_path="$destination_base_folder/$NAME"
+ mkdir -p $destination_base_folder
+ chown $USER:$USER $destination_base_folder
+ mv $source_path $destination_path
+ if [ -d "$destination_path" ]; then
+ echo "= Folder $source_path moved to $destination_path"
+ quarantined=1;
+ fi
+ else
+ echo "=== ERROR: Folder $folder not found - it does not exist?"
+ fi
+ fi
+ done <<< "$THEMES_LIST_CSV"
+ fi
+fi
+
+echo ""
+if [ $quarantined -eq 1 ]; then
+ echo "= All deactivated plugins and themes moved to quarantine."
+ echo "= You can find them in /srv/wp-deactivated-plugins/$DOMAIN and /srv/wp-deactivated-themes/$DOMAIN"
+else
+ echo "= No deactivated plugins or themes found."
+fi
+exit 0;
diff --git a/bin/v-desinfect-wordpress b/bin/v-desinfect-wordpress
index 04583c1e..dbcda395 100644
--- a/bin/v-desinfect-wordpress
+++ b/bin/v-desinfect-wordpress
@@ -32,6 +32,7 @@ declare -a tasks=(
"/usr/local/vesta/bin/v-change-database-password-for-wordpress"
"/usr/local/vesta/bin/v-change-wordpress-admin-passwords"
"/usr/local/vesta/bin/v-fix-wordpress-core"
+ "/usr/local/vesta/bin/v-delete-inactive-wordpress-plugins-and-themes"
"/usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
"INTERACTIVE=1 /usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
)
From 7191baa1c9edcb812b4e79431ae46f729d843c6b Mon Sep 17 00:00:00 2001
From: Peca
Date: Tue, 15 Jul 2025 13:53:20 +0200
Subject: [PATCH 271/304] v-change-wordpress-admin-passwords: improve error
handling
---
bin/v-change-wordpress-admin-passwords | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/bin/v-change-wordpress-admin-passwords b/bin/v-change-wordpress-admin-passwords
index 7c4fabdb..6ab4ad0e 100644
--- a/bin/v-change-wordpress-admin-passwords
+++ b/bin/v-change-wordpress-admin-passwords
@@ -30,14 +30,6 @@ else
WP_RUN="/usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes"
fi
-return_code=$?
-
-if [ $return_code -ne 0 ]; then
- echo "WP-CLI error:"
- cat /home/$USER/web/$DOMAIN/wp-cli-error.log
- exit $return_code
-fi
-
# random 10-char password
gen_pass() { tr -dc 'A-Za-z0-9' /dev/null | tail -n +2"
+RUN="$WP_RUN user list --role=administrator --fields=ID,user_login,user_email --format=csv --skip-plugins --skip-themes"
ADMIN_LIST_CSV=$(eval "$RUN")
+return_code=$?
+
+if [ $return_code -ne 0 ]; then
+ echo "WP-CLI error:"
+ echo "return code: $return_code"
+ cat /home/$USER/web/$DOMAIN/wp-cli-error.log
+ exit $return_code
+fi
+
+ADMIN_LIST_CSV=$(echo "$ADMIN_LIST_CSV" | tail -n +2)
+
[ -z "$ADMIN_LIST_CSV" ] && { echo "No administrator accounts found."; exit 0; }
DEFAULT_USER=""
From 928bea08705d789394c2bde609079e78b634699b Mon Sep 17 00:00:00 2001
From: Peca
Date: Tue, 15 Jul 2025 17:48:08 +0200
Subject: [PATCH 272/304] v-fix-website-permissions: only modify those that are
not already set correctly
---
bin/v-fix-website-permissions | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/bin/v-fix-website-permissions b/bin/v-fix-website-permissions
index 4b92df2f..03798a15 100644
--- a/bin/v-fix-website-permissions
+++ b/bin/v-fix-website-permissions
@@ -69,9 +69,9 @@ fi
echo "Updating permissions for /home/$USER/web/$domain/public_html/"
-find public_html/ -type d -exec chmod 755 {} +
-find public_html/ -type f -exec chmod 644 {} +
-chown -R $USER:$USER public_html/
+find public_html/ -type d ! -perm 755 -exec chmod 755 {} +
+find public_html/ -type f ! -perm 644 -exec chmod 644 {} +
+find public_html/ ! -user $USER -exec chown $USER:$USER {} +
php_chmod="600"
if [ -f "/home/$USER/web/$domain/php_chmod" ]; then
@@ -79,11 +79,11 @@ if [ -f "/home/$USER/web/$domain/php_chmod" ]; then
fi
# Setting chmod 600 for all php files
-echo "= Setting chmod 600 for all php files"
-find -name "*.php" -type f -exec chmod $php_chmod {} +
-find -name ".env" -type f -exec chmod $php_chmod {} +
-find -name "*.php" -type f -exec chown $USER:$USER {} +
-find -name ".env" -type f -exec chown $USER:$USER {} +
+echo "= Setting chmod $php_chmod for all php files"
+find -name "*.php" -type f ! -perm $php_chmod -exec chmod $php_chmod {} +
+find -name ".env" -type f ! -perm $php_chmod -exec chmod $php_chmod {} +
+find -name "*.php" -type f ! -user $USER -exec chown $USER:$USER {} +
+find -name ".env" -type f ! -user $USER -exec chown $USER:$USER {} +
#----------------------------------------------------------#
# Vesta #
From b88f0e56bf8e33ca6d77c0fbd0c419881452960e Mon Sep 17 00:00:00 2001
From: Peca
Date: Tue, 15 Jul 2025 18:44:02 +0200
Subject: [PATCH 273/304] New command: v-delete-wordpress-uploads-php-files
---
bin/v-delete-wordpress-uploads-php-files | 70 ++++++++++++++++++++++++
bin/v-desinfect-wordpress | 1 +
2 files changed, 71 insertions(+)
create mode 100644 bin/v-delete-wordpress-uploads-php-files
diff --git a/bin/v-delete-wordpress-uploads-php-files b/bin/v-delete-wordpress-uploads-php-files
new file mode 100644
index 00000000..4ef12f1e
--- /dev/null
+++ b/bin/v-delete-wordpress-uploads-php-files
@@ -0,0 +1,70 @@
+#!/bin/bash
+# info: delete PHP files from WordPress uploads folder
+# options: DOMAIN
+
+#----------------------------------------------------------#
+# Variable & Function #
+#----------------------------------------------------------#
+
+[ "$(whoami)" != "root" ] && { echo "You must be root to run this command."; exit 1; }
+source /etc/profile
+
+DOMAIN="$1"
+[ -z "$DOMAIN" ] && { echo "Usage: v-delete-wordpress-uploads-php-files DOMAIN"; exit 1; }
+
+USER="$(/usr/local/vesta/bin/v-search-domain-owner "$DOMAIN")"
+[ -z "$USER" ] && { echo "Domain $DOMAIN does not exist."; exit 1; }
+
+WP_PATH="/home/$USER/web/$DOMAIN/public_html"
+[ ! -f "$WP_PATH/wp-config.php" ] && { echo "WordPress is not installed on this domain."; exit 1; }
+
+quarantined=0;
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+cd "$WP_PATH" || exit 1
+
+files=$(find wp-content/uploads/ -type f -name "*.php")
+
+if [ -z "$files" ]; then
+ echo "= No PHP files found in WordPress uploads folder."
+ exit 0;
+fi
+
+echo "= Found PHP files in WordPress uploads folder for domain $DOMAIN :"
+echo "-------------------------------------"
+echo "$files"
+echo "-------------------------------------"
+
+while true; do
+ read -r -p "Do you want to delete these files? (y/n): " RESPONSE < /dev/tty
+ if [ "$RESPONSE" == "y" ] || [ "$RESPONSE" == "Y" ]; then
+ for file in $files; do
+ source_file="/home/$USER/web/$DOMAIN/public_html/$file"
+ destination_file="/srv/wp-uploads-php-files-quarantine/$DOMAIN/$file"
+ destination_folder=$(dirname "$destination_file")
+ mkdir -p "$destination_folder"
+ chown $USER:$USER "$destination_folder"
+ mv "$source_file" "$destination_file"
+ echo "= File $source_file moved to $destination_file"
+ quarantined=1;
+ done
+ chown -R $USER:$USER "/srv/wp-uploads-php-files-quarantine/$DOMAIN"
+ break;
+ fi
+ if [ "$RESPONSE" == "n" ] || [ "$RESPONSE" == "N" ]; then
+ break;
+ fi
+done
+
+echo ""
+if [ $quarantined -eq 1 ]; then
+ echo "= All PHP files moved to quarantine."
+ echo "= You can find them in /srv/wp-uploads-php-files-quarantine/$DOMAIN"
+else
+ echo "= No PHP files found in WordPress uploads folder."
+fi
+
+exit 0;
\ No newline at end of file
diff --git a/bin/v-desinfect-wordpress b/bin/v-desinfect-wordpress
index dbcda395..fcdc2f66 100644
--- a/bin/v-desinfect-wordpress
+++ b/bin/v-desinfect-wordpress
@@ -33,6 +33,7 @@ declare -a tasks=(
"/usr/local/vesta/bin/v-change-wordpress-admin-passwords"
"/usr/local/vesta/bin/v-fix-wordpress-core"
"/usr/local/vesta/bin/v-delete-inactive-wordpress-plugins-and-themes"
+ "/usr/local/vesta/bin/v-delete-wordpress-uploads-php-files"
"/usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
"INTERACTIVE=1 /usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
)
From 29f030205e05648c1e82a110837fc892b4e4edf0 Mon Sep 17 00:00:00 2001
From: Peca
Date: Wed, 16 Jul 2025 12:50:25 +0200
Subject: [PATCH 274/304] v-fix-website-permissions: exclude specific file
types from permission changes to avoid altering 'Change' file attribute
---
bin/v-fix-website-permissions | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/bin/v-fix-website-permissions b/bin/v-fix-website-permissions
index 03798a15..bc0d1ba5 100644
--- a/bin/v-fix-website-permissions
+++ b/bin/v-fix-website-permissions
@@ -69,8 +69,8 @@ fi
echo "Updating permissions for /home/$USER/web/$domain/public_html/"
-find public_html/ -type d ! -perm 755 -exec chmod 755 {} +
-find public_html/ -type f ! -perm 644 -exec chmod 644 {} +
+find public_html/ -type d ! \( -name "*.php" -o -name "*.env" \) ! -perm 755 -exec chmod 755 {} +
+find public_html/ -type f ! \( -name "*.php" -o -name "*.env" \) ! -perm 644 -exec chmod 644 {} +
find public_html/ ! -user $USER -exec chown $USER:$USER {} +
php_chmod="600"
@@ -80,8 +80,7 @@ fi
# Setting chmod 600 for all php files
echo "= Setting chmod $php_chmod for all php files"
-find -name "*.php" -type f ! -perm $php_chmod -exec chmod $php_chmod {} +
-find -name ".env" -type f ! -perm $php_chmod -exec chmod $php_chmod {} +
+find -type f \( -name "*.php" -o -name "*.env" \) ! -perm $php_chmod -exec chmod $php_chmod {} +
find -name "*.php" -type f ! -user $USER -exec chown $USER:$USER {} +
find -name ".env" -type f ! -user $USER -exec chown $USER:$USER {} +
From a5f2e6acd5b78fe24c2d791c31dcbd0aa5554ec2 Mon Sep 17 00:00:00 2001
From: Peca
Date: Wed, 16 Jul 2025 12:52:43 +0200
Subject: [PATCH 275/304] v-fix-website-permissions: exclude specific file
types from permission changes to avoid altering 'Change' file attribute
---
bin/v-fix-website-permissions | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/bin/v-fix-website-permissions b/bin/v-fix-website-permissions
index bc0d1ba5..93b9d662 100644
--- a/bin/v-fix-website-permissions
+++ b/bin/v-fix-website-permissions
@@ -69,20 +69,24 @@ fi
echo "Updating permissions for /home/$USER/web/$domain/public_html/"
-find public_html/ -type d ! \( -name "*.php" -o -name "*.env" \) ! -perm 755 -exec chmod 755 {} +
+# Fixing permissions
+find public_html/ -type d ! -perm 755 -exec chmod 755 {} +
find public_html/ -type f ! \( -name "*.php" -o -name "*.env" \) ! -perm 644 -exec chmod 644 {} +
-find public_html/ ! -user $USER -exec chown $USER:$USER {} +
+# Fixing ownership
+find public_html/ -type d ! -user $USER -exec chown $USER:$USER {} +
+find public_html/ -type f ! \( -name "*.php" -o -name "*.env" \) ! -user $USER -exec chown $USER:$USER {} +
php_chmod="600"
if [ -f "/home/$USER/web/$domain/php_chmod" ]; then
php_chmod=$(cat /home/$USER/web/$domain/php_chmod)
fi
-# Setting chmod 600 for all php files
-echo "= Setting chmod $php_chmod for all php files"
+# Setting chmod 600 for all .php and .env files
+echo "= Setting chmod $php_chmod for all .php and .env files"
+# Fixing permissions
find -type f \( -name "*.php" -o -name "*.env" \) ! -perm $php_chmod -exec chmod $php_chmod {} +
-find -name "*.php" -type f ! -user $USER -exec chown $USER:$USER {} +
-find -name ".env" -type f ! -user $USER -exec chown $USER:$USER {} +
+# Fixing ownership
+find -type f \( -name "*.php" -o -name "*.env" \) ! -user $USER -exec chown $USER:$USER {} +
#----------------------------------------------------------#
# Vesta #
From 3801e8d6cf43ecbeb52e1de97ea1c2e137799112 Mon Sep 17 00:00:00 2001
From: Peca
Date: Wed, 16 Jul 2025 13:57:37 +0200
Subject: [PATCH 276/304] v-delete-wordpress-uploads-php-files: set default
response to 'yes' for moving files to quarantine
---
bin/v-delete-wordpress-uploads-php-files | 34 ++++++++++--------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/bin/v-delete-wordpress-uploads-php-files b/bin/v-delete-wordpress-uploads-php-files
index 4ef12f1e..ce72c0c4 100644
--- a/bin/v-delete-wordpress-uploads-php-files
+++ b/bin/v-delete-wordpress-uploads-php-files
@@ -38,26 +38,20 @@ echo "-------------------------------------"
echo "$files"
echo "-------------------------------------"
-while true; do
- read -r -p "Do you want to delete these files? (y/n): " RESPONSE < /dev/tty
- if [ "$RESPONSE" == "y" ] || [ "$RESPONSE" == "Y" ]; then
- for file in $files; do
- source_file="/home/$USER/web/$DOMAIN/public_html/$file"
- destination_file="/srv/wp-uploads-php-files-quarantine/$DOMAIN/$file"
- destination_folder=$(dirname "$destination_file")
- mkdir -p "$destination_folder"
- chown $USER:$USER "$destination_folder"
- mv "$source_file" "$destination_file"
- echo "= File $source_file moved to $destination_file"
- quarantined=1;
- done
- chown -R $USER:$USER "/srv/wp-uploads-php-files-quarantine/$DOMAIN"
- break;
- fi
- if [ "$RESPONSE" == "n" ] || [ "$RESPONSE" == "N" ]; then
- break;
- fi
-done
+read -r -p "Do you want to move these files to quarantine? (y/n, default: y): " RESPONSE < /dev/tty
+if [ "$RESPONSE" == "y" ] || [ "$RESPONSE" == "Y" ] || [ -z "$RESPONSE" ]; then
+ for file in $files; do
+ source_file="/home/$USER/web/$DOMAIN/public_html/$file"
+ destination_file="/srv/wp-uploads-php-files-quarantine/$DOMAIN/$file"
+ destination_folder=$(dirname "$destination_file")
+ mkdir -p "$destination_folder"
+ chown $USER:$USER "$destination_folder"
+ mv "$source_file" "$destination_file"
+ echo "= File $source_file moved to $destination_file"
+ quarantined=1;
+ done
+ chown -R $USER:$USER "/srv/wp-uploads-php-files-quarantine/$DOMAIN"
+fi
echo ""
if [ $quarantined -eq 1 ]; then
From 403dd654009a7afb2d953c9f0fe8d2d0fa02f358 Mon Sep 17 00:00:00 2001
From: Peca
Date: Wed, 16 Jul 2025 15:35:46 +0200
Subject: [PATCH 277/304] v-change-database-password-for-wordpress: enhance
database name and user retrieval to support both single and double quotes in
wp-config.php
---
bin/v-change-database-password-for-wordpress | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/bin/v-change-database-password-for-wordpress b/bin/v-change-database-password-for-wordpress
index dd7a3a91..0c84f80b 100644
--- a/bin/v-change-database-password-for-wordpress
+++ b/bin/v-change-database-password-for-wordpress
@@ -70,6 +70,12 @@ if [ -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
fi
db_name=$(grep "DB_NAME" $wp_config_path | grep -oP "define\s*\(\s*'DB_NAME'\s*,\s*'\K[^']+")
db_user=$(grep "DB_USER" $wp_config_path | grep -oP "define\s*\(\s*'DB_USER'\s*,\s*'\K[^']+")
+ if [ -z "$db_name" ]; then
+ db_name=$(grep "DB_NAME" $wp_config_path | grep -oP "define\s*\(\s*'DB_NAME'\s*,\s*\"\K[^\"]+")
+ fi
+ if [ -z "$db_user" ]; then
+ db_user=$(grep "DB_USER" $wp_config_path | grep -oP "define\s*\(\s*'DB_USER'\s*,\s*\"\K[^\"]+")
+ fi
new_password=''
found_existing_password=0
if [ -f "/root/remember-db-user-pass.txt" ]; then
From a976a3bc3f0d46f28059e2df3fcc84501846f9b8 Mon Sep 17 00:00:00 2001
From: Peca
Date: Wed, 16 Jul 2025 17:53:38 +0200
Subject: [PATCH 278/304] v-change-database-password-for-wordpress: fixing a
bug in temporary password storage
---
bin/v-change-database-password-for-all-wordpress | 4 +++-
bin/v-change-database-password-for-wordpress | 7 +++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/bin/v-change-database-password-for-all-wordpress b/bin/v-change-database-password-for-all-wordpress
index 2741e960..1a364307 100644
--- a/bin/v-change-database-password-for-all-wordpress
+++ b/bin/v-change-database-password-for-all-wordpress
@@ -51,7 +51,9 @@ for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
done
# cat /root/remember-db-user-pass.txt
-rm /root/remember-db-user-pass.txt
+if [ -f "/root/remember-db-user-pass.txt" ]; then
+ rm /root/remember-db-user-pass.txt
+fi
#----------------------------------------------------------#
# Vesta #
diff --git a/bin/v-change-database-password-for-wordpress b/bin/v-change-database-password-for-wordpress
index 0c84f80b..7f31b181 100644
--- a/bin/v-change-database-password-for-wordpress
+++ b/bin/v-change-database-password-for-wordpress
@@ -94,8 +94,11 @@ if [ -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
echo "DB name: $db_name"
echo "DB user: $db_user"
echo "New DB password: $new_password"
- if [ $found_existing_password -eq 0 ] && [ -f "/root/remember-db-user-pass.txt" ]; then
+ if [ $found_existing_password -eq 0 ]; then
+ touch /root/remember-db-user-pass.txt
echo "$db_user:$new_password" >> /root/remember-db-user-pass.txt
+ chown root:root /root/remember-db-user-pass.txt
+ chmod 600 /root/remember-db-user-pass.txt
fi
/usr/local/vesta/bin/v-change-database-password "$user" "$db_name" "$new_password"
if [ $? -ne 0 ]; then
@@ -126,4 +129,4 @@ fi
# Logging
log_event "$OK" "$ARGUMENTS"
-exit
+exit 0;
From 9eade5a7df4759d0d4a90862fe1e1892f74e8e58 Mon Sep 17 00:00:00 2001
From: Peca
Date: Wed, 16 Jul 2025 19:21:18 +0200
Subject: [PATCH 279/304] v-fix-wordpress-core: support for custom PHP
version
---
bin/v-fix-wordpress-core | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/bin/v-fix-wordpress-core b/bin/v-fix-wordpress-core
index 7a511747..2bcd6c34 100644
--- a/bin/v-fix-wordpress-core
+++ b/bin/v-fix-wordpress-core
@@ -37,7 +37,12 @@ TMP_DIR="$(mktemp -d /tmp/wpfix.XXXXXX)" # temp workspace
trap 'rm -rf "$TMP_DIR"' EXIT
# 1etermine WP version
-WP_VERSION="$(/usr/local/vesta/bin/v-run-wp-cli "$DOMAIN" core version | tr -d '[:space:]')"
+if [ -z "$PHP" ]; then
+ WP_VERSION="$(/usr/local/vesta/bin/v-run-wp-cli "$DOMAIN" core version | tr -d '[:space:]')"
+else
+ WP_VERSION="$(PHP=$PHP /usr/local/vesta/bin/v-run-wp-cli "$DOMAIN" core version | tr -d '[:space:]')"
+fi
+
check_result $? "cannot detect WP version" > /dev/null
if [ -z "$WP_VERSION" ]; then
check_result 1 "empty WP version string"
From f64968ba918e10040325315eaaa5e8f09657d72b Mon Sep 17 00:00:00 2001
From: Peca
Date: Thu, 17 Jul 2025 14:36:37 +0200
Subject: [PATCH 280/304] v-change-wordpress-admin-passwords: add option to
skip content reassignment during user deletion
---
bin/v-change-wordpress-admin-passwords | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/bin/v-change-wordpress-admin-passwords b/bin/v-change-wordpress-admin-passwords
index 6ab4ad0e..eae5b078 100644
--- a/bin/v-change-wordpress-admin-passwords
+++ b/bin/v-change-wordpress-admin-passwords
@@ -81,6 +81,7 @@ while IFS=',' read -r ID LOGIN EMAIL; do
while true; do
echo "-------------------------------------"
read -r -p "Action for \"$TARGET\" [d/c/s/x]? " ACT < /dev/tty
+ skip=0;
case "$ACT" in
[Dd]* )
# read -r -p "Really DELETE \"$TARGET\" ? (y/n, default: y) " CONF < /dev/tty
@@ -97,17 +98,25 @@ while IFS=',' read -r ID LOGIN EMAIL; do
fi
echo "Available admin usernames for reassignment: ${OTHER_USERS[*]}"
while true; do
- read -r -p "Reassign content to which username? [default: $DEFAULT_USER] " REASSIGN < /dev/tty
+ read -r -p "Reassign content to which username? [default: $DEFAULT_USER, s: skip] " REASSIGN < /dev/tty
REASSIGN=${REASSIGN:-$DEFAULT_USER}
DEFAULT_USER=$REASSIGN
if printf '%s\n' "${OTHER_USERS[@]}" | grep -qx "$REASSIGN"; then
break
fi
+ if [[ "$REASSIGN" =~ ^[Ss]$ ]]; then
+ echo "Skipping reassignment."
+ skip=1;
+ break
+ fi
if [[ "$REASSIGN" =~ ^[0-9]+$ ]]; then
break
fi
echo "Invalid username. Please choose one of: ${OTHER_USERS[*]}"
done
+ if [ $skip -eq 1 ]; then
+ break
+ fi
# delete by username, reassign by username
RUN="$WP_RUN user delete $ID --reassign=$REASSIGN --yes --skip-plugins --skip-themes"
eval "$RUN"
From 7799cd3322e4e2b416cba968e5540a505b8c8289 Mon Sep 17 00:00:00 2001
From: Peca
Date: Tue, 22 Jul 2025 14:18:10 +0200
Subject: [PATCH 281/304] v-update-deb-package: change target Debian version to
'trixie' and update dependencies for NGINX, OpenSSL, and Zlib
---
src/deb/vesta_compile.sh | 46 ++++++++++++++++++++++++++++++++++------
1 file changed, 39 insertions(+), 7 deletions(-)
diff --git a/src/deb/vesta_compile.sh b/src/deb/vesta_compile.sh
index a80316d9..c645aa4c 100644
--- a/src/deb/vesta_compile.sh
+++ b/src/deb/vesta_compile.sh
@@ -7,8 +7,8 @@
build_deb_package=1
add_deb_to_apt_repo=0
-TARGET_DEB_NAME='bookworm'
-TARGET_DEB_VER='12'
+TARGET_DEB_NAME='trixie'
+TARGET_DEB_VER='13'
run_apt_update_and_install=1
wait_to_press_enter=1
@@ -31,8 +31,8 @@ fi
MAINTAINER_EMAIL='info@myvestacp.com'
-TARGET_DEB_NAME_MAIN='bookworm'
-TARGET_DEB_VER_MAIN='12'
+TARGET_DEB_NAME_MAIN='trixie'
+TARGET_DEB_VER_MAIN='13'
# Set compiling directory
BUILD_DIR="/usr/src/$TARGET_DEB_NAME"
@@ -58,10 +58,10 @@ BUILD_DATE=$(date +"%d-%b-%Y")
# Set Version for compiling
VESTA_V=$VESTA_VER"_amd64"
-NGINX_V='1.25.1'
-OPENSSL_V='1.1.1u'
+NGINX_V='1.29.0'
+OPENSSL_V='1.1.1w'
PCRE_V='8.45'
-ZLIB_V='1.2.13'
+ZLIB_V='1.3.1'
PHP_V='5.6.40'
# Generate Links for sourcecode
@@ -130,6 +130,9 @@ if [ $run_apt_update_and_install -eq 1 ]; then
if [ ! -e /usr/local/include/curl ] && [ "$release" -lt 12 ]; then
ln -s /usr/include/x86_64-linux-gnu/curl /usr/local/include/curl
fi
+ if [ "$release" -eq 13 ]; then
+ ln -s /usr/include/x86_64-linux-gnu/curl /usr/local/include/curl
+ fi
press_enter "=== Press enter to continue ==============================================================================="
fi
@@ -258,6 +261,7 @@ EOF
press_enter "*** please copy above generated key to your clipboard and then paste it after pressing enter now ***"
vi $PATH_OF_APT_REPO_ROOT/deb_signing.key
cp $PATH_OF_APT_REPO_ROOT/deb_signing.key $PATH_OF_C_WEB_FOLDER_ROOT/deb_signing.key
+ cp $PATH_OF_APT_REPO_ROOT/deb_signing.key $PATH_OF_C_WEB_FOLDER_ROOT/debian/13/deb_signing.key
cp $PATH_OF_APT_REPO_ROOT/deb_signing.key $PATH_OF_C_WEB_FOLDER_ROOT/debian/12/deb_signing.key
cp $PATH_OF_APT_REPO_ROOT/deb_signing.key $PATH_OF_C_WEB_FOLDER_ROOT/debian/11/deb_signing.key
cp $PATH_OF_APT_REPO_ROOT/deb_signing.key $PATH_OF_C_WEB_FOLDER_ROOT/debian/10/deb_signing.key
@@ -442,6 +446,34 @@ if [ "$CWEB_B" = true ]; then
fi
tar -czf fail2ban.tar.gz fail2ban/
+ if [ -f "dovecot.tar.gz" ]; then
+ rm dovecot.tar.gz
+ fi
+ tar -czf dovecot.tar.gz dovecot/
+ echo "=== All done for Debian12"
+ ##########
+ cd $PATH_OF_C_WEB_FOLDER_ROOT/debian/13
+
+ if [ -f "packages.tar.gz" ]; then
+ rm packages.tar.gz
+ fi
+ tar -czf packages.tar.gz packages/
+
+ if [ -f "templates.tar.gz" ]; then
+ rm templates.tar.gz
+ fi
+ tar -czf templates.tar.gz templates/
+
+ if [ -f "firewall.tar.gz" ]; then
+ rm firewall.tar.gz
+ fi
+ tar -czf firewall.tar.gz firewall/
+
+ if [ -f "fail2ban.tar.gz" ]; then
+ rm fail2ban.tar.gz
+ fi
+ tar -czf fail2ban.tar.gz fail2ban/
+
if [ -f "dovecot.tar.gz" ]; then
rm dovecot.tar.gz
fi
From b3758430c653c3c031273d85f3fd44d154fe265c Mon Sep 17 00:00:00 2001
From: Peca
Date: Tue, 22 Jul 2025 16:30:23 +0200
Subject: [PATCH 282/304] v-update-php-version: upgrade PHP to 8.4.10 and
update download link; add additional dependencies for Debian 13
---
src/deb/vesta_compile.sh | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/deb/vesta_compile.sh b/src/deb/vesta_compile.sh
index c645aa4c..0d899cb3 100644
--- a/src/deb/vesta_compile.sh
+++ b/src/deb/vesta_compile.sh
@@ -62,7 +62,7 @@ NGINX_V='1.29.0'
OPENSSL_V='1.1.1w'
PCRE_V='8.45'
ZLIB_V='1.3.1'
-PHP_V='5.6.40'
+PHP_V='8.4.10'
# Generate Links for sourcecode
NGINX='https://nginx.org/download/nginx-'$NGINX_V'.tar.gz'
@@ -73,7 +73,7 @@ OPENSSL='https://www.openssl.org/source/openssl-'$OPENSSL_V'.tar.gz'
PCRE='https://sourceforge.net/projects/pcre/files/pcre/'$PCRE_V'/pcre-'$PCRE_V'.tar.gz/download'
# Zlib moved archives to Github
ZLIB='https://github.com/madler/zlib/archive/refs/tags/v'$ZLIB_V'.tar.gz'
-PHP='http://de2.php.net/distributions/php-'$PHP_V'.tar.gz'
+PHP='https://www.php.net/distributions/php-'$PHP_V'.tar.gz'
# Set package dependencies for compiling
release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
@@ -81,7 +81,7 @@ release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
if [ "$release" -lt 12 ]; then
SOFTWARE='build-essential libxml2-dev libz-dev libcurl4-gnutls-dev unzip openssl libssl-dev pkg-config reprepro dpkg-sig git rsync'
else
- SOFTWARE='build-essential libxml2-dev libz-dev libcurl4-gnutls-dev unzip openssl libssl-dev pkg-config reprepro git rsync'
+ SOFTWARE='build-essential libxml2-dev libz-dev libcurl4-gnutls-dev unzip openssl libssl-dev pkg-config reprepro git rsync libsqlite3-dev libonig-dev'
fi
function press_enter {
@@ -130,7 +130,7 @@ if [ $run_apt_update_and_install -eq 1 ]; then
if [ ! -e /usr/local/include/curl ] && [ "$release" -lt 12 ]; then
ln -s /usr/include/x86_64-linux-gnu/curl /usr/local/include/curl
fi
- if [ "$release" -eq 13 ]; then
+ if [ ! -e /usr/local/include/curl ] && [ "$release" -eq 13 ]; then
ln -s /usr/include/x86_64-linux-gnu/curl /usr/local/include/curl
fi
press_enter "=== Press enter to continue ==============================================================================="
@@ -530,7 +530,7 @@ if [ "$NGINX_B" = true ]; then
--with-openssl-opt=no-weak-ssl-ciphers \
--with-openssl-opt=no-ssl3 \
--with-pcre=../pcre-$PCRE_V \
- --with-pcre-jit \
+ --with-pcre-jit \
--with-zlib=../zlib-$ZLIB_V
# Check install directory and remove if exists
@@ -625,11 +625,10 @@ if [ "$PHP_B" = true ]; then
--with-zlib \
--with-fpm-user=admin \
--with-fpm-group=admin \
- --with-mysql \
--with-mysqli \
--with-curl \
--enable-mbstring \
- --with-mysql-sock=/var/run/mysqld/mysqld.sock
+ --with-mysql-sock=/var/run/mysqld/mysqld.sock
# Check install directory and remove if exists
if [ -d $INSTALL_DIR/php ]; then
@@ -637,7 +636,7 @@ if [ "$PHP_B" = true ]; then
fi
press_enter "=== Press enter to compile PHP ==============================================================================="
-
+
make && make install
press_enter "=== Press enter to continue ==============================================================================="
From 77b6506baeca26e71dcba0eb367c9f66b213da83 Mon Sep 17 00:00:00 2001
From: Peca
Date: Wed, 23 Jul 2025 14:02:52 +0200
Subject: [PATCH 283/304] v-update-deb-package: update completion message for
Debian 13
---
src/deb/vesta_compile.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/deb/vesta_compile.sh b/src/deb/vesta_compile.sh
index 0d899cb3..08bc163b 100644
--- a/src/deb/vesta_compile.sh
+++ b/src/deb/vesta_compile.sh
@@ -478,7 +478,7 @@ if [ "$CWEB_B" = true ]; then
rm dovecot.tar.gz
fi
tar -czf dovecot.tar.gz dovecot/
- echo "=== All done for Debian12"
+ echo "=== All done for Debian13"
##########
cp /root/vesta/install/vst-install-debian.sh $PATH_OF_C_WEB_FOLDER_ROOT/vst-install-debian.sh
From 30581ea672b0bcce6d2605a6138d1085c60aaf67 Mon Sep 17 00:00:00 2001
From: Peca
Date: Wed, 23 Jul 2025 22:37:09 +0200
Subject: [PATCH 284/304] v-change-wordpress-admin-passwords: enhance output
messages for password change confirmation
---
bin/v-change-wordpress-admin-passwords | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/bin/v-change-wordpress-admin-passwords b/bin/v-change-wordpress-admin-passwords
index eae5b078..bca23ad8 100644
--- a/bin/v-change-wordpress-admin-passwords
+++ b/bin/v-change-wordpress-admin-passwords
@@ -160,8 +160,15 @@ while IFS=',' read -r ID LOGIN EMAIL; do
done <<< "$ADMIN_LIST_CSV"
if [ -f /home/$USER/web/$DOMAIN/wp-admin-password-change.txt ]; then
+ echo ""
+ echo ""
echo "-------------------------------------"
- echo
+ echo "For website $DOMAIN - new wp-admin passwords have been set."
+ echo "-------------------------------------"
+ cat /home/$USER/web/$DOMAIN/wp-admin-password-change.txt
+ echo "-------------------------------------"
+ echo ""
+ echo ""
read -r -p "Do you want to save the new passwords to a file /home/$USER/web/$DOMAIN/wp-admin-password-change.txt ? (y/n, default: n) " SAVE_PASSWORDS < /dev/tty
if [ -z "$SAVE_PASSWORDS" ]; then
SAVE_PASSWORDS="n"
@@ -191,14 +198,4 @@ echo "Cache flushed and salts refreshed."
echo
echo "Done."
-if [ -f /home/$USER/web/$DOMAIN/wp-admin-password-change.txt ]; then
- echo "-------------------------------------"
- echo "For website $DOMAIN - new wp-admin passwords have been set."
- echo "-------------------------------------"
- cat /home/$USER/web/$DOMAIN/wp-admin-password-change.txt
- echo "-------------------------------------"
- echo ""
- read -r -p "== Press Enter to continue..."
-fi
-
exit 0
From 4e8bac8dda0670066c3b8cd880bfb388cb550a25 Mon Sep 17 00:00:00 2001
From: Peca
Date: Wed, 23 Jul 2025 23:34:07 +0200
Subject: [PATCH 285/304] v-update-firewall-rules: improve nginx configuration
handling for deleting rules, as well as for suspended and unsuspended rules
---
bin/v-delete-firewall-rule | 2 +-
bin/v-suspend-firewall-rule | 9 +++++++++
bin/v-unsuspend-firewall-rule | 13 +++++++++++++
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/bin/v-delete-firewall-rule b/bin/v-delete-firewall-rule
index 61f7602d..10fd0fb9 100755
--- a/bin/v-delete-firewall-rule
+++ b/bin/v-delete-firewall-rule
@@ -45,7 +45,7 @@ $BIN/v-update-firewall
if [ "$WEB_SYSTEM" == 'nginx' ] || [ "$PROXY_SYSTEM" == 'nginx' ]; then
parse_object_kv_list_non_eval "$oldvalues"
if [ "$PORT" == "80,443" ] && [ "$ACTION" == "DROP" ]; then
- sed -i "/$IP/d" /etc/nginx/conf.d/block-firewall.conf
+ sed -i "\#$IP#d" /etc/nginx/conf.d/block-firewall.conf
systemctl restart nginx
fi
fi
diff --git a/bin/v-suspend-firewall-rule b/bin/v-suspend-firewall-rule
index 67f14cec..9191fed0 100755
--- a/bin/v-suspend-firewall-rule
+++ b/bin/v-suspend-firewall-rule
@@ -32,12 +32,21 @@ is_object_unsuspended '../../data/firewall/rules' 'RULE' "$rule"
# Action #
#----------------------------------------------------------#
+oldvalues=$(grep "RULE='$rule'" $VESTA/data/firewall/rules.conf)
+
# Suspending rule
update_object_value ../../data/firewall/rules RULE $rule '$SUSPENDED' yes
# Updating system firewall
$BIN/v-update-firewall
+if [ "$WEB_SYSTEM" == 'nginx' ] || [ "$PROXY_SYSTEM" == 'nginx' ]; then
+ parse_object_kv_list_non_eval "$oldvalues"
+ if [ "$PORT" == "80,443" ] && [ "$ACTION" == "DROP" ]; then
+ sed -i "\#$IP#d" /etc/nginx/conf.d/block-firewall.conf
+ systemctl restart nginx
+ fi
+fi
#----------------------------------------------------------#
# Vesta #
diff --git a/bin/v-unsuspend-firewall-rule b/bin/v-unsuspend-firewall-rule
index be6320d4..f0e00c96 100755
--- a/bin/v-unsuspend-firewall-rule
+++ b/bin/v-unsuspend-firewall-rule
@@ -32,12 +32,25 @@ is_object_suspended '../../data/firewall/rules' 'RULE' "$rule"
# Action #
#----------------------------------------------------------#
+oldvalues=$(grep "RULE='$rule'" $VESTA/data/firewall/rules.conf)
+
# Suspending rule
update_object_value ../../data/firewall/rules RULE $rule '$SUSPENDED' no
# Updating system firewall
$BIN/v-update-firewall
+if [ "$WEB_SYSTEM" == 'nginx' ] || [ "$PROXY_SYSTEM" == 'nginx' ]; then
+ parse_object_kv_list_non_eval "$oldvalues"
+ if [ "$PORT" == "80,443" ] && [ "$ACTION" == "DROP" ]; then
+ touch /etc/nginx/conf.d/block-firewall.conf
+ if ! grep -q "deny $IP;" /etc/nginx/conf.d/block-firewall.conf; then
+ echo "deny $IP;" >> /etc/nginx/conf.d/block-firewall.conf
+ systemctl restart nginx
+ fi
+ fi
+fi
+
#----------------------------------------------------------#
# Vesta #
From d017fbbe0700a61adb45a8494b1f6656655ffff3 Mon Sep 17 00:00:00 2001
From: Peca
Date: Fri, 25 Jul 2025 16:37:45 +0200
Subject: [PATCH 286/304] v-fix-website-permissions: improve error messages for
non-existent user and domain directories
---
bin/v-fix-website-permissions | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bin/v-fix-website-permissions b/bin/v-fix-website-permissions
index 93b9d662..13c6775d 100644
--- a/bin/v-fix-website-permissions
+++ b/bin/v-fix-website-permissions
@@ -42,12 +42,12 @@ is_format_valid 'domain'
is_object_valid 'user' 'USER' "$user"
if [ ! -d "/home/$user" ]; then
- echo "User doesn't exist";
+ echo "Error: Folder /home/$user doesn't exist";
exit 1;
fi
if [ ! -d "/home/$user/web/$domain/public_html" ]; then
- echo "Domain doesn't exist";
+ echo "Error: Folder /home/$user/web/$domain/public_html doesn't exist";
exit 1;
fi
From 5fb7862b39b7437777fd1c57bc35c9c588854ac4 Mon Sep 17 00:00:00 2001
From: Peca
Date: Sat, 26 Jul 2025 21:36:10 +0200
Subject: [PATCH 287/304] Replace direct calls to 'wp' with 'v-run-wp-cli'
---
bin/v-add-wordpress-admin | 16 ++++------
bin/v-clone-website | 22 ++++++-------
bin/v-install-wordfence-cli | 0
bin/v-install-wordpress | 29 +++++++++++------
bin/{v-get-wp-cli => v-install-wp-cli} | 24 ++++++++++++--
bin/v-migrate-site-to-https | 22 +++++++++----
bin/v-run-wp-cli | 44 +++++++++++++++++++-------
7 files changed, 108 insertions(+), 49 deletions(-)
create mode 100644 bin/v-install-wordfence-cli
rename bin/{v-get-wp-cli => v-install-wp-cli} (60%)
diff --git a/bin/v-add-wordpress-admin b/bin/v-add-wordpress-admin
index 67f58bf4..20585485 100644
--- a/bin/v-add-wordpress-admin
+++ b/bin/v-add-wordpress-admin
@@ -63,21 +63,19 @@ if [ ! -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
exit 1;
fi
-if ! command -v wp &> /dev/null; then
- echo "WP CLI is not installed. Installing..."
- wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
- chmod +x /usr/local/bin/wp
- echo "WP CLI installed successfully."
+if [ ! -f "/usr/local/bin/wp" ] || [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ echo "= WP CLI is not installed. Installing..."
+ /usr/local/vesta/bin/v-install-wp-cli
+fi
+if [ ! -f "/usr/local/bin/wp" ] && [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ exit 1;
fi
-
-phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$domain")
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
-cd /home/$USER/web/$domain/public_html
-sudo -u $USER /usr/bin/php$phpver /usr/local/bin/wp user create $username $email --role=administrator --user_pass="$password" --skip-plugins=$(sudo -H -u$USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
+/usr/local/vesta/bin/v-run-wp-cli $domain user create $username $email --role=administrator --user_pass="$password" --skip-plugins --skip-themes;
#----------------------------------------------------------#
# Vesta #
diff --git a/bin/v-clone-website b/bin/v-clone-website
index 0258e39a..0e089465 100644
--- a/bin/v-clone-website
+++ b/bin/v-clone-website
@@ -265,10 +265,12 @@ if [ $IT_IS_WP -eq 0 ]; then
git clone https://github.com/interconnectit/Search-Replace-DB.git
fi
else
- if [ ! -f "/usr/local/bin/wp" ]; then
- echo "=== Downloading latest wp-cli"
- wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
- chmod +x /usr/local/bin/wp
+ if [ ! -f "/usr/local/bin/wp" ] || [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ echo "= WP CLI is not installed. Installing..."
+ /usr/local/vesta/bin/v-install-wp-cli
+ fi
+ if [ ! -f "/usr/local/bin/wp" ] && [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ exit 1;
fi
fi
@@ -429,17 +431,15 @@ if [ $IT_IS_WP -eq 0 ]; then
php /root/Search-Replace-DB/srdb.cli.php -h localhost -n "$TO_DATABASE_NAME" -u "$TO_DATABASE_USERNAME" -p "$TO_DATABASE_PASSWORD" -s "/home/$FROM_USER/" -r "/home/$TO_USER/"
fi
else
- phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$TO_DOMAIN")
- cd $TO_FOLDER
echo "=== Replacing $FROM_DOMAIN to $TO_DOMAIN in database $TO_DATABASE_NAME"
- sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp search-replace "$FROM_DOMAIN" "$TO_DOMAIN" --precise --all-tables --skip-columns=guid --skip-plugins=$(sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
+ /usr/local/vesta/bin/v-run-wp-cli $TO_DOMAIN search-replace "$FROM_DOMAIN" "$TO_DOMAIN" --precise --all-tables --skip-columns=guid --skip-plugins --skip-themes;
if [ "$FROM_USER" != "$TO_USER" ]; then
echo "=== Replacing /home/$FROM_USER/ to /home/$TO_USER/ in database $TO_DATABASE_NAME"
- sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp search-replace "/home/$FROM_USER/" "/home/$TO_USER/" --precise --all-tables --skip-columns=guid --skip-plugins=$(sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
+ /usr/local/vesta/bin/v-run-wp-cli $TO_DOMAIN search-replace "/home/$FROM_USER/" "/home/$TO_USER/" --precise --all-tables --skip-columns=guid --skip-plugins --skip-themes;
fi
- sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp cache flush --skip-plugins=$(sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
- sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp config shuffle-salts WP_CACHE_KEY_SALT --force --skip-plugins=$(sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
- sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp config shuffle-salts --skip-plugins=$(sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
+ /usr/local/vesta/bin/v-run-wp-cli $TO_DOMAIN cache flush --skip-plugins --skip-themes;
+ /usr/local/vesta/bin/v-run-wp-cli $TO_DOMAIN config shuffle-salts WP_CACHE_KEY_SALT --force --skip-plugins --skip-themes;
+ /usr/local/vesta/bin/v-run-wp-cli $TO_DOMAIN config shuffle-salts --skip-plugins --skip-themes;
fi
# ----------- Update Wordfence WAF Path -------------
diff --git a/bin/v-install-wordfence-cli b/bin/v-install-wordfence-cli
new file mode 100644
index 00000000..e69de29b
diff --git a/bin/v-install-wordpress b/bin/v-install-wordpress
index 3f21d172..ba4d38c2 100644
--- a/bin/v-install-wordpress
+++ b/bin/v-install-wordpress
@@ -71,12 +71,12 @@ if [ -z "$email" ]; then
fi
if [ ! -d "/home/$user" ]; then
- echo "User doesn't exist";
+ echo "= Error: Folder /home/$user doesn't exist";
exit 1;
fi
if [ ! -d "/home/$user/web/$domain/public_html" ]; then
- echo "Domain doesn't exist";
+ echo "= Error: Folder /home/$user/web/$domain/public_html doesn't exist";
exit 1;
fi
@@ -138,24 +138,35 @@ fi
/usr/local/vesta/bin/v-add-database "$user" "$DBUSERSUF" "$DBUSERSUF" "$PASSWDDB" "mysql"
-if [ ! -f "/usr/local/bin/wp" ]; then
- echo "=== Downloading latest wp-cli"
- wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
- chmod +x /usr/local/bin/wp
+if [ ! -f "/usr/local/bin/wp" ] || [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ echo "= WP CLI is not installed. Installing..."
+ /usr/local/vesta/bin/v-install-wp-cli
+fi
+if [ ! -f "/usr/local/bin/wp" ] && [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ exit 1;
fi
WORKINGDIR="/home/$user/web/$domain/public_html"
rm -rf $WORKINGDIR/*
cd $WORKINGDIR
-sudo -H -u$user wp core download
-sudo -H -u$user wp core config --dbname=$DBUSER --dbuser=$DBUSER --dbpass=$PASSWDDB
+/usr/local/vesta/bin/v-run-wp-cli $domain core download
+if [ ! -f "$WORKINGDIR/index.php" ]; then
+ echo "= WordPress installation failed: WordPress core download failed."
+ exit 1;
+fi
+
+/usr/local/vesta/bin/v-run-wp-cli $domain core config --dbname=$DBUSER --dbuser=$DBUSER --dbpass=$PASSWDDB
+if [ ! -f "$WORKINGDIR/wp-config.php" ]; then
+ echo "= WordPress installation failed: WordPress core config failed, wp-config.php not found."
+ exit 1;
+fi
password=$(LC_CTYPE=C tr -dc A-Za-z0-9_\!\@\#\$\%\^\&\*\(\)-+= < /dev/urandom | head -c 12)
wpadmin=$(echo "$domain" | sed 's#\.#_#g')_4dm1n
-sudo -H -u$user wp core install --url="$domain" --title="$domain" --admin_user="$wpadmin" --admin_password="$password" --admin_email="$email" --path=$WORKINGDIR
+/usr/local/vesta/bin/v-run-wp-cli $domain core install --url="$domain" --title="$domain" --admin_user="$wpadmin" --admin_password="$password" --admin_email="$email" --path=$WORKINGDIR
mysql -u$DBUSER -p$PASSWDDB -e "USE $DBUSER; update wp_options set option_value = '$PROTOCOL://$domain' where option_name = 'siteurl'; update wp_options set option_value = '$PROTOCOL://$domain' where option_name = 'home';"
diff --git a/bin/v-get-wp-cli b/bin/v-install-wp-cli
similarity index 60%
rename from bin/v-get-wp-cli
rename to bin/v-install-wp-cli
index c097a024..e9be765d 100644
--- a/bin/v-get-wp-cli
+++ b/bin/v-install-wp-cli
@@ -24,10 +24,16 @@ if [ ! -f "/usr/local/bin/composer" ]; then
fi
if [ -d "/usr/local/bin/wp-cli" ]; then
- echo "= Removing old WP CLI..."
+ echo "= Removing old myVesta WP CLI..."
rm -rf /usr/local/bin/wp-cli
fi
+echo "= Installing classic WP CLI..."
+wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
+chmod +x /usr/local/bin/wp
+
+echo "= Installing myVesta WP CLI..."
+
cd /usr/local/bin
git clone https://github.com/wp-cli/wp-cli.git
@@ -36,9 +42,21 @@ chown -R www-data:www-data wp-cli
cd wp-cli/
sudo -H -u www-data composer install
+echo "= Installing search-replace-command package..."
+sudo -H -u www-data WP_CLI_PACKAGES_DIR=/usr/local/bin/wp-cli/packages php /usr/local/bin/wp-cli/php/boot-fs.php package install wp-cli/search-replace-command
+
# Fix terminal columns issue for WP CLI
+echo "= Fixing terminal columns issue for WP CLI..."
/usr/local/vesta/bin/v-sed '$columns = 80;' "if (file_exists('/usr/local/bin/wp-cli/COLUMNS')) \$columns=intval(file_get_contents('/usr/local/bin/wp-cli/COLUMNS')); else \$columns = 80;" '/usr/local/bin/wp-cli/vendor/wp-cli/php-cli-tools/lib/cli/Shell.php'
-echo "= WP CLI installed successfully."
+echo ""
-exit 0;
\ No newline at end of file
+if [ -f "/usr/local/bin/wp-cli/php/boot-fs.php" ] || [ -f "/usr/local/bin/wp" ]; then
+ echo "= WP CLI installed successfully."
+ echo "= Usage: v-run-wp-cli DOMAIN WP_CLI_COMMAND"
+ exit 0;
+else
+ echo "= WP CLI installation failed."
+ echo "= Please install it manually."
+ exit 1;
+fi
diff --git a/bin/v-migrate-site-to-https b/bin/v-migrate-site-to-https
index b6f4295b..1df0f0d5 100644
--- a/bin/v-migrate-site-to-https
+++ b/bin/v-migrate-site-to-https
@@ -40,6 +40,14 @@ is_format_valid 'domain' 'user'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
+if [ ! -f "/usr/local/bin/wp" ] || [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ echo "= WP CLI is not installed. Installing..."
+ /usr/local/vesta/bin/v-install-wp-cli
+fi
+if [ ! -f "/usr/local/bin/wp" ] && [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ exit 1;
+fi
+
FROM_DATABASE_NAME=''
FROM_DATABASE_USERNAME=''
FROM_DATABASE_PASSWORD=''
@@ -113,10 +121,12 @@ if [ $IT_IS_WP -eq 0 ]; then
git clone https://github.com/interconnectit/Search-Replace-DB.git
fi
else
- if [ ! -f "/usr/local/bin/wp" ]; then
- echo "=== Downloading latest wp-cli"
- wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
- chmod +x /usr/local/bin/wp
+ if [ ! -f "/usr/local/bin/wp" ] || [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ echo "= WP CLI is not installed. Installing..."
+ /usr/local/vesta/bin/v-install-wp-cli
+ fi
+ if [ ! -f "/usr/local/bin/wp" ] && [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ exit 1;
fi
fi
@@ -172,9 +182,9 @@ if [ $IT_IS_WP -eq 0 ]; then
else
cd $SITE_FOLDER
echo "=== Replacing $FROM_REPLACE1 to $TO_REPLACE1 in database $FROM_DATABASE_NAME"
- sudo -H -u$FROM_USER /usr/bin/php$phpver /usr/local/bin/wp search-replace "$FROM_REPLACE1" "$TO_REPLACE1" --precise --all-tables --skip-columns=guid --skip-plugins=$(sudo -H -u$FROM_USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
+ /usr/local/vesta/bin/v-run-wp-cli $FROM_DOMAIN search-replace "$FROM_REPLACE1" "$TO_REPLACE1" --precise --all-tables --skip-columns=guid --skip-plugins --skip-themes;
echo "=== Replacing $FROM_REPLACE2 to $TO_REPLACE2 in database $FROM_DATABASE_NAME"
- sudo -H -u$FROM_USER /usr/bin/php$phpver /usr/local/bin/wp search-replace "$FROM_REPLACE2" "$TO_REPLACE2" --precise --all-tables --skip-columns=guid --skip-plugins=$(sudo -H -u$FROM_USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
+ /usr/local/vesta/bin/v-run-wp-cli $FROM_DOMAIN search-replace "$FROM_REPLACE2" "$TO_REPLACE2" --precise --all-tables --skip-columns=guid --skip-plugins --skip-themes;
fi
echo "===== DONE ===="
diff --git a/bin/v-run-wp-cli b/bin/v-run-wp-cli
index ef4f6e10..c0c37d25 100644
--- a/bin/v-run-wp-cli
+++ b/bin/v-run-wp-cli
@@ -45,28 +45,37 @@ is_object_unsuspended 'user' 'USER' "$user"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
if [ ! -d "/home/$user" ]; then
- # echo "User doesn't exist";
+ echo "= User doesn't exist";
exit 1;
fi
-if [ ! -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
- echo 'Please install WordPress first.'
+if [[ "$wp_command" != core\ download* ]] && [[ "$wp_command" != core\ config* ]] && [ ! -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
+ echo '= Please install WordPress first.'
exit 1;
fi
-if ! command -v wp &> /dev/null; then
- echo "WP CLI is not installed. Installing..."
- wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
- chmod +x /usr/local/bin/wp
- echo "WP CLI installed successfully."
+wpcli=""
+
+if [ ! -f "/usr/local/bin/wp" ] || [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ echo "= WP CLI is not installed. Installing..."
+ /usr/local/vesta/bin/v-install-wp-cli
fi
-wpcli="/usr/local/bin/wp"
+if [ -f "/usr/local/bin/wp" ]; then
+ wpcli="/usr/local/bin/wp"
+ WP_CLI_PACKAGES_DIR=""
+fi
-if [ -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+if [ -f "/usr/local/bin/wp-cli/php/boot-fs.php" ] && [ -d "/usr/local/bin/wp-cli/packages/vendor/wp-cli/search-replace-command" ] && [ -z "$USE_WP_CLI_BUNDLED" ]; then
wpcli="/usr/local/bin/wp-cli/php/boot-fs.php"
COLUMNS=$(/usr/bin/env stty size 2>/dev/null | awk '{print $2}')
echo $COLUMNS > /usr/local/bin/wp-cli/COLUMNS
+ WP_CLI_PACKAGES_DIR="WP_CLI_PACKAGES_DIR=/usr/local/bin/wp-cli/packages"
+fi
+
+if [ -z "$wpcli" ]; then
+ echo "= WP CLI is not installed. Please install it manually."
+ exit 1;
fi
mkdir -p /home/$user/.wp-cli
@@ -83,7 +92,20 @@ fi
#----------------------------------------------------------#
cd /home/$USER/web/$domain/public_html
-sudo -u $USER /usr/bin/php$phpver -d disable_functions=pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,exec,system,passthru,shell_exec,proc_open,popen -d open_basedir=/home/$user/web/$domain:/home/$user/.wp-cli:/home/$user/tmp:/usr/local/bin $wpcli --path=/home/$user/web/$domain/public_html/ $wp_command 2>/home/$user/web/$domain/wp-cli-error.log
+
+if [ -z "$OPEN_BASEDIR" ]; then
+ OPEN_BASEDIR="/home/$user/web/$domain:/home/$user/.wp-cli:/home/$user/tmp:/usr/local/bin:/tmp"
+fi
+
+if [ -z "$DISABLE_FUNCTIONS" ]; then
+ DISABLE_FUNCTIONS="pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,exec,system,passthru,shell_exec,proc_open,popen"
+fi
+
+if [ -z "$SHOW_ERRORS" ]; then
+ sudo -u $USER $WP_CLI_PACKAGES_DIR /usr/bin/php$phpver -d disable_functions=$DISABLE_FUNCTIONS -d open_basedir=$OPEN_BASEDIR $wpcli --path=/home/$user/web/$domain/public_html/ $wp_command 2>/home/$user/web/$domain/wp-cli-error.log
+else
+ sudo -u $USER $WP_CLI_PACKAGES_DIR /usr/bin/php$phpver -d disable_functions=$DISABLE_FUNCTIONS -d open_basedir=$OPEN_BASEDIR $wpcli --path=/home/$user/web/$domain/public_html/ $wp_command
+fi
return_code=$?
From 35653eec54bb105cc383a5cbd255fc1ad0791d32 Mon Sep 17 00:00:00 2001
From: Peca
Date: Sat, 26 Jul 2025 22:00:22 +0200
Subject: [PATCH 288/304] Add WordFence CLI installation script
---
bin/v-desinfect-wordpress | 5 +++++
bin/v-install-wordfence-cli | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/bin/v-desinfect-wordpress b/bin/v-desinfect-wordpress
index fcdc2f66..51ee217e 100644
--- a/bin/v-desinfect-wordpress
+++ b/bin/v-desinfect-wordpress
@@ -27,6 +27,11 @@ if [ -z "$user" ]; then
exit 1
fi
+if [ ! -f "/usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate" ]; then
+ echo "= WordFence CLI is not installed. Installing..."
+ /usr/local/vesta/bin/v-install-wordfence-cli
+fi
+
# absolute paths to maintenance scripts, in desired order
declare -a tasks=(
"/usr/local/vesta/bin/v-change-database-password-for-wordpress"
diff --git a/bin/v-install-wordfence-cli b/bin/v-install-wordfence-cli
index e69de29b..fc6ca0b5 100644
--- a/bin/v-install-wordfence-cli
+++ b/bin/v-install-wordfence-cli
@@ -0,0 +1,37 @@
+#!/bin/bash
+# info: Script for installing WordFence CLI
+# options: NONE
+
+if ! command -v git &> /dev/null; then
+ echo "= Git is not installed. Installing..."
+ apt-get update > /dev/null 2>&1
+ apt-get install -y git
+fi
+
+cd /root
+
+if [ ! -d "myvesta-wordfence-cli" ]; then
+ git clone https://github.com/isscbta/myvesta-wordfence-cli.git
+ cd ~/myvesta-wordfence-cli/
+else
+ cd ~/myvesta-wordfence-cli/
+ git pull
+fi
+
+echo ""
+echo "----------------------------------------------------------------"
+echo ""
+echo "Which Docker container do you want to install for WordFence CLI?"
+echo "1. WordFence CLI official Docker container"
+echo "2. WordFence CLI Docker container maintained by myVesta"
+read -r -p "Enter your choice: " choice < /dev/tty
+
+if [ "$choice" == "1" ]; then
+ bash wf-cli-install.sh
+fi
+
+if [ "$choice" == "2" ]; then
+ bash wf-cli-install-our-image.sh
+fi
+
+exit 0;
From 95ed753b0b1bb3bf8bd7aad2631bc55093f22092 Mon Sep 17 00:00:00 2001
From: Peca
Date: Sun, 27 Jul 2025 18:07:14 +0200
Subject: [PATCH 289/304] Separating v-install-wp-cli-myvesta. Update
v-run-wp-cli to display error log if PHP Fatal Error occured. Updating
v-run-wp-cli to use standard wp-cli, making v-run-wp-cli-myvesta for myvesta
version of wp-cli.
---
bin/v-install-wp-cli | 39 ++----------------------
bin/v-install-wp-cli-myvesta | 58 ++++++++++++++++++++++++++++++++++++
bin/v-run-wp-cli | 18 +++++++----
bin/v-run-wp-cli-myvesta | 8 +++++
4 files changed, 81 insertions(+), 42 deletions(-)
create mode 100644 bin/v-install-wp-cli-myvesta
create mode 100644 bin/v-run-wp-cli-myvesta
diff --git a/bin/v-install-wp-cli b/bin/v-install-wp-cli
index e9be765d..17df71e8 100644
--- a/bin/v-install-wp-cli
+++ b/bin/v-install-wp-cli
@@ -12,46 +12,11 @@ if [ "$whoami" != "root" ]; then
exit 1
fi
-# Importing system environment
-source /etc/profile
-
-if [ ! -f "/usr/local/bin/composer" ]; then
- echo "= Composer is not installed. Installing..."
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php composer-setup.php --install-dir=/usr/local/bin --filename=composer
- php -r "unlink('composer-setup.php');"
- echo "= Composer installed successfully."
-fi
-
-if [ -d "/usr/local/bin/wp-cli" ]; then
- echo "= Removing old myVesta WP CLI..."
- rm -rf /usr/local/bin/wp-cli
-fi
-
-echo "= Installing classic WP CLI..."
+echo "= Installing WP CLI by downloading phar file..."
wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
chmod +x /usr/local/bin/wp
-echo "= Installing myVesta WP CLI..."
-
-cd /usr/local/bin
-git clone https://github.com/wp-cli/wp-cli.git
-
-chown -R www-data:www-data wp-cli
-
-cd wp-cli/
-sudo -H -u www-data composer install
-
-echo "= Installing search-replace-command package..."
-sudo -H -u www-data WP_CLI_PACKAGES_DIR=/usr/local/bin/wp-cli/packages php /usr/local/bin/wp-cli/php/boot-fs.php package install wp-cli/search-replace-command
-
-# Fix terminal columns issue for WP CLI
-echo "= Fixing terminal columns issue for WP CLI..."
-/usr/local/vesta/bin/v-sed '$columns = 80;' "if (file_exists('/usr/local/bin/wp-cli/COLUMNS')) \$columns=intval(file_get_contents('/usr/local/bin/wp-cli/COLUMNS')); else \$columns = 80;" '/usr/local/bin/wp-cli/vendor/wp-cli/php-cli-tools/lib/cli/Shell.php'
-
-echo ""
-
-if [ -f "/usr/local/bin/wp-cli/php/boot-fs.php" ] || [ -f "/usr/local/bin/wp" ]; then
+if [ -f "/usr/local/bin/wp" ]; then
echo "= WP CLI installed successfully."
echo "= Usage: v-run-wp-cli DOMAIN WP_CLI_COMMAND"
exit 0;
diff --git a/bin/v-install-wp-cli-myvesta b/bin/v-install-wp-cli-myvesta
new file mode 100644
index 00000000..f619626f
--- /dev/null
+++ b/bin/v-install-wp-cli-myvesta
@@ -0,0 +1,58 @@
+#!/bin/bash
+# info: Download myVesta WP CLI
+# options: NONE
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+whoami=$(whoami)
+if [ "$whoami" != "root" ]; then
+ echo "You must be root to execute this script"
+ exit 1
+fi
+
+# Importing system environment
+source /etc/profile
+
+if [ ! -f "/usr/local/bin/composer" ]; then
+ echo "= Composer is not installed. Installing..."
+ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
+ php composer-setup.php --install-dir=/usr/local/bin --filename=composer
+ php -r "unlink('composer-setup.php');"
+ echo "= Composer installed successfully."
+fi
+
+if [ -d "/usr/local/bin/wp-cli" ]; then
+ echo "= Removing old myVesta WP CLI..."
+ rm -rf /usr/local/bin/wp-cli
+fi
+
+echo "= Installing myVesta WP CLI..."
+
+cd /usr/local/bin
+git clone https://github.com/wp-cli/wp-cli.git
+
+chown -R www-data:www-data wp-cli
+
+cd wp-cli/
+sudo -H -u www-data composer install
+
+echo "= Installing search-replace-command package..."
+sudo -H -u www-data WP_CLI_PACKAGES_DIR=/usr/local/bin/wp-cli/packages php /usr/local/bin/wp-cli/php/boot-fs.php package install wp-cli/search-replace-command
+
+# Fix terminal columns issue for WP CLI
+echo "= Fixing terminal columns issue for WP CLI..."
+/usr/local/vesta/bin/v-sed '$columns = 80;' "if (file_exists('/usr/local/bin/wp-cli/COLUMNS')) \$columns=intval(file_get_contents('/usr/local/bin/wp-cli/COLUMNS')); else \$columns = 80;" '/usr/local/bin/wp-cli/vendor/wp-cli/php-cli-tools/lib/cli/Shell.php'
+
+echo ""
+
+if [ -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ echo "= myVesta WP CLI installed successfully."
+ echo "= Usage: v-run-wp-cli-myvesta DOMAIN WP_CLI_COMMAND"
+ exit 0;
+else
+ echo "= myVesta WP CLI installation failed."
+ echo "= Please install it manually."
+ exit 1;
+fi
diff --git a/bin/v-run-wp-cli b/bin/v-run-wp-cli
index c0c37d25..999e30a8 100644
--- a/bin/v-run-wp-cli
+++ b/bin/v-run-wp-cli
@@ -61,12 +61,19 @@ if [ ! -f "/usr/local/bin/wp" ] || [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php
/usr/local/vesta/bin/v-install-wp-cli
fi
+output='terminal'
+if [ -t 1 ]; then
+ output='terminal'
+else
+ output='file'
+fi
+
if [ -f "/usr/local/bin/wp" ]; then
wpcli="/usr/local/bin/wp"
WP_CLI_PACKAGES_DIR=""
fi
-if [ -f "/usr/local/bin/wp-cli/php/boot-fs.php" ] && [ -d "/usr/local/bin/wp-cli/packages/vendor/wp-cli/search-replace-command" ] && [ -z "$USE_WP_CLI_BUNDLED" ]; then
+if [ ! -z "$USE_WP_CLI_MYVESTA" ] && [ -f "/usr/local/bin/wp-cli/php/boot-fs.php" ] && [ -d "/usr/local/bin/wp-cli/packages/vendor/wp-cli/search-replace-command" ] && [ "$output" == "terminal" ]; then
wpcli="/usr/local/bin/wp-cli/php/boot-fs.php"
COLUMNS=$(/usr/bin/env stty size 2>/dev/null | awk '{print $2}')
echo $COLUMNS > /usr/local/bin/wp-cli/COLUMNS
@@ -113,10 +120,11 @@ if [ -f "/usr/local/bin/wp-cli/COLUMNS" ]; then
rm /usr/local/bin/wp-cli/COLUMNS
fi
-# echo "WP CLI: Done."
-# echo "To see Warning/Error log: "
-# echo "cat /home/$user/web/$domain/wp-cli-error.log"
-
+if [ -z "$SHOW_ERRORS" ]; then
+ if grep -q "PHP Fatal error" /home/$user/web/$domain/wp-cli-error.log || [ $return_code -ne 0 ]; then
+ cat /home/$user/web/$domain/wp-cli-error.log
+ fi
+fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
diff --git a/bin/v-run-wp-cli-myvesta b/bin/v-run-wp-cli-myvesta
new file mode 100644
index 00000000..e250a8ee
--- /dev/null
+++ b/bin/v-run-wp-cli-myvesta
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+if [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ echo "= myVesta WP CLI is not installed. Installing..."
+ /usr/local/vesta/bin/v-install-wp-cli-myvesta
+fi
+
+USE_WP_CLI_MYVESTA=1 /usr/local/vesta/bin/v-run-wp-cli "$@"
From ef8d033b60e0dd6e1a1a9fa2bad9eaf7d7dd0e0f Mon Sep 17 00:00:00 2001
From: Peca
Date: Wed, 30 Jul 2025 16:18:20 +0200
Subject: [PATCH 290/304] Enhance v-run-wp-cli and v-run-wp-cli-myvesta to
check for file age and update if older than 30 days
---
bin/v-run-wp-cli | 18 ++++++++++++++++--
bin/v-run-wp-cli-myvesta | 13 +++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/bin/v-run-wp-cli b/bin/v-run-wp-cli
index 999e30a8..e4a3d4a7 100644
--- a/bin/v-run-wp-cli
+++ b/bin/v-run-wp-cli
@@ -61,7 +61,21 @@ if [ ! -f "/usr/local/bin/wp" ] || [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php
/usr/local/vesta/bin/v-install-wp-cli
fi
-output='terminal'
+if [ -z "$USE_WP_CLI_MYVESTA" ]; then
+ if [ -f "/usr/local/bin/wp" ]; then
+ # Get current time and file ctime in seconds since epoch
+ current_time=$(date +%s)
+ file_ctime=$(stat -c %Z /usr/local/bin/wp)
+ # Calculate age in days
+ age_days=$(( (current_time - file_ctime) / 86400 ))
+ if [ "$age_days" -gt 30 ]; then
+ echo "= The /usr/local/bin/wp file is older than 30 days (based on CTime)."
+ echo "= Updating WP CLI..."
+ /usr/local/vesta/bin/v-install-wp-cli
+ fi
+ fi
+fi
+
if [ -t 1 ]; then
output='terminal'
else
@@ -73,7 +87,7 @@ if [ -f "/usr/local/bin/wp" ]; then
WP_CLI_PACKAGES_DIR=""
fi
-if [ ! -z "$USE_WP_CLI_MYVESTA" ] && [ -f "/usr/local/bin/wp-cli/php/boot-fs.php" ] && [ -d "/usr/local/bin/wp-cli/packages/vendor/wp-cli/search-replace-command" ] && [ "$output" == "terminal" ]; then
+if [ ! -z "$USE_WP_CLI_MYVESTA" ] && [ -f "/usr/local/bin/wp-cli/php/boot-fs.php" ] && [ -d "/usr/local/bin/wp-cli/packages/vendor/wp-cli/search-replace-command" ] && [ "$output" == "terminal" ]; then
wpcli="/usr/local/bin/wp-cli/php/boot-fs.php"
COLUMNS=$(/usr/bin/env stty size 2>/dev/null | awk '{print $2}')
echo $COLUMNS > /usr/local/bin/wp-cli/COLUMNS
diff --git a/bin/v-run-wp-cli-myvesta b/bin/v-run-wp-cli-myvesta
index e250a8ee..5947edfa 100644
--- a/bin/v-run-wp-cli-myvesta
+++ b/bin/v-run-wp-cli-myvesta
@@ -5,4 +5,17 @@ if [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
/usr/local/vesta/bin/v-install-wp-cli-myvesta
fi
+if [ -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+ # Get current time and file ctime in seconds since epoch
+ current_time=$(date +%s)
+ file_ctime=$(stat -c %Z /usr/local/bin/wp-cli/php/boot-fs.php)
+ # Calculate age in days
+ age_days=$(( (current_time - file_ctime) / 86400 ))
+ if [ "$age_days" -gt 30 ]; then
+ echo "= The /usr/local/bin/wp-cli/php/boot-fs.php file is older than 30 days (based on CTime)."
+ echo "= Updating myVesta WP CLI..."
+ /usr/local/vesta/bin/v-install-wp-cli-myvesta
+ fi
+fi
+
USE_WP_CLI_MYVESTA=1 /usr/local/vesta/bin/v-run-wp-cli "$@"
From 48944af1826e8bb2dd1540094b6bf561003f207f Mon Sep 17 00:00:00 2001
From: Peca
Date: Wed, 30 Jul 2025 18:14:25 +0200
Subject: [PATCH 291/304] Update v-install-wp-cli-myvesta to set PHP version
dynamically based on the oldest installed version and revert to the current
version after installation
---
bin/v-install-wp-cli-myvesta | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/bin/v-install-wp-cli-myvesta b/bin/v-install-wp-cli-myvesta
index f619626f..b65479f6 100644
--- a/bin/v-install-wp-cli-myvesta
+++ b/bin/v-install-wp-cli-myvesta
@@ -35,12 +35,33 @@ git clone https://github.com/wp-cli/wp-cli.git
chown -R www-data:www-data wp-cli
+ver_ge() {
+ # usage: ver_ge 7.2 5.6 --> returns true if $1 is greater than or equal to $2
+ [ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$2" ]
+}
+
+current_php_version=$(readlink -f /usr/bin/php | grep -oP 'php\K[0-9]+\.[0-9]+')
+
+php_versions=$(/usr/local/vesta/bin/v-list-php)
+for php_version in $php_versions; do
+ if ver_ge "$php_version" "7.2"; then
+ oldest_allowed_php_version=$php_version
+ break
+ fi
+done
+
+echo "= Setting PHP version to $oldest_allowed_php_version"
+update-alternatives --set php /usr/bin/php$oldest_allowed_php_version
+
cd wp-cli/
sudo -H -u www-data composer install
echo "= Installing search-replace-command package..."
sudo -H -u www-data WP_CLI_PACKAGES_DIR=/usr/local/bin/wp-cli/packages php /usr/local/bin/wp-cli/php/boot-fs.php package install wp-cli/search-replace-command
+echo "= Setting PHP version to $current_php_version"
+update-alternatives --set php /usr/bin/php$current_php_version
+
# Fix terminal columns issue for WP CLI
echo "= Fixing terminal columns issue for WP CLI..."
/usr/local/vesta/bin/v-sed '$columns = 80;' "if (file_exists('/usr/local/bin/wp-cli/COLUMNS')) \$columns=intval(file_get_contents('/usr/local/bin/wp-cli/COLUMNS')); else \$columns = 80;" '/usr/local/bin/wp-cli/vendor/wp-cli/php-cli-tools/lib/cli/Shell.php'
From 46a6ebafb0ad8a4a09008a21859b6dd2b0d3f9eb Mon Sep 17 00:00:00 2001
From: Peca
Date: Fri, 1 Aug 2025 19:42:16 +0200
Subject: [PATCH 292/304] Enhance v-commander to check for kernel updates and
reboot requirements
---
bin/v-commander | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/bin/v-commander b/bin/v-commander
index f04b3a17..72607c95 100644
--- a/bin/v-commander
+++ b/bin/v-commander
@@ -201,11 +201,9 @@ do
apt_upgraded=1
kernelupdate=$(grep -c 'linux-image-' /var/log/apt/history.log)
- if [ $kernelupdate -gt 0 ]; then
+ if [ $kernelupdate -gt 0 ] || [ -f "/run/reboot-required" ] || [ -f "/var/run/reboot-required" ]; then
touch /root/kernelupdate
- echo "== kernel is updated"
- else
- echo "== kernel is not updated"
+ echo "== kernel is updated, reboot is required!"
fi
fi
From cc09de9b6ec7e6104e5451ca2274822f3eaa8651 Mon Sep 17 00:00:00 2001
From: Peca
Date: Fri, 1 Aug 2025 19:46:28 +0200
Subject: [PATCH 293/304] v-fix-website-permissions: checks for php_chmod conf
files
---
bin/v-fix-website-permissions | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/bin/v-fix-website-permissions b/bin/v-fix-website-permissions
index 13c6775d..5c1eaca3 100644
--- a/bin/v-fix-website-permissions
+++ b/bin/v-fix-website-permissions
@@ -77,6 +77,15 @@ find public_html/ -type d ! -user $USER -exec chown $USER:$USER {} +
find public_html/ -type f ! \( -name "*.php" -o -name "*.env" \) ! -user $USER -exec chown $USER:$USER {} +
php_chmod="600"
+if [ -f "/home/php_chmod" ]; then
+ php_chmod=$(cat /home/php_chmod)
+fi
+if [ -f "/home/$USER/php_chmod" ]; then
+ php_chmod=$(cat /home/$USER/php_chmod)
+fi
+if [ -f "/home/$USER/web/php_chmod" ]; then
+ php_chmod=$(cat /home/$USER/web/php_chmod)
+fi
if [ -f "/home/$USER/web/$domain/php_chmod" ]; then
php_chmod=$(cat /home/$USER/web/$domain/php_chmod)
fi
From c1f2a02fb8a05f9147e8bbc4d6dffaed6bb0e97e Mon Sep 17 00:00:00 2001
From: Peca
Date: Fri, 1 Aug 2025 20:08:17 +0200
Subject: [PATCH 294/304] Implement cron job for fixing website permissions
---
install/vst-install-debian.sh | 4 +++-
src/deb/vesta/postinst | 10 ++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/install/vst-install-debian.sh b/install/vst-install-debian.sh
index f6de9e70..9517e4ef 100755
--- a/install/vst-install-debian.sh
+++ b/install/vst-install-debian.sh
@@ -1894,7 +1894,9 @@ command="sudo $VESTA/bin/v-update-user-stats"
$VESTA/bin/v-add-cron-job 'admin' '20' '00' '*' '*' '*' "$command"
command="sudo $VESTA/bin/v-update-sys-rrd"
$VESTA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command"
-service cron restart
+command="sudo $VESTA/bin/v-fix-website-permissions-for-all-websites > /dev/null 2>&1"
+$VESTA/bin/v-add-cron-job 'admin' '05' '03' '*' '*' '*' "$command"
+systemctl restart cron.service
echo "== Building inititall rrd images"
$VESTA/bin/v-update-sys-rrd
diff --git a/src/deb/vesta/postinst b/src/deb/vesta/postinst
index 68252789..d8a22ee1 100755
--- a/src/deb/vesta/postinst
+++ b/src/deb/vesta/postinst
@@ -21,10 +21,20 @@ if [ ! -d "/usr/local/vesta/data/upgrades" ]; then
mkdir -p /usr/local/vesta/data/upgrades
fi
+VESTA="/usr/local/vesta"
+
# show changelog after update
echo "1" > /usr/local/vesta/data/upgrades/show_changelog
chmod a=rw /usr/local/vesta/data/upgrades/show_changelog
+# Fixing permissions for all websites
+if ! grep -q "fix-website-permissions-for-all-websites" /usr/local/vesta/data/users/admin/cron.conf; then
+ echo "== Fixing permissions for all websites"
+ command="sudo $VESTA/bin/v-fix-website-permissions-for-all-websites > /dev/null 2>&1"
+ $VESTA/bin/v-add-cron-job 'admin' '05' '03' '*' '*' '*' "$command"
+ systemctl restart cron.service
+fi
+
if ! grep -q "FILEMANAGER_KEY='FREEFM'" /usr/local/vesta/conf/vesta.conf; then
echo "== Adding FileManager license to vesta.conf"
echo "FILEMANAGER_KEY='FREEFM'" >> /usr/local/vesta/conf/vesta.conf
From 97548e55fb76e9fd10913a0caedb08f535c9cb43 Mon Sep 17 00:00:00 2001
From: Peca
Date: Sun, 3 Aug 2025 15:00:29 +0200
Subject: [PATCH 295/304] Removing temporary Docker container network
interfaces from RRD
---
bin/v-update-sys-rrd-net | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/bin/v-update-sys-rrd-net b/bin/v-update-sys-rrd-net
index e9c642e4..d59eefd9 100755
--- a/bin/v-update-sys-rrd-net
+++ b/bin/v-update-sys-rrd-net
@@ -35,13 +35,15 @@ if [ ! -d "$RRD/net" ]; then
mkdir $RRD/net
fi
+find $RRD/net -name "veth*" -delete
+
# Parsing network interfaces
ndev=$(cat /proc/net/dev)
ifaces=$(echo "$ndev" |grep : |cut -f 1 -d : | sed "s/ //g")
# Parsing excludes
if [ -z "$RRD_IFACE_EXCLUDE" ]; then
- RRD_IFACE_EXCLUDE='lo'
+ RRD_IFACE_EXCLUDE='lo,'
fi
for exclude in $(echo ${RRD_IFACE_EXCLUDE//,/ }); do
ifaces=$(echo "$ifaces" |grep -vw "$exclude" )
@@ -62,6 +64,8 @@ for iface in $ifaces; do
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797
+ else
+ touch $RRD/net/$iface.rrd
fi
# Parsing device stats
@@ -112,6 +116,8 @@ for iface in $ifaces; do
done
+find $RRD/net -name "*.png" -mtime +1 -delete
+find $RRD/net -name "*.rrd" -mtime +1 -delete
#----------------------------------------------------------#
# Vesta #
From d18967e627f654fc980457ead8bd35d5466bd9e6 Mon Sep 17 00:00:00 2001
From: Peca
Date: Mon, 4 Aug 2025 11:07:07 +0200
Subject: [PATCH 296/304] Refactor v-run-wp-cli to simplify WP CLI installation
check by removing redundant file check for boot-fs.php
---
bin/v-run-wp-cli | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bin/v-run-wp-cli b/bin/v-run-wp-cli
index e4a3d4a7..b1e4e6aa 100644
--- a/bin/v-run-wp-cli
+++ b/bin/v-run-wp-cli
@@ -56,7 +56,7 @@ fi
wpcli=""
-if [ ! -f "/usr/local/bin/wp" ] || [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
+if [ ! -f "/usr/local/bin/wp" ]; then
echo "= WP CLI is not installed. Installing..."
/usr/local/vesta/bin/v-install-wp-cli
fi
From 8680995e66e820258bfaede558a5e144120856a8 Mon Sep 17 00:00:00 2001
From: Peca
Date: Mon, 4 Aug 2025 15:19:22 +0200
Subject: [PATCH 297/304] Avoid 600 permissions for Apache-less variant
---
bin/v-fix-user-permissions | 8 ++++----
bin/v-fix-website-permissions | 6 ++++++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/bin/v-fix-user-permissions b/bin/v-fix-user-permissions
index 991ada62..47690477 100644
--- a/bin/v-fix-user-permissions
+++ b/bin/v-fix-user-permissions
@@ -49,10 +49,10 @@ find /home/$user/mail/*/ -maxdepth 1 -type d -exec chmod g-rwx {} \;
find /home/$user/conf/dns/ -type f -exec chown root:bind {} \;
find /home/$user/conf/ -type d -exec chown root:root {} \;
-find /home/$user/web/*/public_html/ -type d -exec chmod 755 {} +
-find /home/$user/web/*/public_html/ -type f -exec chmod 644 {} +
-find /home/$user/web/*/public_html/ -exec chown $user:$user {} \;
-find /home/$user/web/*/ -name "*.php" -type f -exec chmod 600 {} +
+for domain in $(/usr/local/vesta/bin/v-list-web-domains $user plain |cut -f 1); do
+ /usr/local/vesta/bin/v-fix-website-permissions $domain $user
+ echo "--------------------------------"
+done
echo "Done, permissions fixed for user: $user"
diff --git a/bin/v-fix-website-permissions b/bin/v-fix-website-permissions
index 5c1eaca3..186075a1 100644
--- a/bin/v-fix-website-permissions
+++ b/bin/v-fix-website-permissions
@@ -28,6 +28,7 @@ USER=$user
# Includes
source /usr/local/vesta/func/main.sh
+source /usr/local/vesta/conf/vesta.conf
if [ -z "$user" ]; then
check_result $E_NOTEXIST "domain $domain doesn't exist"
@@ -77,6 +78,11 @@ find public_html/ -type d ! -user $USER -exec chown $USER:$USER {} +
find public_html/ -type f ! \( -name "*.php" -o -name "*.env" \) ! -user $USER -exec chown $USER:$USER {} +
php_chmod="600"
+
+if [ "$WEB_SYSTEM" = 'nginx' ]; then
+ php_chmod="644"
+fi
+
if [ -f "/home/php_chmod" ]; then
php_chmod=$(cat /home/php_chmod)
fi
From 4dc1e73612d07e80aad72c533d7fd10ed253834e Mon Sep 17 00:00:00 2001
From: Peca
Date: Mon, 4 Aug 2025 16:42:07 +0200
Subject: [PATCH 298/304] Remove redundant WP CLI installation checks from
multiple scripts
---
bin/v-add-wordpress-admin | 8 --------
bin/v-clone-website | 8 --------
bin/v-install-wordpress | 8 --------
bin/v-migrate-site-to-https | 15 ---------------
4 files changed, 39 deletions(-)
diff --git a/bin/v-add-wordpress-admin b/bin/v-add-wordpress-admin
index 20585485..60778fb2 100644
--- a/bin/v-add-wordpress-admin
+++ b/bin/v-add-wordpress-admin
@@ -63,14 +63,6 @@ if [ ! -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
exit 1;
fi
-if [ ! -f "/usr/local/bin/wp" ] || [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
- echo "= WP CLI is not installed. Installing..."
- /usr/local/vesta/bin/v-install-wp-cli
-fi
-if [ ! -f "/usr/local/bin/wp" ] && [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
- exit 1;
-fi
-
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
diff --git a/bin/v-clone-website b/bin/v-clone-website
index 0e089465..9bebbffd 100644
--- a/bin/v-clone-website
+++ b/bin/v-clone-website
@@ -264,14 +264,6 @@ if [ $IT_IS_WP -eq 0 ]; then
cd /root
git clone https://github.com/interconnectit/Search-Replace-DB.git
fi
-else
- if [ ! -f "/usr/local/bin/wp" ] || [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
- echo "= WP CLI is not installed. Installing..."
- /usr/local/vesta/bin/v-install-wp-cli
- fi
- if [ ! -f "/usr/local/bin/wp" ] && [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
- exit 1;
- fi
fi
CREATE_TO_DATABASE=0
diff --git a/bin/v-install-wordpress b/bin/v-install-wordpress
index ba4d38c2..f23afa74 100644
--- a/bin/v-install-wordpress
+++ b/bin/v-install-wordpress
@@ -138,14 +138,6 @@ fi
/usr/local/vesta/bin/v-add-database "$user" "$DBUSERSUF" "$DBUSERSUF" "$PASSWDDB" "mysql"
-if [ ! -f "/usr/local/bin/wp" ] || [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
- echo "= WP CLI is not installed. Installing..."
- /usr/local/vesta/bin/v-install-wp-cli
-fi
-if [ ! -f "/usr/local/bin/wp" ] && [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
- exit 1;
-fi
-
WORKINGDIR="/home/$user/web/$domain/public_html"
rm -rf $WORKINGDIR/*
cd $WORKINGDIR
diff --git a/bin/v-migrate-site-to-https b/bin/v-migrate-site-to-https
index 1df0f0d5..c15a521e 100644
--- a/bin/v-migrate-site-to-https
+++ b/bin/v-migrate-site-to-https
@@ -40,13 +40,6 @@ is_format_valid 'domain' 'user'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
-if [ ! -f "/usr/local/bin/wp" ] || [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
- echo "= WP CLI is not installed. Installing..."
- /usr/local/vesta/bin/v-install-wp-cli
-fi
-if [ ! -f "/usr/local/bin/wp" ] && [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
- exit 1;
-fi
FROM_DATABASE_NAME=''
FROM_DATABASE_USERNAME=''
@@ -120,14 +113,6 @@ if [ $IT_IS_WP -eq 0 ]; then
cd /root
git clone https://github.com/interconnectit/Search-Replace-DB.git
fi
-else
- if [ ! -f "/usr/local/bin/wp" ] || [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
- echo "= WP CLI is not installed. Installing..."
- /usr/local/vesta/bin/v-install-wp-cli
- fi
- if [ ! -f "/usr/local/bin/wp" ] && [ ! -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
- exit 1;
- fi
fi
From a183cabdc7ece59d29c37f0c3064779adb52c140 Mon Sep 17 00:00:00 2001
From: Peca
Date: Mon, 4 Aug 2025 16:50:52 +0200
Subject: [PATCH 299/304] v-install-wordpress: avoid changing nginx proxy
template in apache-less variant
---
bin/v-install-wordpress | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/bin/v-install-wordpress b/bin/v-install-wordpress
index f23afa74..25e38f3e 100644
--- a/bin/v-install-wordpress
+++ b/bin/v-install-wordpress
@@ -119,20 +119,22 @@ fi
TPL_CHANGED=0;
-if [ "$PROTOCOL" = "https" ]; then
- if [ -f "/usr/local/vesta/data/templates/web/nginx/force-https-firewall-wordpress.stpl" ] && [ $TPL_CHANGED -eq 0 ]; then
- TPL_CHANGED=1;
- /usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" "force-https-firewall-wordpress" "jpeg,jpg,png,gif,bmp,ico,svg,tif,tiff,css,js,ttf,otf,webp,txt,csv,rtf,doc,docx,xls,xlsx,ppt,pptx,odf,odp,ods,odt,pdf,psd,ai,eot,eps,ps,zip,tar,tgz,gz,rar,bz2,7z,aac,m4a,mp3,mp4,ogg,wav,wma,3gp,avi,flv,m4v,mkv,mov,mpeg,mpg,wmv,exe,iso,dmg,swf,woff,woff2" "yes"
+if [ "$WEB_SYSTEM" != 'nginx' ]; then
+ if [ "$PROTOCOL" = "https" ]; then
+ if [ -f "/usr/local/vesta/data/templates/web/nginx/force-https-firewall-wordpress.stpl" ] && [ $TPL_CHANGED -eq 0 ]; then
+ TPL_CHANGED=1;
+ /usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" "force-https-firewall-wordpress" "jpeg,jpg,png,gif,bmp,ico,svg,tif,tiff,css,js,ttf,otf,webp,txt,csv,rtf,doc,docx,xls,xlsx,ppt,pptx,odf,odp,ods,odt,pdf,psd,ai,eot,eps,ps,zip,tar,tgz,gz,rar,bz2,7z,aac,m4a,mp3,mp4,ogg,wav,wma,3gp,avi,flv,m4v,mkv,mov,mpeg,mpg,wmv,exe,iso,dmg,swf,woff,woff2" "yes"
+ fi
+ if [ -f "/usr/local/vesta/data/templates/web/nginx/force-https.stpl" ] && [ $TPL_CHANGED -eq 0 ]; then
+ TPL_CHANGED=1;
+ /usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" "force-https" "jpeg,jpg,png,gif,bmp,ico,svg,tif,tiff,css,js,ttf,otf,webp,txt,csv,rtf,doc,docx,xls,xlsx,ppt,pptx,odf,odp,ods,odt,pdf,psd,ai,eot,eps,ps,zip,tar,tgz,gz,rar,bz2,7z,aac,m4a,mp3,mp4,ogg,wav,wma,3gp,avi,flv,m4v,mkv,mov,mpeg,mpg,wmv,exe,iso,dmg,swf,woff,woff2" "yes"
+ fi
fi
- if [ -f "/usr/local/vesta/data/templates/web/nginx/force-https.stpl" ] && [ $TPL_CHANGED -eq 0 ]; then
- TPL_CHANGED=1;
- /usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" "force-https" "jpeg,jpg,png,gif,bmp,ico,svg,tif,tiff,css,js,ttf,otf,webp,txt,csv,rtf,doc,docx,xls,xlsx,ppt,pptx,odf,odp,ods,odt,pdf,psd,ai,eot,eps,ps,zip,tar,tgz,gz,rar,bz2,7z,aac,m4a,mp3,mp4,ogg,wav,wma,3gp,avi,flv,m4v,mkv,mov,mpeg,mpg,wmv,exe,iso,dmg,swf,woff,woff2" "yes"
- fi
-fi
-if [ "$PROTOCOL" = "http" ]; then
- if [ -f "/usr/local/vesta/data/templates/web/nginx/hosting-firewall-wordpress.stpl" ] && [ $TPL_CHANGED -eq 0 ]; then
- TPL_CHANGED=1;
- /usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" "hosting-firewall-wordpress" "jpeg,jpg,png,gif,bmp,ico,svg,tif,tiff,css,js,ttf,otf,webp,txt,csv,rtf,doc,docx,xls,xlsx,ppt,pptx,odf,odp,ods,odt,pdf,psd,ai,eot,eps,ps,zip,tar,tgz,gz,rar,bz2,7z,aac,m4a,mp3,mp4,ogg,wav,wma,3gp,avi,flv,m4v,mkv,mov,mpeg,mpg,wmv,exe,iso,dmg,swf,woff,woff2" "yes"
+ if [ "$PROTOCOL" = "http" ]; then
+ if [ -f "/usr/local/vesta/data/templates/web/nginx/hosting-firewall-wordpress.stpl" ] && [ $TPL_CHANGED -eq 0 ]; then
+ TPL_CHANGED=1;
+ /usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" "hosting-firewall-wordpress" "jpeg,jpg,png,gif,bmp,ico,svg,tif,tiff,css,js,ttf,otf,webp,txt,csv,rtf,doc,docx,xls,xlsx,ppt,pptx,odf,odp,ods,odt,pdf,psd,ai,eot,eps,ps,zip,tar,tgz,gz,rar,bz2,7z,aac,m4a,mp3,mp4,ogg,wav,wma,3gp,avi,flv,m4v,mkv,mov,mpeg,mpg,wmv,exe,iso,dmg,swf,woff,woff2" "yes"
+ fi
fi
fi
From 5008c2c778595f0a73d3e78bc55d7a62d37fe371 Mon Sep 17 00:00:00 2001
From: Peca
Date: Thu, 7 Aug 2025 18:29:11 +0200
Subject: [PATCH 300/304] Refactor v-fix-website-permissions to introduce
conditional checks for PHP and symlink ownership adjustments, allowing for
more flexible permission management based on configuration files.
---
bin/v-fix-website-permissions | 108 +++++++++++++++++++++++++---------
1 file changed, 79 insertions(+), 29 deletions(-)
diff --git a/bin/v-fix-website-permissions b/bin/v-fix-website-permissions
index 186075a1..fca37e15 100644
--- a/bin/v-fix-website-permissions
+++ b/bin/v-fix-website-permissions
@@ -68,40 +68,90 @@ if [ -z "$SKIP_OWNERSHIP_CHECK" ] && [ -f "public_html/index.php" ]; then
fi
fi
+echo "Updating permissions for /home/$USER/web/$domain/"
-echo "Updating permissions for /home/$USER/web/$domain/public_html/"
-# Fixing permissions
-find public_html/ -type d ! -perm 755 -exec chmod 755 {} +
-find public_html/ -type f ! \( -name "*.php" -o -name "*.env" \) ! -perm 644 -exec chmod 644 {} +
-# Fixing ownership
-find public_html/ -type d ! -user $USER -exec chown $USER:$USER {} +
-find public_html/ -type f ! \( -name "*.php" -o -name "*.env" \) ! -user $USER -exec chown $USER:$USER {} +
-
-php_chmod="600"
-
-if [ "$WEB_SYSTEM" = 'nginx' ]; then
- php_chmod="644"
+php_chmod_allowed=1
+if [ -f "/home/php_chmod_disabled" ]; then
+ php_chmod_allowed=0
+fi
+if [ -f "/home/$USER/php_chmod_disabled" ]; then
+ php_chmod_allowed=0
+fi
+if [ -f "/home/$USER/web/php_chmod_disabled" ]; then
+ php_chmod_allowed=0
+fi
+if [ -f "/home/$USER/web/$domain/php_chmod_disabled" ]; then
+ php_chmod_allowed=0
fi
-if [ -f "/home/php_chmod" ]; then
- php_chmod=$(cat /home/php_chmod)
-fi
-if [ -f "/home/$USER/php_chmod" ]; then
- php_chmod=$(cat /home/$USER/php_chmod)
-fi
-if [ -f "/home/$USER/web/php_chmod" ]; then
- php_chmod=$(cat /home/$USER/web/php_chmod)
-fi
-if [ -f "/home/$USER/web/$domain/php_chmod" ]; then
- php_chmod=$(cat /home/$USER/web/$domain/php_chmod)
+# === General files and directories permissions ===
+if [ "$php_chmod_allowed" -eq 1 ]; then
+ # New way of fixing permissions
+ # Fixing permissions
+ find public_html/ -type d ! -perm 755 -exec chmod 755 {} +
+ find public_html/ -type f ! \( -name "*.php" -o -name "*.env" \) ! -perm 644 -exec chmod 644 {} +
+
+ # Fixing ownership
+ find public_html/ -type d ! -user $USER -exec chown $USER:$USER {} +
+ find public_html/ -type f ! \( -name "*.php" -o -name "*.env" \) ! -user $USER -exec chown $USER:$USER {} +
+else
+ # Old way of fixing permissions
+ # Fixing permissions
+ find public_html/ -type d ! -perm 755 -exec chmod 755 {} +
+ find public_html/ -type f ! -perm 644 -exec chmod 644 {} +
+
+ # Fixing ownership
+ find public_html/ -type d ! -user $USER -exec chown $USER:$USER {} +
+ find public_html/ -type f ! -user $USER -exec chown $USER:$USER {} +
fi
-# Setting chmod 600 for all .php and .env files
-echo "= Setting chmod $php_chmod for all .php and .env files"
-# Fixing permissions
-find -type f \( -name "*.php" -o -name "*.env" \) ! -perm $php_chmod -exec chmod $php_chmod {} +
-# Fixing ownership
-find -type f \( -name "*.php" -o -name "*.env" \) ! -user $USER -exec chown $USER:$USER {} +
+# === PHP and .env permissions ===
+if [ "$php_chmod_allowed" -eq 1 ]; then
+ php_chmod="600"
+
+ if [ "$WEB_SYSTEM" = 'nginx' ]; then
+ php_chmod="644"
+ fi
+
+ if [ -f "/home/php_chmod" ]; then
+ php_chmod=$(cat /home/php_chmod)
+ fi
+ if [ -f "/home/$USER/php_chmod" ]; then
+ php_chmod=$(cat /home/$USER/php_chmod)
+ fi
+ if [ -f "/home/$USER/web/php_chmod" ]; then
+ php_chmod=$(cat /home/$USER/web/php_chmod)
+ fi
+ if [ -f "/home/$USER/web/$domain/php_chmod" ]; then
+ php_chmod=$(cat /home/$USER/web/$domain/php_chmod)
+ fi
+
+ # Setting chmod 600 for all .php and .env files
+ echo "= Setting chmod $php_chmod for all .php and .env files"
+ # Fixing permissions
+ find -type f \( -name "*.php" -o -name "*.env" \) ! -perm $php_chmod -exec chmod $php_chmod {} +
+ # Fixing ownership
+ find -type f \( -name "*.php" -o -name "*.env" \) ! -user $USER -exec chown $USER:$USER {} +
+fi
+
+# === Symlinks ownership ===
+symlink_chown_allowed=1
+if [ -f "/home/symlink_chown_disabled" ]; then
+ symlink_chown_allowed=0
+fi
+if [ -f "/home/$USER/symlink_chown_disabled" ]; then
+ symlink_chown_allowed=0
+fi
+if [ -f "/home/$USER/web/symlink_chown_disabled" ]; then
+ symlink_chown_allowed=0
+fi
+if [ -f "/home/$USER/web/$domain/symlink_chown_disabled" ]; then
+ symlink_chown_allowed=0
+fi
+
+if [ "$symlink_chown_allowed" -eq 1 ]; then
+ find -type l ! -user $USER -exec chown -h $USER:$USER {} +
+fi
#----------------------------------------------------------#
# Vesta #
From efe0045c5f7a7fa12ded564a4e7ee49df38cf152 Mon Sep 17 00:00:00 2001
From: Peca
Date: Thu, 7 Aug 2025 19:03:30 +0200
Subject: [PATCH 301/304] Introduction of v-fix-website-permissions-only-php
script
---
bin/v-fix-website-permissions | 6 +-
...site-permissions-for-all-websites-only-php | 44 +++++++
bin/v-fix-website-permissions-only-php | 121 ++++++++++++++++++
install/vst-install-debian.sh | 2 +-
src/deb/vesta/postinst | 19 ++-
5 files changed, 184 insertions(+), 8 deletions(-)
create mode 100644 bin/v-fix-website-permissions-for-all-websites-only-php
create mode 100644 bin/v-fix-website-permissions-only-php
diff --git a/bin/v-fix-website-permissions b/bin/v-fix-website-permissions
index fca37e15..50b143c8 100644
--- a/bin/v-fix-website-permissions
+++ b/bin/v-fix-website-permissions
@@ -1,6 +1,6 @@
#!/bin/bash
-# info: Fixing chown and chmod permissions in the public_html directory
-# options: DOMAIN
+# info: Fixing chown and chmod permissions for a website
+# options: DOMAIN [USER]
#----------------------------------------------------------#
# Variable&Function #
@@ -68,7 +68,7 @@ if [ -z "$SKIP_OWNERSHIP_CHECK" ] && [ -f "public_html/index.php" ]; then
fi
fi
-echo "Updating permissions for /home/$USER/web/$domain/"
+echo "Updating permissions and ownership for /home/$USER/web/$domain/"
php_chmod_allowed=1
if [ -f "/home/php_chmod_disabled" ]; then
diff --git a/bin/v-fix-website-permissions-for-all-websites-only-php b/bin/v-fix-website-permissions-for-all-websites-only-php
new file mode 100644
index 00000000..a89d2416
--- /dev/null
+++ b/bin/v-fix-website-permissions-for-all-websites-only-php
@@ -0,0 +1,44 @@
+#!/bin/bash
+# info: fix website permissions for all websites
+# options:
+#
+# The command is used for fixing website permissions for all websites on the server.
+
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+# Importing system variables
+source /etc/profile
+
+# Includes
+source $VESTA/func/main.sh
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+touch /usr/local/vesta/log/fix-website-permissions-for-all-websites-only-php.log
+truncate -s 0 /usr/local/vesta/log/fix-website-permissions-for-all-websites-only-php.log
+
+for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
+ if [ ! -f "/usr/local/vesta/data/users/$user/user.conf" ]; then
+ continue;
+ fi
+
+ for domain in $(/usr/local/vesta/bin/v-list-web-domains $user plain |cut -f 1); do
+ /usr/local/vesta/bin/v-fix-website-permissions-only-php $domain $user >> /usr/local/vesta/log/fix-website-permissions-for-all-websites-only-php.log 2>&1
+ echo "--------------------------------" >> /usr/local/vesta/log/fix-website-permissions-for-all-websites-only-php.log
+ done
+
+done
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$ARGUMENTS"
+
+exit
diff --git a/bin/v-fix-website-permissions-only-php b/bin/v-fix-website-permissions-only-php
new file mode 100644
index 00000000..cf548e6b
--- /dev/null
+++ b/bin/v-fix-website-permissions-only-php
@@ -0,0 +1,121 @@
+#!/bin/bash
+# info: Fixing PHP and .env permissions and ownership for a website
+# options: DOMAIN [USER]
+
+#----------------------------------------------------------#
+# Variable&Function #
+#----------------------------------------------------------#
+
+whoami=$(whoami)
+if [ "$whoami" != "root" ]; then
+ echo "You must be root to execute this script"
+ exit 1
+fi
+
+# Importing system environment
+source /etc/profile
+
+# Argument definition
+domain=$1
+
+# Check if number of arguments is 2
+if [ $# -eq 2 ]; then
+ user=$2
+else
+ user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
+fi
+USER=$user
+
+# Includes
+source /usr/local/vesta/func/main.sh
+source /usr/local/vesta/conf/vesta.conf
+
+if [ -z "$user" ]; then
+ check_result $E_NOTEXIST "domain $domain doesn't exist"
+fi
+
+#----------------------------------------------------------#
+# Verifications #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'DOMAIN'
+is_format_valid 'domain'
+is_object_valid 'user' 'USER' "$user"
+
+if [ ! -d "/home/$user" ]; then
+ echo "Error: Folder /home/$user doesn't exist";
+ exit 1;
+fi
+
+if [ ! -d "/home/$user/web/$domain/public_html" ]; then
+ echo "Error: Folder /home/$user/web/$domain/public_html doesn't exist";
+ exit 1;
+fi
+
+#----------------------------------------------------------#
+# Action #
+#----------------------------------------------------------#
+
+# Going to domain directory
+cd /home/$USER/web/$domain
+
+# Ownership check
+if [ -z "$SKIP_OWNERSHIP_CHECK" ] && [ -f "public_html/index.php" ]; then
+ owner=$(stat -c '%U' "public_html/index.php")
+ if [ "$owner" = "root" ] || [ "$owner" = "www-data" ]; then
+ echo "Skipping permission fix for $domain, because v-lock-wordpress is used (index.php is owned by $owner)"
+ exit 1
+ fi
+fi
+
+echo "Updating PHP and .env permissions and ownership for /home/$USER/web/$domain/"
+
+php_chmod_allowed=1
+if [ -f "/home/php_chmod_disabled" ]; then
+ php_chmod_allowed=0
+fi
+if [ -f "/home/$USER/php_chmod_disabled" ]; then
+ php_chmod_allowed=0
+fi
+if [ -f "/home/$USER/web/php_chmod_disabled" ]; then
+ php_chmod_allowed=0
+fi
+if [ -f "/home/$USER/web/$domain/php_chmod_disabled" ]; then
+ php_chmod_allowed=0
+fi
+
+# === PHP and .env permissions ===
+if [ "$php_chmod_allowed" -eq 1 ]; then
+ php_chmod="600"
+
+ if [ "$WEB_SYSTEM" = 'nginx' ]; then
+ php_chmod="644"
+ fi
+
+ if [ -f "/home/php_chmod" ]; then
+ php_chmod=$(cat /home/php_chmod)
+ fi
+ if [ -f "/home/$USER/php_chmod" ]; then
+ php_chmod=$(cat /home/$USER/php_chmod)
+ fi
+ if [ -f "/home/$USER/web/php_chmod" ]; then
+ php_chmod=$(cat /home/$USER/web/php_chmod)
+ fi
+ if [ -f "/home/$USER/web/$domain/php_chmod" ]; then
+ php_chmod=$(cat /home/$USER/web/$domain/php_chmod)
+ fi
+
+ # Setting chmod 600 for all .php and .env files
+ echo "= Setting chmod $php_chmod for all .php and .env files"
+ # Fixing permissions
+ find -type f \( -name "*.php" -o -name "*.env" \) ! -perm $php_chmod -exec chmod $php_chmod {} +
+ # Fixing ownership
+ find -type f \( -name "*.php" -o -name "*.env" \) ! -user $USER -exec chown $USER:$USER {} +
+fi
+
+#----------------------------------------------------------#
+# Vesta #
+#----------------------------------------------------------#
+echo "PHP and .env permissions and ownership for $domain have been successfully updated."
+
+exit 0
diff --git a/install/vst-install-debian.sh b/install/vst-install-debian.sh
index 9517e4ef..1c8f2e1b 100755
--- a/install/vst-install-debian.sh
+++ b/install/vst-install-debian.sh
@@ -1894,7 +1894,7 @@ command="sudo $VESTA/bin/v-update-user-stats"
$VESTA/bin/v-add-cron-job 'admin' '20' '00' '*' '*' '*' "$command"
command="sudo $VESTA/bin/v-update-sys-rrd"
$VESTA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command"
-command="sudo $VESTA/bin/v-fix-website-permissions-for-all-websites > /dev/null 2>&1"
+command="sudo $VESTA/bin/v-fix-website-permissions-for-all-websites-only-php"
$VESTA/bin/v-add-cron-job 'admin' '05' '03' '*' '*' '*' "$command"
systemctl restart cron.service
diff --git a/src/deb/vesta/postinst b/src/deb/vesta/postinst
index d8a22ee1..f5f79877 100755
--- a/src/deb/vesta/postinst
+++ b/src/deb/vesta/postinst
@@ -27,10 +27,21 @@ VESTA="/usr/local/vesta"
echo "1" > /usr/local/vesta/data/upgrades/show_changelog
chmod a=rw /usr/local/vesta/data/upgrades/show_changelog
-# Fixing permissions for all websites
-if ! grep -q "fix-website-permissions-for-all-websites" /usr/local/vesta/data/users/admin/cron.conf; then
- echo "== Fixing permissions for all websites"
- command="sudo $VESTA/bin/v-fix-website-permissions-for-all-websites > /dev/null 2>&1"
+if grep -q "fix-website-permissions-for-all-websites" /usr/local/vesta/data/users/admin/cron.conf; then
+ if ! grep -q "fix-website-permissions-for-all-websites-only-php" /usr/local/vesta/data/users/admin/cron.conf; then
+ echo "== Renaming fix-website-permissions-for-all-websites to fix-website-permissions-for-all-websites-only-php"
+ sed -i 's|v-fix-website-permissions-for-all-websites > /dev/null 2>&1|v-fix-website-permissions-for-all-websites-only-php|' /usr/local/vesta/data/users/admin/cron.conf
+ sed -i 's|v-fix-website-permissions-for-all-websites > /dev/null 2>&1|v-fix-website-permissions-for-all-websites-only-php|' /var/spool/cron/crontabs/admin
+ sed -i 's|v-fix-website-permissions-for-all-websites |v-fix-website-permissions-for-all-websites-only-php |' /usr/local/vesta/data/users/admin/cron.conf
+ sed -i 's|v-fix-website-permissions-for-all-websites |v-fix-website-permissions-for-all-websites-only-php |' /var/spool/cron/crontabs/admin
+ systemctl restart cron.service
+ fi
+fi
+
+# Fixing PHP and .env permissions and ownership for all websites
+if ! grep -q "fix-website-permissions-for-all-websites-only-php" /usr/local/vesta/data/users/admin/cron.conf; then
+ echo "== Fixing PHP and .env permissions and ownership for all websites"
+ command="sudo $VESTA/bin/v-fix-website-permissions-for-all-websites-only-php"
$VESTA/bin/v-add-cron-job 'admin' '05' '03' '*' '*' '*' "$command"
systemctl restart cron.service
fi
From 4fff4b498553e2545c674427296d271a0d16ee5f Mon Sep 17 00:00:00 2001
From: Cursor Agent
Date: Sun, 10 Aug 2025 11:48:54 +0000
Subject: [PATCH 302/304] Fix PHP 5.6 array index and implode compatibility
issues
Co-authored-by: peca
---
web/add/dns/index.php | 12 ++++++++++--
web/add/mail/index.php | 9 +++++++--
web/add/web/index.php | 6 +++++-
web/upload/UploadHandler.php | 9 +++++++--
4 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/web/add/dns/index.php b/web/add/dns/index.php
index 7c18faab..06ca9547 100644
--- a/web/add/dns/index.php
+++ b/web/add/dns/index.php
@@ -80,7 +80,11 @@ if (!empty($_POST['ok'])) {
// Flush field values on success
if (empty($_SESSION['error_msg'])) {
- $_SESSION['ok_msg'] = __('DNS_DOMAIN_CREATED_OK',htmlentities($_POST[v_domain]),htmlentities($_POST[v_domain]));
+ if (PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50700) {
+ $_SESSION['ok_msg'] = __('DNS_DOMAIN_CREATED_OK',htmlentities($_POST[v_domain]),htmlentities($_POST[v_domain]));
+ } else {
+ $_SESSION['ok_msg'] = __('DNS_DOMAIN_CREATED_OK',htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
+ }
unset($v_domain);
}
}
@@ -128,7 +132,11 @@ if (!empty($_POST['ok_rec'])) {
// Flush field values on success
if (empty($_SESSION['error_msg'])) {
- $_SESSION['ok_msg'] = __('DNS_RECORD_CREATED_OK',htmlentities($_POST[v_rec]),htmlentities($_POST[v_domain]));
+ if (PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50700) {
+ $_SESSION['ok_msg'] = __('DNS_RECORD_CREATED_OK',htmlentities($_POST[v_rec]),htmlentities($_POST[v_domain]));
+ } else {
+ $_SESSION['ok_msg'] = __('DNS_RECORD_CREATED_OK',htmlentities($_POST['v_rec']),htmlentities($_POST['v_domain']));
+ }
unset($v_domain);
unset($v_rec);
unset($v_val);
diff --git a/web/add/mail/index.php b/web/add/mail/index.php
index c761139c..5fe9b6ff 100644
--- a/web/add/mail/index.php
+++ b/web/add/mail/index.php
@@ -186,8 +186,13 @@ if (!empty($_POST['ok_acc'])) {
// Flush field values on success
if (empty($_SESSION['error_msg'])) {
- $_SESSION['ok_msg'] = __('MAIL_ACCOUNT_CREATED_OK',htmlentities(strtolower($_POST['v_account'])),htmlentities($_POST[v_domain]),htmlentities(strtolower($_POST['v_account'])),htmlentities($_POST[v_domain]));
- $_SESSION['ok_msg'] .= " / " . __('open webmail') . "";
+ if (PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50700) {
+ $_SESSION['ok_msg'] = __('MAIL_ACCOUNT_CREATED_OK',htmlentities(strtolower($_POST['v_account'])),htmlentities($_POST[v_domain]),htmlentities(strtolower($_POST['v_account'])),htmlentities($_POST[v_domain]));
+ $_SESSION['ok_msg'] .= " / " . __('open webmail') . "";
+ } else {
+ $_SESSION['ok_msg'] = __('MAIL_ACCOUNT_CREATED_OK',htmlentities(strtolower($_POST['v_account'])),htmlentities($_POST['v_domain']),htmlentities(strtolower($_POST['v_account'])),htmlentities($_POST['v_domain']));
+ $_SESSION['ok_msg'] .= " / " . __('open webmail') . "";
+ }
unset($v_account);
unset($v_password);
unset($v_password);
diff --git a/web/add/web/index.php b/web/add/web/index.php
index d77b8f40..f8953f19 100644
--- a/web/add/web/index.php
+++ b/web/add/web/index.php
@@ -323,7 +323,11 @@ if (!empty($_POST['ok'])) {
}
if (!empty($_SESSION['error_msg']) && $domain_added) {
- $_SESSION['ok_msg'] = __('WEB_DOMAIN_CREATED_OK',htmlentities($_POST[v_domain]),htmlentities($_POST[v_domain]));
+ if (PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50700) {
+ $_SESSION['ok_msg'] = __('WEB_DOMAIN_CREATED_OK',htmlentities($_POST[v_domain]),htmlentities($_POST[v_domain]));
+ } else {
+ $_SESSION['ok_msg'] = __('WEB_DOMAIN_CREATED_OK',htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
+ }
$_SESSION['flash_error_msg'] = $_SESSION['error_msg'];
$url = '/edit/web/?domain='.strtolower(preg_replace("/^www\./i", "", $_POST['v_domain']));
header('Location: ' . $url);
diff --git a/web/upload/UploadHandler.php b/web/upload/UploadHandler.php
index 48f40b23..581f9741 100755
--- a/web/upload/UploadHandler.php
+++ b/web/upload/UploadHandler.php
@@ -1095,8 +1095,13 @@ class UploadHandler
}
}
if (count($failed_versions)) {
- $file->error = $this->get_error_message('image_resize')
- .' ('.implode($failed_versions,', ').')';
+ if (PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50700) {
+ $file->error = $this->get_error_message('image_resize')
+ .' ('.implode($failed_versions,', ').')';
+ } else {
+ $file->error = $this->get_error_message('image_resize')
+ .' ('.implode(', ', $failed_versions).')';
+ }
}
// Free memory:
$this->destroy_image_object($file_path);
From be756306b084aa808dcd4328303a316f0a4a3a10 Mon Sep 17 00:00:00 2001
From: Cursor Agent
Date: Sun, 10 Aug 2025 12:13:20 +0000
Subject: [PATCH 303/304] Remove PHP version-specific code for array access and
string formatting
Co-authored-by: peca
---
web/add/dns/index.php | 12 ++----------
web/add/mail/index.php | 9 ++-------
web/add/web/index.php | 6 +-----
web/upload/UploadHandler.php | 9 ++-------
4 files changed, 7 insertions(+), 29 deletions(-)
diff --git a/web/add/dns/index.php b/web/add/dns/index.php
index 06ca9547..b9e47abe 100644
--- a/web/add/dns/index.php
+++ b/web/add/dns/index.php
@@ -80,11 +80,7 @@ if (!empty($_POST['ok'])) {
// Flush field values on success
if (empty($_SESSION['error_msg'])) {
- if (PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50700) {
- $_SESSION['ok_msg'] = __('DNS_DOMAIN_CREATED_OK',htmlentities($_POST[v_domain]),htmlentities($_POST[v_domain]));
- } else {
- $_SESSION['ok_msg'] = __('DNS_DOMAIN_CREATED_OK',htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
- }
+ $_SESSION['ok_msg'] = __('DNS_DOMAIN_CREATED_OK',htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
unset($v_domain);
}
}
@@ -132,11 +128,7 @@ if (!empty($_POST['ok_rec'])) {
// Flush field values on success
if (empty($_SESSION['error_msg'])) {
- if (PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50700) {
- $_SESSION['ok_msg'] = __('DNS_RECORD_CREATED_OK',htmlentities($_POST[v_rec]),htmlentities($_POST[v_domain]));
- } else {
- $_SESSION['ok_msg'] = __('DNS_RECORD_CREATED_OK',htmlentities($_POST['v_rec']),htmlentities($_POST['v_domain']));
- }
+ $_SESSION['ok_msg'] = __('DNS_RECORD_CREATED_OK',htmlentities($_POST['v_rec']),htmlentities($_POST['v_domain']));
unset($v_domain);
unset($v_rec);
unset($v_val);
diff --git a/web/add/mail/index.php b/web/add/mail/index.php
index 5fe9b6ff..6a8b6e9f 100644
--- a/web/add/mail/index.php
+++ b/web/add/mail/index.php
@@ -186,13 +186,8 @@ if (!empty($_POST['ok_acc'])) {
// Flush field values on success
if (empty($_SESSION['error_msg'])) {
- if (PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50700) {
- $_SESSION['ok_msg'] = __('MAIL_ACCOUNT_CREATED_OK',htmlentities(strtolower($_POST['v_account'])),htmlentities($_POST[v_domain]),htmlentities(strtolower($_POST['v_account'])),htmlentities($_POST[v_domain]));
- $_SESSION['ok_msg'] .= " / " . __('open webmail') . "";
- } else {
- $_SESSION['ok_msg'] = __('MAIL_ACCOUNT_CREATED_OK',htmlentities(strtolower($_POST['v_account'])),htmlentities($_POST['v_domain']),htmlentities(strtolower($_POST['v_account'])),htmlentities($_POST['v_domain']));
- $_SESSION['ok_msg'] .= " / " . __('open webmail') . "";
- }
+ $_SESSION['ok_msg'] = __('MAIL_ACCOUNT_CREATED_OK',htmlentities(strtolower($_POST['v_account'])),htmlentities($_POST['v_domain']),htmlentities(strtolower($_POST['v_account'])),htmlentities($_POST['v_domain']));
+ $_SESSION['ok_msg'] .= " / " . __('open webmail') . "";
unset($v_account);
unset($v_password);
unset($v_password);
diff --git a/web/add/web/index.php b/web/add/web/index.php
index f8953f19..e11cff23 100644
--- a/web/add/web/index.php
+++ b/web/add/web/index.php
@@ -323,11 +323,7 @@ if (!empty($_POST['ok'])) {
}
if (!empty($_SESSION['error_msg']) && $domain_added) {
- if (PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50700) {
- $_SESSION['ok_msg'] = __('WEB_DOMAIN_CREATED_OK',htmlentities($_POST[v_domain]),htmlentities($_POST[v_domain]));
- } else {
- $_SESSION['ok_msg'] = __('WEB_DOMAIN_CREATED_OK',htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
- }
+ $_SESSION['ok_msg'] = __('WEB_DOMAIN_CREATED_OK',htmlentities($_POST['v_domain']),htmlentities($_POST['v_domain']));
$_SESSION['flash_error_msg'] = $_SESSION['error_msg'];
$url = '/edit/web/?domain='.strtolower(preg_replace("/^www\./i", "", $_POST['v_domain']));
header('Location: ' . $url);
diff --git a/web/upload/UploadHandler.php b/web/upload/UploadHandler.php
index 581f9741..ce8863bb 100755
--- a/web/upload/UploadHandler.php
+++ b/web/upload/UploadHandler.php
@@ -1095,13 +1095,8 @@ class UploadHandler
}
}
if (count($failed_versions)) {
- if (PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50700) {
- $file->error = $this->get_error_message('image_resize')
- .' ('.implode($failed_versions,', ').')';
- } else {
- $file->error = $this->get_error_message('image_resize')
- .' ('.implode(', ', $failed_versions).')';
- }
+ $file->error = $this->get_error_message('image_resize')
+ .' ('.implode(', ', $failed_versions).')';
}
// Free memory:
$this->destroy_image_object($file_path);
From 457e5c862ee820cf03558f6ea6b34290d16ca9ac Mon Sep 17 00:00:00 2001
From: Peca
Date: Tue, 12 Aug 2025 13:58:17 +0200
Subject: [PATCH 304/304] Add cron job for disk usage snapshot
---
bin/v-df-snapshot-diff | 102 +++++++++++++++++++++++++++++++++
bin/v-df-snapshot-logs-cleaner | 11 ++++
bin/v-df-snapshot-make | 20 +++++++
install/vst-install-debian.sh | 4 ++
src/deb/vesta/postinst | 14 +++++
5 files changed, 151 insertions(+)
create mode 100644 bin/v-df-snapshot-diff
create mode 100644 bin/v-df-snapshot-logs-cleaner
create mode 100644 bin/v-df-snapshot-make
diff --git a/bin/v-df-snapshot-diff b/bin/v-df-snapshot-diff
new file mode 100644
index 00000000..ee427bd2
--- /dev/null
+++ b/bin/v-df-snapshot-diff
@@ -0,0 +1,102 @@
+#!/bin/bash
+# info: Make a diff between two snapshots of the disk usage
+# options: FILE1 FILE2
+
+whoami=$(whoami)
+if [ "$whoami" != "root" ]; then
+ echo "You must be root to execute this script"
+ exit 1
+fi
+
+# Let's declare three associative arrays
+declare -A FILE1
+declare -A FILE2
+declare -A FILED
+
+file1=$1
+file2=$2
+
+if [[ ! "$file1" =~ ^/usr/local/vesta/data/df/snapshot-.*\.txt$ ]]; then
+ file1="/usr/local/vesta/data/df/$file1"
+fi
+
+if [[ ! "$file2" =~ ^/usr/local/vesta/data/df/snapshot-.*\.txt$ ]]; then
+ file2="/usr/local/vesta/data/df/$file2"
+fi
+
+if [ ! -f "$file1" ]; then
+ echo "File $file1 not found"
+ exit 1
+fi
+
+if [ ! -f "$file2" ]; then
+ echo "File $file2 not found"
+ exit 1
+fi
+
+timestamp=$(date +%Y-%m-%d-%H-%M-%S)
+mkdir -p /usr/local/vesta/data/df-diff
+file0="/usr/local/vesta/data/df-diff/diff-$timestamp.txt"
+file0s="/usr/local/vesta/data/df-diff/diff-size-sorted-$timestamp.txt"
+file0f="/usr/local/vesta/data/df-diff/diff-folder-sorted-$timestamp.txt"
+touch $file0
+
+# Let's load the first file and fill the array FILE1
+while IFS=$'\t' read SIZE DIRECTORY; do
+ # Skip blank lines or lines that are not in the correct format
+ [[ -z "$DIRECTORY" ]] && continue
+ [[ "$DIRECTORY" = "total" ]] && continue
+ # Insert values into the array
+ FILE1["$DIRECTORY"]="$SIZE"
+done < "$file1"
+
+# Let's load the second file and fill the array FILE2
+while IFS=$'\t' read SIZE DIRECTORY; do
+ # Skip blank lines or lines that are not in the correct format
+ [[ -z "$DIRECTORY" ]] && continue
+ [[ "$DIRECTORY" = "total" ]] && continue
+ # Insert values into the array
+ FILE2["$DIRECTORY"]="$SIZE"
+done < "$file2"
+
+# We iterate through FILE1 and look for the matching key in FILE2
+for k in "${!FILE1[@]}"; do
+ if [[ -v FILE2["$k"] ]]; then
+ # If there is the same folder (KEY) in FILE2
+ DIFF=$(( ${FILE2[$k]} - ${FILE1[$k]} ))
+ FILED["$k"]=$DIFF
+ echo -e "${DIFF}\t${k}" >> $file0
+ else
+ # If the folder (KEY) is not found in FILE2
+ FILED["$k"]=${FILE1["$k"]}
+ echo -e "${FILE1["$k"]}\t${k}" >> $file0
+ fi
+done
+
+# sorted by size
+sort -nr -k1,1 $file0 > $file0s
+
+# sorted by folders
+while IFS=$'\t' read SIZE DIRECTORY; do
+ [[ -z "$DIRECTORY" ]] && continue
+ [[ "$DIRECTORY" = "total" ]] && continue
+ echo -e "$DIRECTORY\t${FILED["$DIRECTORY"]}" >> $file0f
+done < "$file2"
+
+chmod 600 $file0 $file0s $file0f
+chown root:root $file0 $file0s $file0f
+
+echo "Done."
+echo "You can do:"
+echo "mcview $file0"
+echo "mcview $file0s"
+echo "mcview $file0f"
+echo "--------------------------------"
+echo "Here is the first 30 lines of the diff, sorted by size (descending, in MB):"
+head -n 30 $file0s
+echo "--------------------------------"
+echo "Here is the first 30 lines of the diff, sorted by folders (in MB):"
+head -n 30 $file0f
+echo "--------------------------------"
+
+exit 0
diff --git a/bin/v-df-snapshot-logs-cleaner b/bin/v-df-snapshot-logs-cleaner
new file mode 100644
index 00000000..63275034
--- /dev/null
+++ b/bin/v-df-snapshot-logs-cleaner
@@ -0,0 +1,11 @@
+#!/bin/bash
+# info: Clean up old snapshots of the disk usage
+# options: NONE
+
+folder="/usr/local/vesta/data/df"
+mkdir -p $folder
+find $folder -type f -mtime +30 -delete
+
+folder="/usr/local/vesta/data/df-diff"
+mkdir -p $folder
+find $folder -type f -mtime +30 -delete
diff --git a/bin/v-df-snapshot-make b/bin/v-df-snapshot-make
new file mode 100644
index 00000000..51c41e9d
--- /dev/null
+++ b/bin/v-df-snapshot-make
@@ -0,0 +1,20 @@
+#!/bin/bash
+# info: Make a snapshot of the disk usage
+# options: NONE
+
+folder="/usr/local/vesta/data/df"
+
+mkdir -p $folder
+timestamp=$(date +%Y-%m-%d-%H-%M-%S)
+du --max-depth=1 -c -m -x / > $folder/snapshot-$timestamp.txt
+du --max-depth=1 -c -m -x /home >> $folder/snapshot-$timestamp.txt
+du --max-depth=2 -c -m -x /home >> $folder/snapshot-$timestamp.txt
+du --max-depth=3 -c -m -x /home >> $folder/snapshot-$timestamp.txt
+du --max-depth=6 -c -m -x /home >> $folder/snapshot-$timestamp.txt
+du --max-depth=1 -c -m -x /var/lib/mysql >> $folder/snapshot-$timestamp.txt
+du --max-depth=1 -c -m -x /var/log >> $folder/snapshot-$timestamp.txt
+
+chmod 600 $folder/snapshot-$timestamp.txt
+chown root:root $folder/snapshot-$timestamp.txt
+
+exit 0
diff --git a/install/vst-install-debian.sh b/install/vst-install-debian.sh
index 1c8f2e1b..e8208113 100755
--- a/install/vst-install-debian.sh
+++ b/install/vst-install-debian.sh
@@ -1896,6 +1896,10 @@ command="sudo $VESTA/bin/v-update-sys-rrd"
$VESTA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command"
command="sudo $VESTA/bin/v-fix-website-permissions-for-all-websites-only-php"
$VESTA/bin/v-add-cron-job 'admin' '05' '03' '*' '*' '*' "$command"
+command="sudo $VESTA/bin/v-df-snapshot-make"
+$VESTA/bin/v-add-cron-job 'admin' '05' '04' '*' '*' '*' "$command"
+command="sudo $VESTA/bin/v-df-snapshot-logs-cleaner"
+$VESTA/bin/v-add-cron-job 'admin' '10' '04' '*' '*' '*' "$command"
systemctl restart cron.service
echo "== Building inititall rrd images"
diff --git a/src/deb/vesta/postinst b/src/deb/vesta/postinst
index f5f79877..ac034e82 100755
--- a/src/deb/vesta/postinst
+++ b/src/deb/vesta/postinst
@@ -38,6 +38,20 @@ if grep -q "fix-website-permissions-for-all-websites" /usr/local/vesta/data/user
fi
fi
+# Adding cron job for disk usage snapshot
+if ! grep -q "v-df-snapshot-make" /usr/local/vesta/data/users/admin/cron.conf; then
+ echo "== Adding cron job for disk usage snapshot"
+ command="sudo $VESTA/bin/v-df-snapshot-make"
+ $VESTA/bin/v-add-cron-job 'admin' '05' '04' '*' '*' '*' "$command"
+ systemctl restart cron.service
+fi
+if ! grep -q "v-df-snapshot-logs-cleaner" /usr/local/vesta/data/users/admin/cron.conf; then
+ echo "== Adding cron job for disk usage snapshot logs cleaner"
+ command="sudo $VESTA/bin/v-df-snapshot-logs-cleaner"
+ $VESTA/bin/v-add-cron-job 'admin' '10' '04' '*' '*' '*' "$command"
+ systemctl restart cron.service
+fi
+
# Fixing PHP and .env permissions and ownership for all websites
if ! grep -q "fix-website-permissions-for-all-websites-only-php" /usr/local/vesta/data/users/admin/cron.conf; then
echo "== Fixing PHP and .env permissions and ownership for all websites"