Enhance v-run-wp-cli and v-run-wp-cli-myvesta to check for file age and update if older than 30 days

This commit is contained in:
Peca 2025-07-30 16:18:20 +02:00
commit ef8d033b60
2 changed files with 29 additions and 2 deletions

View file

@ -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 /usr/local/vesta/bin/v-install-wp-cli
fi 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 if [ -t 1 ]; then
output='terminal' output='terminal'
else else

View file

@ -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 /usr/local/vesta/bin/v-install-wp-cli-myvesta
fi 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 "$@" USE_WP_CLI_MYVESTA=1 /usr/local/vesta/bin/v-run-wp-cli "$@"