mirror of
https://github.com/myvesta/vesta
synced 2025-08-20 21:34:12 -07:00
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:
parent
95ed753b0b
commit
ef8d033b60
2 changed files with 29 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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 "$@"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue