Added new comman for disable selector
This commit is contained in:
63
installer.sh
63
installer.sh
@@ -1,5 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function restore_system() {
|
||||
current_php=$(readlink -f /usr/bin/php)
|
||||
if [ "$current_php" == "/usr/bin/hestiacp-php-selector" ]; then
|
||||
if [ -e /etc/hestia_php_selector/system/php.path ]; then
|
||||
php_sys=$(cat /etc/hestia_php_selector/system/php.path)
|
||||
if [ -n "$php_sys" ]; then
|
||||
update-alternatives --display php | grep "/usr/bin/php82"
|
||||
if [ $? -eq 0 ]; then
|
||||
update-alternatives --set php "$php_sys"
|
||||
else
|
||||
php_ver=$(echo "$php_sys" | grep -o -P "php\d+.?\d+")
|
||||
is_sim_php=$(update-alternatives --display php | tail -n +3 | grep -Po "^(.+?)(?= -)" | grep "$php_ver" | head -n1)
|
||||
fst_php=$(update-alternatives --display php | tail -n +3 | grep -Po "^(.+?)(?= -)" | head -n1)
|
||||
if [ -n "$is_sim_php" ]; then
|
||||
update-alternatives --set php "$is_sim_php"
|
||||
else
|
||||
if [ -n "$fst_php" ]; then
|
||||
update-alternatives --set php "$fst_php"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
uid=$(id -u)
|
||||
if [ "$uid" != "0" ]; then
|
||||
echo "Command must be executed as privileged user"
|
||||
@@ -15,43 +41,24 @@ install)
|
||||
if [ ! -e /etc/hestia_php_selector/system/php.path ]; then
|
||||
mkdir -p /etc/hestia_php_selector/system/
|
||||
current_path_to_php=$(readlink -f /usr/bin/php)
|
||||
echo "$current_path_to_php" > /etc/hestia_php_selector/system/php.path
|
||||
echo "$current_path_to_php" >/etc/hestia_php_selector/system/php.path
|
||||
chmod 644 /etc/hestia_php_selector/system/php.path
|
||||
fi
|
||||
/usr/bin/hestiacp-php-admin add
|
||||
fi
|
||||
;;
|
||||
;;
|
||||
delete)
|
||||
current_php=$(readlink -f /usr/bin/php)
|
||||
if [ "$current_php" == "/usr/bin/hestiacp-php-selector" ]; then
|
||||
if [ -e /etc/hestia_php_selector/system/php.path ]; then
|
||||
php_sys=$(cat /etc/hestia_php_selector/system/php.path)
|
||||
if [ -n "$php_sys" ]; then
|
||||
update-alternatives --display php | grep "/usr/bin/php82"
|
||||
if [ $? -eq 0 ]; then
|
||||
update-alternatives --set php "$php_sys"
|
||||
else
|
||||
php_ver=$(echo "$php_sys" | grep -o -P "php\d+.?\d+")
|
||||
is_sim_php=`update-alternatives --display php | tail -n +3 | grep -Po "^(.+?)(?= -)" | grep "$php_ver" | head -n1`
|
||||
fst_php=`update-alternatives --display php | tail -n +3 | grep -Po "^(.+?)(?= -)" | head -n1`
|
||||
if [ -n "$is_sim_php" ]; then
|
||||
update-alternatives --set php "$is_sim_php"
|
||||
else
|
||||
if [ -n "$fst_php" ]; then
|
||||
update-alternatives --set php "$fst_php"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
restore_system
|
||||
update-alternatives --display php | grep hestiacp-php-selector
|
||||
if [ $? -eq 0 ]; then
|
||||
update-alternatives --remove php /usr/bin/hestiacp-php-selector
|
||||
fi
|
||||
/usr/bin/hestiacp-php-admin remove-all
|
||||
;;
|
||||
;;
|
||||
off)
|
||||
restore_system
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user