Added alternative php. Part 8

This commit is contained in:
Alexey Berezhok
2025-01-22 23:10:51 +03:00
parent b29a369515
commit c25c8d8f64
17 changed files with 181 additions and 67 deletions

View File

@@ -22,11 +22,11 @@ source $HESTIA/func/main.sh
source_conf "$HESTIA/conf/hestia.conf"
source_conf "$HESTIA/install/upgrade/upgrade.conf"
if [ -f /etc/redhat-release ]; then
for elem in "${!multiphp_v[@]}"; do
multiphp_v[$elem]=$(convert_dot_version_to_non_dot "${multiphp_v[$elem]}")
done
fi
for elem in "${!multiphp_v[@]}"; do
multiphp_v[$elem]=$(convert_dot_version_to_non_dot "${multiphp_v[$elem]}")
done
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#

View File

@@ -50,7 +50,7 @@ else
fi
if [ "$LOCAL_PHP" == "yes" ]; then
rm -f /opt/brepo/php*/etc/php-fpm.d/
rm -f /opt/brepo/php*/etc/php-fpm.d/www.conf
cp -f $HESTIA/install/rpm/php-fpm/www.conf /opt/brepo/php${version}/etc/php-fpm.d/www.conf
else
rm -f /etc/opt/remi/php*/php-fpm.d/www.conf

View File

@@ -40,6 +40,28 @@ check_hestia_demo_mode
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
php_v="82"
if [[ "$service" =~ ^php ]];then
ver_php=$(echo "$service" | grep -Po "\d+")
if [ -z "$ver_php" ]; then
php_v=$(get_system_default_php)
else
if [ "$LOCAL_PHP" == "yes" ]; then
if [ -e "/opt/brepo/php${ver_php}" ]; then
php_v="$ver_php"
else
php_v=$(get_system_default_php)
fi
else
if [ -e "/etc/opt/remi/php${ver_php}" ]; then
php_v="$ver_php"
else
php_v=$(get_system_default_php)
fi
fi
fi
service="php"
fi
# Defining dst config path
case $service in
@@ -50,7 +72,13 @@ case $service in
exim4) dst='/etc/exim4/exim4.conf.template' ;;
vsftpd) dst=$(find /etc/vsftpd* -name 'vsftpd.conf') ;;
proftpd) dst=$(find /etc/proftpd* -name 'proftpd.conf') ;;
php) dst=$(find /etc/php* -name php.ini) ;;
php)
if [ "$LOCAL_PHP" == "yes" ]; then
dst=$(find /opt/brepo/php${php_v} -name php.ini)
else
dst=$(find /etc/opt/remi/php${php_v} -name php.ini)
fi
;;
mysql) dst=$(find /etc/my* -name my.cnf) ;;
mysqld) dst=$(find /etc/my* -name my.cnf) ;;
mariadb) dst=$(find /etc/my* -name my.cnf) ;;
@@ -103,7 +131,7 @@ if [ "$update" = 'yes' ] && [ "$restart" != 'no' ]; then
if [ "$service" = 'php' ]; then
if [ "$(multiphp_count)" -gt 0 ]; then
service="php-fpm"
elif [ "$WEB_SYSTEM" = 'apache2' ]; then
elif [ "$WEB_SYSTEM" = 'httpd' ]; then
service="$WEB_SYSTEM"
fi
fi

View File

@@ -1,6 +1,6 @@
#!/bin/bash
# info: list php config parameters
# options: [FORMAT]
# options: [VERSION] [FORMAT]
#
# example: v-list-sys-php-config
#
@@ -11,7 +11,8 @@
#----------------------------------------------------------#
# Argument definition
format=${1-shell}
php_ver=${1-default}
format=${2-shell}
# Includes
# shellcheck source=/etc/hestiacp/hestia.conf
@@ -61,12 +62,40 @@ csv_list() {
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
declare -a versions
if [ "$php_ver" == "default" ]; then
# List through /etc/php
if [ "$LOCAL_PHP" == "yes" ]; then
for version in /opt/brepo/php*/etc/php-fpm.d/www.conf; do
ver=$(echo "$version" | awk -F"/" '{ print $4 }' | sed "s/php\([[:digit:]]\+\)/\1/g")
if [ "$ver" != "php*" ]; then
versions+=("$ver")
fi
done
else
for version in /etc/opt/remi/php*/php-fpm.d/www.conf; do
ver=$(echo "$version" | awk -F"/" '{ print $5 }' | sed "s/php\([[:digit:]]\+\)/\1/g")
if [ "$ver" != "php*" ]; then
versions+=("$ver")
fi
done
fi
else
ver=$(echo "$php_ver" | sed "s/php\([[:digit:]]\+\)/\1/g")
versions+=("$ver")
fi
if [ ${#versions[@]} -eq 0 ]; then
php_ver="82"
else
php_ver="${versions[0]}"
fi
# Defining config path
if [ "$LOCAL_PHP" == "yes" ]; then
config_path=$(find /opt/brepo/php* -name php.ini)
config_path=$(find /opt/brepo/php${php_ver}/* -name php.ini)
else
config_path=$(find /etc/opt/remi/php* -name php.ini)
config_path=$(find /etc/opt/remi/php${php_ver}/* -name php.ini)
fi
config_count=$(echo "$config_path" | wc -l)
@@ -77,7 +106,7 @@ if [ "$config_count" -gt 1 ]; then
multiphp_versions=$(ls -d /etc/opt/remi/php*/php-fpm.d 2> /dev/null | wc -l)
fi
if [ "$WEB_BACKEND" = 'php-fpm' ] || [ "$multiphp_versions" -gt 0 ]; then
config_path=$(echo "$config_path" | grep fpm)
config_path=$(echo "$config_path" | grep "php")
else
config_path=$(echo "$config_path" | grep httpd)
fi
@@ -89,7 +118,7 @@ keys="$keys |upload_max_filesize |post_max_size"
keys="$keys |display_errors |error_reporting "
# Reading config
config=$(cat $config_path | grep -v "^;")
config=$(cat "$config_path" | grep -v "^;")
# Listing data
case $format in

View File

@@ -175,12 +175,12 @@ fi
# Checking PHP intepreter
if [ -n "$WEB_BACKEND" ] && [ "$WEB_BACKEND" != 'remote' ]; then
if [ "$LOCAL_PHP" == "yes" ]; then
php_versions=$(/opt/brepo/php*/sbin/php-fpm | cut -d'/' -f4 | sed 's|php||')
php_versions=$(ls /opt/brepo/php*/sbin/php-fpm | cut -d'/' -f4 | sed 's|php||')
for version in $php_versions; do
proc_name="php-fpm"
service_name="php${version}"
service_name="fpm${version}"
get_srv_state "$proc_name"
data="$data\nNAME='$service_name-php-fpm' SYSTEM='php interpreter' STATE='$state'"
data="$data\nNAME='brepo-php-$service_name' SYSTEM='php interpreter' STATE='$state'"
data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'"
done
else

View File

@@ -32,6 +32,10 @@ is_format_valid 'service' 'restart'
# Action #
#----------------------------------------------------------#
if [ "$service" == "apache2" ]; then
service="httpd"
fi
log="/dev/null"
if [ "$DEBUG_MODE" = "true" ]; then
@@ -49,13 +53,21 @@ if [ "$service" = "php-fpm" ]; then
php_versions=$($BIN/v-list-sys-php plain)
# Substitute php-fpm service name formats
for version in $php_versions; do
service_list="${service_list} php${version}-fpm"
if [ "$LOCAL_PHP" == "yes" ]; then
service_list="${service_list} brepo-php-fpm${version}"
else
service_list="${service_list} php${version}-php-fpm"
fi
done
else
service_list="$service"
fi
for service in $service_list; do
is_fpm="no"
if [[ "$service" =~ ^php[0-9.]+-php-fpm ]] || [[ "$service" =~ brepo-php-fpm[0-9.]+ ]]; then
is_fpm="yes"
fi
if [ "$service" = "iptables" ]; then
# Run the restart rules for iptables firewall
$BIN/v-stop-firewall
@@ -64,21 +76,13 @@ for service in $service_list; do
service $service upgrade >> $log 2>&1
elif [ -z "$restart" -o "$restart" = "no" ] && [ \
"$service" = "nginx" -o \
"$service" = "apache2" -o \
"$service" = "httpd" -o \
"$service" = "exim4" -o \
"$service" = "dovecot" -o \
"$service" = "bind9" -o \
"$service" = "named" -o \
"$service" = "vsftpd" -o \
"$service" = "php5.6-fpm" -o \
"$service" = "php7.0-fpm" -o \
"$service" = "php7.1-fpm" -o \
"$service" = "php7.2-fpm" -o \
"$service" = "php7.3-fpm" -o \
"$service" = "php7.4-fpm" -o \
"$service" = "php8.0-fpm" -o \
"$service" = "php8.1-fpm" -o \
"$service" = "php8.2-fpm" -o \
"$is_fpm" = "yes" -o \
"$service" = "proftpd" -o \
"$service" = "ssh" -o \
"$service" = "fail2ban" ]; then