mirror of
https://github.com/myvesta/vesta
synced 2025-08-21 05:44:08 -07:00
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
This commit is contained in:
parent
ef8d033b60
commit
48944af182
1 changed files with 21 additions and 0 deletions
|
@ -35,12 +35,33 @@ git clone https://github.com/wp-cli/wp-cli.git
|
||||||
|
|
||||||
chown -R www-data:www-data wp-cli
|
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/
|
cd wp-cli/
|
||||||
sudo -H -u www-data composer install
|
sudo -H -u www-data composer install
|
||||||
|
|
||||||
echo "= Installing search-replace-command package..."
|
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
|
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
|
# Fix terminal columns issue for WP CLI
|
||||||
echo "= Fixing 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'
|
/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'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue