Make service configuring correct for rpm

devel
Alexey Berezhok 12 months ago
parent c1e7097201
commit c4646bd8e8

@ -58,7 +58,10 @@ else
config_path='/etc/clamd.conf' config_path='/etc/clamd.conf'
fi fi
if [ -e '/etc/clamd.d/clamd.conf' ]; then if [ -e '/etc/clamd.d/clamd.conf' ]; then
config_path='/etc/clamav/clamd.conf' config_path='/etc/clamd.d/clamd.conf'
fi
if [ -e '/etc/clamd.d/daemon.conf' ]; then
config_path='/etc/clamd.d/daemon.conf'
fi fi
fi fi

@ -67,6 +67,12 @@ csv_list() {
declare -a versions declare -a versions
# List through /etc/php # List through /etc/php
if [ -f /etc/redhat-release ]; then
for version in /etc/opt/remi/php*/; do
ver=$(echo "$version" | awk -F"/" '{ print $5 }' | sed 's|php||')
versions+=("$ver")
done
else
if [ -n "$WEB_BACKEND" ]; then if [ -n "$WEB_BACKEND" ]; then
for version in /etc/php/*/fpm; do for version in /etc/php/*/fpm; do
ver=$(echo "$version" | awk -F"/" '{ print $4 }') ver=$(echo "$version" | awk -F"/" '{ print $4 }')
@ -79,6 +85,7 @@ else
versions+=("$ver") versions+=("$ver")
done done
fi fi
fi
# Listing data # Listing data
case $format in case $format in
json) json_list ;; json) json_list ;;

@ -63,10 +63,18 @@ csv_list() {
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining config path # Defining config path
if [ -f /etc/redhat-release ]; then
config_path=$(find /etc/opt/remi/php* -name php.ini)
else
config_path=$(find /etc/php* -name php.ini) config_path=$(find /etc/php* -name php.ini)
fi
config_count=$(echo "$config_path" | wc -l) config_count=$(echo "$config_path" | wc -l)
if [ "$config_count" -gt 1 ]; then if [ "$config_count" -gt 1 ]; then
if [ -f /etc/redhat-release ]; then
multiphp_versions=$(ls -d /etc/opt/remi/php*/php-fpm.d 2> /dev/null | wc -l)
else
multiphp_versions=$(ls -d /etc/php/*/fpm/pool.d 2> /dev/null | wc -l) multiphp_versions=$(ls -d /etc/php/*/fpm/pool.d 2> /dev/null | wc -l)
fi
if [ "$WEB_BACKEND" = 'php-fpm' ] || [ "$multiphp_versions" -gt 0 ]; then if [ "$WEB_BACKEND" = 'php-fpm' ] || [ "$multiphp_versions" -gt 0 ]; then
config_path=$(echo "$config_path" | grep fpm) config_path=$(echo "$config_path" | grep fpm)
else else

@ -86,6 +86,15 @@ get_srv_state() {
rtime="0" rtime="0"
# Searching related pids # Searching related pids
if [ -f /etc/redhat-release ] && [ "$name" = "php-fpm" ]; then
pids=''
for php_pid in $(pidof php-fpm); do
process_info=$(ps -p "$php_pid" -o args | tail -n1 | grep "$srv")
if [ -n "$process_info" ]; then
pids="${pids}|${php_pid}"
fi
done
else
if [ -z $3 ]; then if [ -z $3 ]; then
pids=$(pidof $name | tr ' ' '|') pids=$(pidof $name | tr ' ' '|')
else else
@ -94,6 +103,7 @@ get_srv_state() {
if [ -z "$pids" ] && [ "$name" != 'nginx' ]; then if [ -z "$pids" ] && [ "$name" != 'nginx' ]; then
pids=$(pgrep $name | tr '\n' '|') pids=$(pgrep $name | tr '\n' '|')
fi fi
fi
# Prevent from an SSH false positive when there is a TTY or SFTP connection but service is down # Prevent from an SSH false positive when there is a TTY or SFTP connection but service is down
if [ "$name" == 'ssh' ] && [ "$(systemctl show sshd.service | grep 'SubState=' | cut -f2 -d=)" != "running" ]; then if [ "$name" == 'ssh' ] && [ "$(systemctl show sshd.service | grep 'SubState=' | cut -f2 -d=)" != "running" ]; then
@ -164,15 +174,26 @@ fi
# Checking PHP intepreter # Checking PHP intepreter
if [ -n "$WEB_BACKEND" ] && [ "$WEB_BACKEND" != 'remote' ]; then if [ -n "$WEB_BACKEND" ] && [ "$WEB_BACKEND" != 'remote' ]; then
if [ -f /etc/redhat-release ]; then
php_versions=$(ls /opt/remi/php*/root/sbin/php-fpm | cut -d'/' -f4 | sed 's|php||')
for version in $php_versions; do
proc_name="php-fpm"
service_name="php${version}"
get_srv_state "$proc_name"
data="$data\nNAME='$service_name-php-fpm' SYSTEM='php interpreter' STATE='$state'"
data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'"
done
else
php_versions=$(ls /usr/sbin/php*fpm* | cut -d'/' -f4 | sed 's|php-fpm||') php_versions=$(ls /usr/sbin/php*fpm* | cut -d'/' -f4 | sed 's|php-fpm||')
for version in $php_versions; do for version in $php_versions; do
proc_name="php-fpm${version}" proc_name="php-fpm${version}"
service_name="php${version}-fpm" service_name="php${version}-fpm"
get_srv_state "$proc_name" get_srv_state "$service_name" "$proc_name"
data="$data\nNAME='$service_name' SYSTEM='php interpreter' STATE='$state'" data="$data\nNAME='$service_name' SYSTEM='php interpreter' STATE='$state'"
data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'" data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'"
done done
fi fi
fi
# Checking WEB Proxy # Checking WEB Proxy
if [ -n "$PROXY_SYSTEM" ] && [ "$PROXY_SYSTEM" != 'remote' ]; then if [ -n "$PROXY_SYSTEM" ] && [ "$PROXY_SYSTEM" != 'remote' ]; then
@ -210,6 +231,11 @@ if [ -n "$ANTIVIRUS_SYSTEM" ] && [ "$ANTIVIRUS_SYSTEM" != 'remote' ]; then
if [ "$ANTIVIRUS_SYSTEM" == 'clamav' ]; then if [ "$ANTIVIRUS_SYSTEM" == 'clamav' ]; then
ANTIVIRUS_SYSTEM='clamd' ANTIVIRUS_SYSTEM='clamd'
fi fi
if [ -f /etc/redhat-release ]; then
if [ "$ANTIVIRUS_SYSTEM" == 'clamav-daemon' ]; then
ANTIVIRUS_SYSTEM='clamd'
fi
fi
get_srv_state "$ANTIVIRUS_SYSTEM" get_srv_state "$ANTIVIRUS_SYSTEM"
else else
if [ "$ANTIVIRUS_SYSTEM" == 'clamav-daemon' ]; then if [ "$ANTIVIRUS_SYSTEM" == 'clamav-daemon' ]; then

@ -24,11 +24,11 @@ fi
php_DIR="/run/php" php_DIR="/run/php"
#make php directory in /var/run/directory for php-fpm and for hestia-php #make php directory in /var/run/directory for php-fpm and for hestia-php
if [ -f /etc/redhat-release ]; then if [ -f /etc/redhat-release ]; then
if [ ! -e "$php_DIR" ]; then
user_apache=$(cat $HESTIA_INSTALL_DIR/php-fpm/multiphp.tpl | grep listen.group | cut -d= -f2 | xargs) user_apache=$(cat $HESTIA_INSTALL_DIR/php-fpm/multiphp.tpl | grep listen.group | cut -d= -f2 | xargs)
if [ -n "$user_apache" ]; then if [ -n "$user_apache" ]; then
if grep -q "$user_apache" /etc/passwd; then if grep -q "$user_apache" /etc/passwd; then
if grep -q "$user_apache" /etc/group; then if grep -q "$user_apache" /etc/group; then
if [ ! -e "$php_DIR" ]; then
mkdir "$php_DIR" mkdir "$php_DIR"
chmod 755 "$php_DIR" chmod 755 "$php_DIR"
chown "$user_apache":"$user_apache" "$php_DIR" chown "$user_apache":"$user_apache" "$php_DIR"

@ -38,6 +38,10 @@ if [ "$DEBUG_MODE" = "true" ]; then
log="/var/log/hestia/debug.log" log="/var/log/hestia/debug.log"
fi fi
if [ "$service" = "cron" ] && [ -f /etc/redhat-release ]; then
service="crond"
fi
# Multi-instance service restart request handling # Multi-instance service restart request handling
if [ "$service" = "php-fpm" ]; then if [ "$service" = "php-fpm" ]; then
service_list='' service_list=''

@ -1127,7 +1127,7 @@ if [ "$exim" = 'yes' ]; then
fi fi
# Cron daemon # Cron daemon
write_config_value "CRON_SYSTEM" "cron" write_config_value "CRON_SYSTEM" "crond"
# Firewall stack # Firewall stack
if [ "$iptables" = 'yes' ]; then if [ "$iptables" = 'yes' ]; then

@ -10,6 +10,7 @@ ExecStart=/usr/local/hestia/php/sbin/php-fpm --fpm-config /usr/local/hestia/php/
ExecReload=/bin/kill -USR2 $MAINPID ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -TERM $MAINPID ExecStop=/bin/kill -TERM $MAINPID
ExecStartPre=/bin/bash -c "/bin/systemctl set-environment HOSTNAME=$(/usr/bin/hostname)" ExecStartPre=/bin/bash -c "/bin/systemctl set-environment HOSTNAME=$(/usr/bin/hostname)"
ExecStartPre=/bin/bash -c "[ -e /usr/local/hestia/bin/v-oneshot-service ] && /usr/local/hestia/bin/v-oneshot-service"
Environment="HESTIA=/usr/local/hestia" Environment="HESTIA=/usr/local/hestia"
[Install] [Install]

@ -125,7 +125,11 @@ unset($output);
$phpfpm = []; $phpfpm = [];
foreach ($php as $version) { foreach ($php as $version) {
$phpfpm[] = "php" . $version . "-fpm"; $phpfpm[] = "php" . $version . "-fpm";
$phpfpm[] = "php" . $version . "-php-fpm";
} }
$clamav_names = [];
$clamav_names[] = "clamav-daemon";
$clamav_names[] = "clamd";
exec(HESTIA_CMD . "v-list-sys-services json", $output, $return_var); exec(HESTIA_CMD . "v-list-sys-services json", $output, $return_var);
$data = json_decode(implode("", $output), true); $data = json_decode(implode("", $output), true);

@ -128,6 +128,11 @@
} else { } else {
$edit_url=$key; $edit_url=$key;
} }
if (in_array($key, $clamav_names)){
$edit_url="clamav-daemon";
} else {
$edit_url=$key;
}
$cpu = $data[$key]['CPU'] / 10; $cpu = $data[$key]['CPU'] / 10;
$cpu = number_format($cpu, 1); $cpu = number_format($cpu, 1);

Loading…
Cancel
Save