Fix switching versions in Linux

This commit is contained in:
Shivam Mathur 2022-03-07 08:22:08 +05:30
parent 62bd8f3ca4
commit a826799c7c
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -116,8 +116,14 @@ add_pecl() {
# Function to switch versions of PHP binaries. # Function to switch versions of PHP binaries.
switch_version() { switch_version() {
tools=("$@") && ! (( ${#tools[@]} )) && tools+=(pear pecl php phar phar.phar php-cgi php-config phpize phpdbg) tools=("$@")
to_wait=() to_wait=()
if ! (( ${#tools[@]} )); then
tools+=(pear pecl php phar phar.phar php-cgi php-config phpize phpdbg)
[ -e /usr/lib/cgi-bin/php"$version" ] && sudo update-alternatives --set php-cgi-bin /usr/lib/cgi-bin/php"$version" & to_wait+=($!)
[ -e /usr/sbin/php-fpm"$version" ] && sudo update-alternatives --set php-fpm /usr/sbin/php-fpm"$version" & to_wait+=($!)
[ -e /run/php/php"$version"-fpm.sock ] && sudo update-alternatives --set php-fpm.sock /run/php/php"$version"-fpm.sock & to_wait+=($!)
fi
for tool in "${tools[@]}"; do for tool in "${tools[@]}"; do
if [ -e "/usr/bin/$tool$version" ]; then if [ -e "/usr/bin/$tool$version" ]; then
sudo update-alternatives --set "$tool" /usr/bin/"$tool$version" & sudo update-alternatives --set "$tool" /usr/bin/"$tool$version" &
@ -159,7 +165,6 @@ add_php() {
setup_old_versions setup_old_versions
else else
add_packaged_php add_packaged_php
switch_version >/dev/null 2>&1
fi fi
status="Installed" status="Installed"
} }