From a826799c7c8ad2e9a9b4c9af5c53d8e6ff6d885d Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 7 Mar 2022 08:22:08 +0530 Subject: [PATCH] Fix switching versions in Linux --- src/scripts/linux.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index 8e7ade47..7bf7a5c3 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -116,8 +116,14 @@ add_pecl() { # Function to switch versions of PHP binaries. switch_version() { - tools=("$@") && ! (( ${#tools[@]} )) && tools+=(pear pecl php phar phar.phar php-cgi php-config phpize phpdbg) + tools=("$@") 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 if [ -e "/usr/bin/$tool$version" ]; then sudo update-alternatives --set "$tool" /usr/bin/"$tool$version" & @@ -159,7 +165,6 @@ add_php() { setup_old_versions else add_packaged_php - switch_version >/dev/null 2>&1 fi status="Installed" }