Fixes for php-fpm service

devel
Alexey Berezhok 1 year ago
parent 68774baa01
commit e826a68bd3

@ -21,6 +21,12 @@ source $HESTIA/func/main.sh
# load config file
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
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#

@ -0,0 +1,39 @@
#!/bin/bash
# info: prepare actions befor whole system will start
# options: NONE
#
# example: v-oneshot-service
#
# This function prepares dir structure for such things
# wich deleted on system shoutdown, run as root only
# Includes
# shellcheck source=/etc/hestiacp/hestia.conf
source /etc/hestiacp/hestia.conf
# shellcheck source=/usr/local/hestia/func/main.sh
source $HESTIA/func/main.sh
# load config file
source_conf "$HESTIA/conf/hestia.conf"
# Checking root permissions
if [ "$(id -u)" != '0' ]; then
echo "Error: Script can be run executed only by root"
exit 10
fi
php_DIR="/run/php"
#make php directory in /var/run/directory for php-fpm
if [ -f /etc/redhat-release ]; then
user_apache=$(cat $HESTIA_INSTALL_DIR/php-fpm/multiphp.tpl | grep listen.group | cut -d= -f2 | xargs)
if [ -n "$user_apache" ]; then
if grep "$user_apache" /etc/passwd; then
if grep "$user_apache" /etc/group; then
if [ ! -e "$php_DIR" ]; then
mkdir "$php_DIR"
chmod 755 "$php_DIR"
chown "$user_apache":"$user_apache" "$php_DIR"
fi
fi
fi
fi
fi

@ -9,6 +9,9 @@
restart=$1
# For backward compatibility might change in the feature
version=$2
if [ -f "/etc/redhat-release" ]; then
version="${version//./}"
fi
#----------------------------------------------------------#
# Variables & Functions #
@ -55,10 +58,21 @@ tmpfile=$(mktemp)
if [ -z "$version" ]; then
# Substitute php-fpm service name formats
for version in $($BIN/v-list-sys-php plain); do
v_php="php$version-fpm"
if [ ! -f "/etc/php/${version}/fpm/pool.d/dummy.conf" ]; then
cp -f "$HESTIA_INSTALL_DIR/php-fpm/dummy.conf" "/etc/php/${version}/fpm/pool.d/"
sed -i "s/9999/99${version//./}/g" "/etc/php/${version}/fpm/pool.d/dummy.conf"
if [ -f /etc/redhat-release ]; then
v_php="php$version-php-fpm"
else
v_php="php$version-fpm"
fi
if [ -f /etc/redhat-release ]; then
if [ ! -f "/etc/opt/remi/php${version}/php-fpm.d/dummy.conf" ]; then
cp -f $HESTIA_INSTALL_DIR/php-fpm/dummy.conf /etc/opt/remi/php${version}/php-fpm.d/
sed -i "s/9999/99$v_tpl/g" /etc/opt/remi/php${version}/php-fpm.d/dummy.conf
fi
else
if [ ! -f "/etc/php/${version}/fpm/pool.d/dummy.conf" ]; then
cp -f "$HESTIA_INSTALL_DIR/php-fpm/dummy.conf" "/etc/php/${version}/fpm/pool.d/"
sed -i "s/9999/99${version//./}/g" "/etc/php/${version}/fpm/pool.d/dummy.conf"
fi
fi
$BIN/v-restart-service "$v_php" "$restart"
@ -68,7 +82,11 @@ if [ -z "$version" ]; then
fi
done
else
v_php="php$version-fpm"
if [ -f /etc/redhat-release ]; then
v_php="php$version-php-fpm"
else
v_php="php$version-fpm"
fi
$BIN/v-restart-service "$v_php" "$restart"
if [ $? -ne 0 ]; then
send_email_report

@ -103,7 +103,7 @@ prepare_web_backend() {
local backend_template=${1:-$template}
if [ -f "/etc/redhat-release" ]; then
pool=$(find -L /etc/opt/remi/php80/ -name "$domain.conf" -exec dirname {} \;)
pool=$(find -L /etc/opt/remi/php80/ -name "$domain.conf" -exec dirname {} \; 2>/dev/null)
else
pool=$(find -L /etc/php/ -name "$domain.conf" -exec dirname {} \;)
fi
@ -121,7 +121,8 @@ prepare_web_backend() {
backend_version=$(multiphp_default_version)
if [ -z "$pool" ] || [ -z "$BACKEND" ]; then
if [ -f "/etc/redhat-release" ]; then
pool=$(find -L /etc/opt/remi/php80 -type d \( -name "pool.d" -o -name "*fpm.d" \))
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

@ -14,7 +14,11 @@ BACKUP_DISK_LIMIT=95
BACKUP_LA_LIMIT=$(cat /proc/cpuinfo | grep processor | wc -l)
RRD_STEP=300
BIN=$HESTIA/bin
HESTIA_INSTALL_DIR="$HESTIA/install/deb"
if [ -f /etc/redhat-release ]; then
HESTIA_INSTALL_DIR="$HESTIA/install/rpm"
else
HESTIA_INSTALL_DIR="$HESTIA/install/deb"
fi
HESTIA_COMMON_DIR="$HESTIA/install/common"
HESTIA_BACKUP="/root/hst_backups/$(date +%d%m%Y%H%M)"
HESTIA_PHP="$HESTIA/php/bin/php"
@ -1712,3 +1716,9 @@ search_command_arg_position() {
echo "$position"
}
# Convert version X.X to XX
convert_dot_version_to_non_dot() {
version="$1"
echo "${version//./}"
}

@ -1897,6 +1897,14 @@ if [ "$apache" = 'yes' ] && [ "$nginx" = 'yes' ]; then
systemctl restart httpd
fi
#install oneshot service for hestia
echo "[ * ] Configuring One Shot Service..."
$HESTIA/bin/v-oneshot-service
if [ ! -e /etc/systemd/system/hestiacp-prepare.service ]; then
cp -f $HESTIA_INSTALL_DIR/oneshot/hestiacp-prepare.service /etc/systemd/system/
systemctl enable hestiacp-prepare.service --now
fi
# Adding default domain
$HESTIA/bin/v-add-web-domain admin $servername $ip
check_result $? "can't create $servername domain"

@ -0,0 +1,11 @@
[Unit]
Description=Prepare some actions on system boot for HestiaCP rpm
Before=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/hestia/bin/v-oneshot-service
[Install]
WantedBy=multi-user.target
Loading…
Cancel
Save