Use local php. Part 3
This commit is contained in:
@@ -101,34 +101,33 @@ is_web_alias_new() {
|
||||
prepare_web_backend() {
|
||||
# Accept first function argument as backend template otherwise fallback to $template global variable
|
||||
local backend_template=${1:-$template}
|
||||
|
||||
if [ -f "/etc/redhat-release" ]; then
|
||||
pool=$(find -L /etc/opt/remi/php80/ -name "$domain.conf" -exec dirname {} \; 2>/dev/null)
|
||||
php_type=$(cat "$HESTIA/conf/hestia.conf" | grep "LOCAL_PHP" | grep "yes")
|
||||
|
||||
if [ -n "$php_type" ]; then
|
||||
pool=$(find -L /opt/brepo/ -name "$domain.conf" -exec dirname {} \; 2>/dev/null)
|
||||
else
|
||||
pool=$(find -L /etc/php/ -name "$domain.conf" -exec dirname {} \;)
|
||||
pool=$(find -L /etc/opt/remi/php80/ -name "$domain.conf" -exec dirname {} \; 2>/dev/null)
|
||||
fi
|
||||
# Check if multiple-PHP installed
|
||||
if [ -f "/etc/redhat-release" ]; then
|
||||
regex="^.*PHP-([0-9])([0-9])$"
|
||||
else
|
||||
regex="^.*PHP-([0-9])\_([0-9])$"
|
||||
fi
|
||||
regex="^.*PHP-([0-9])([0-9])$"
|
||||
|
||||
if [[ $backend_template =~ $regex ]]; then
|
||||
if [ -f "/etc/redhat-release" ]; then
|
||||
if [ -n "$php_type" ]; then
|
||||
backend_version="${BASH_REMATCH[1]}${BASH_REMATCH[2]}"
|
||||
pool=$(find -L /opt/brepo/php$backend_version -type d \( -name "pool.d" -o -name "*fpm.d" \))
|
||||
else
|
||||
backend_version="${BASH_REMATCH[1]}${BASH_REMATCH[2]}"
|
||||
pool=$(find -L /etc/opt/remi/php$backend_version -type d \( -name "pool.d" -o -name "*fpm.d" \))
|
||||
else
|
||||
backend_version="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
|
||||
pool=$(find -L /etc/php/$backend_version -type d \( -name "pool.d" -o -name "*fpm.d" \))
|
||||
fi
|
||||
else
|
||||
backend_version=$(multiphp_default_version)
|
||||
if [ -z "$pool" ] || [ -z "$BACKEND" ]; then
|
||||
if [ -f "/etc/redhat-release" ]; then
|
||||
if [ -n "$php_type" ]; then
|
||||
m_backend_version="${backend_version//./}"
|
||||
pool=$(find -L /opt/brepo/php$m_backend_version -type d \( -name "pool.d" -o -name "*fpm.d" \))
|
||||
else
|
||||
m_backend_version="${backend_version//./}"
|
||||
pool=$(find -L /etc/opt/remi/php$m_backend_version -type d \( -name "pool.d" -o -name "*fpm.d" \))
|
||||
else
|
||||
pool=$(find -L /etc/php/$backend_version -type d \( -name "pool.d" -o -name "*fpm.d" \))
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -151,11 +150,12 @@ prepare_web_backend() {
|
||||
|
||||
# Delete web backend
|
||||
delete_web_backend() {
|
||||
if [ -f "/etc/redhat-release" ]; then
|
||||
find -L /etc/opt/remi/ -name "$backend_type.conf" -exec rm -f {} \;
|
||||
else
|
||||
find -L /etc/php/ -type f -name "$backend_type.conf" -exec rm -f {} \;
|
||||
fi
|
||||
php_type=$(cat "$HESTIA/conf/hestia.conf" | grep "LOCAL_PHP" | grep "yes")
|
||||
if [ -n "$php_type" ]; then
|
||||
find -L /opt/brepo/php* -name "$backend_type.conf" -exec rm -f {} \;
|
||||
else
|
||||
find -L /etc/opt/remi/ -name "$backend_type.conf" -exec rm -f {} \;
|
||||
fi
|
||||
}
|
||||
|
||||
# Prepare web aliases
|
||||
|
||||
21
func/main.sh
21
func/main.sh
@@ -1561,9 +1561,16 @@ multiphp_count() {
|
||||
multiphp_versions() {
|
||||
local -a php_versions_list
|
||||
local php_ver
|
||||
local php_type_internal=$(cat "$HESTIA/conf/hestia.conf" | grep "LOCAL_PHP" | grep "yes")
|
||||
local pool_internal=""
|
||||
if [ "$(multiphp_count)" -gt 0 ]; then
|
||||
for php_ver in $($BIN/v-list-sys-php plain); do
|
||||
[ ! -d "/etc/php/$php_ver/fpm/pool.d/" ] && continue
|
||||
if [ -n "$php_type_internal" ]; then
|
||||
pool_internal="/opt/brepo/php$php_ver/etc/php-fpm.d"
|
||||
else
|
||||
pool_internal="/etc/opt/remi/php$php_ver/php-fpm.d"
|
||||
fi
|
||||
[ ! -d "$pool_internal" ] && continue
|
||||
php_versions_list+=($php_ver)
|
||||
done
|
||||
echo "${php_versions_list[@]}"
|
||||
@@ -1572,11 +1579,19 @@ multiphp_versions() {
|
||||
|
||||
multiphp_default_version() {
|
||||
# Get system wide default php version (set by update-alternatives)
|
||||
local sys_phpversion=$(php -r "echo substr(phpversion(),0,3);")
|
||||
local sys_phpversion_l=$(php -r "echo substr(phpversion(),0,3);")
|
||||
local sys_phpversion="${sys_phpversion_l//./}"
|
||||
local php_type_internal=$(cat "$HESTIA/conf/hestia.conf" | grep "LOCAL_PHP" | grep "yes")
|
||||
local pool_internal=""
|
||||
if [ -n "$php_type_internal" ]; then
|
||||
pool_internal="/opt/brepo/php$sys_phpversion/etc/php-fpm.d"
|
||||
else
|
||||
pool_internal="/etc/opt/remi/php$sys_phpversion/php-fpm.d"
|
||||
fi
|
||||
|
||||
# Check if the system php also has php-fpm enabled, otherwise return
|
||||
# the most recent php version which does have it installed.
|
||||
if [ ! -d "/etc/php/$sys_phpversion/fpm/pool.d/" ]; then
|
||||
if [ ! -d "$pool_internal" ]; then
|
||||
local all_versions="$(multiphp_versions)"
|
||||
if [ -n "$all_versions" ]; then
|
||||
sys_phpversion="${all_versions##*\ }"
|
||||
|
||||
Reference in New Issue
Block a user