Added fixes for hestiacp for rpm installer
This commit is contained in:
51
bin/v-check-service-config
Executable file
51
bin/v-check-service-config
Executable file
@@ -0,0 +1,51 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# info: check service config
|
||||||
|
# options: [SERVICE NAME]
|
||||||
|
#
|
||||||
|
# example: v-restart-web
|
||||||
|
#
|
||||||
|
# This function return status of service check config.
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variables & Functions #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
date=$(date +"%Y-%m-%d %H:%M:%S")
|
||||||
|
DEBUG_LOG_FILE="/var/log/hestia/debug.log"
|
||||||
|
|
||||||
|
[[ -f /etc/redhat-release ]] || exit 0
|
||||||
|
|
||||||
|
[[ -n "$1" ]] || exit 1
|
||||||
|
|
||||||
|
[[ -n "$2" ]] || DEBUG_LOG_FILE="$2"
|
||||||
|
|
||||||
|
SERVICE_NAME="$1"
|
||||||
|
|
||||||
|
case "$SERVICE_NAME" in
|
||||||
|
nginx )
|
||||||
|
/usr/sbin/nginx -t >> "$DEBUG_LOG_FILE" 2>&1
|
||||||
|
V_RESULT=$?
|
||||||
|
exit $V_RESULT
|
||||||
|
;;
|
||||||
|
httpd )
|
||||||
|
/usr/sbin/httpd -t >> "$DEBUG_LOG_FILE" 2>&1
|
||||||
|
V_RESULT=$?
|
||||||
|
exit $V_RESULT
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Something like error, we shouldn't be here
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ BACKEND="$template"
|
|||||||
|
|
||||||
# Defining pool directory
|
# Defining pool directory
|
||||||
if [ -f "/etc/redhat-release" ]; then
|
if [ -f "/etc/redhat-release" ]; then
|
||||||
pool=$(find -L /etc/opt/remi/php80/ -name "$domain.conf" -exec dirname {} \;)
|
pool=$(find -L /etc/opt/remi/ -name "$domain.conf" -exec dirname {} \;)
|
||||||
else
|
else
|
||||||
pool=$(find -L /etc/php/ -name "$domain.conf" -exec dirname {} \;)
|
pool=$(find -L /etc/php/ -name "$domain.conf" -exec dirname {} \;)
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -23,8 +23,12 @@ send_email_report() {
|
|||||||
email=$(echo "$email" | cut -f 2 -d "'")
|
email=$(echo "$email" | cut -f 2 -d "'")
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
subj="$(hostname): $FTP_SYSTEM restart failed"
|
subj="$(hostname): $FTP_SYSTEM restart failed"
|
||||||
service "$FTP_SYSTEM" configtest >> $tmpfile 2>&1
|
if [ -f /etc/redhat-release ]; then
|
||||||
service "$FTP_SYSTEM" restart >> $tmpfile 2>&1
|
systemctl restart "$FTP_SYSTEM" >> $tmpfile 2>&1
|
||||||
|
else
|
||||||
|
service "$FTP_SYSTEM" configtest >> $tmpfile 2>&1
|
||||||
|
service "$FTP_SYSTEM" restart >> $tmpfile 2>&1
|
||||||
|
fi
|
||||||
cat $tmpfile | $SENDMAIL -s "$subj" $email
|
cat $tmpfile | $SENDMAIL -s "$subj" $email
|
||||||
rm -f $tmpfile
|
rm -f $tmpfile
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,13 +70,20 @@ if [ -f "$HESTIA/web/inc/nginx_proxy" ]; then
|
|||||||
if [ "$1" = 'background' ]; then
|
if [ "$1" = 'background' ]; then
|
||||||
# Restart system
|
# Restart system
|
||||||
sleep 15
|
sleep 15
|
||||||
|
|
||||||
# Preform a check if Nginx is valid as reload doesn't throw an error / exit
|
# Preform a check if Nginx is valid as reload doesn't throw an error / exit
|
||||||
if [ "$DEBUG_MODE" = "true" ]; then
|
if [ "$DEBUG_MODE" = "true" ]; then
|
||||||
echo "[ $date | $PROXY_SYSTEM ]" >> /var/log/hestia/debug.log 2>&1
|
echo "[ $date | $PROXY_SYSTEM ]" >> /var/log/hestia/debug.log 2>&1
|
||||||
service $PROXY_SYSTEM configtest >> /var/log/hestia/debug.log 2>&1
|
if [ -f /etc/redhat-release ]; then
|
||||||
|
$BIN/v-check-service-config "$PROXY_SYSTEM" /var/log/hestia/debug.log
|
||||||
|
else
|
||||||
|
service $PROXY_SYSTEM configtest >> /var/log/hestia/debug.log 2>&1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
service $PROXY_SYSTEM configtest > /dev/null 2>&1
|
if [ -f /etc/redhat-release ]; then
|
||||||
|
$BIN/v-check-service-config "$PROXY_SYSTEM" /dev/null
|
||||||
|
else
|
||||||
|
service $PROXY_SYSTEM configtest > /dev/null 2>&1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
send_email_report
|
send_email_report
|
||||||
@@ -100,9 +107,17 @@ else
|
|||||||
# Preform a check if Nginx is valid as reload doesn't throw an error / exit
|
# Preform a check if Nginx is valid as reload doesn't throw an error / exit
|
||||||
if [ "$DEBUG_MODE" = "true" ]; then
|
if [ "$DEBUG_MODE" = "true" ]; then
|
||||||
echo "[ $date | $PROXY_SYSTEM ]" >> /var/log/hestia/debug.log 2>&1
|
echo "[ $date | $PROXY_SYSTEM ]" >> /var/log/hestia/debug.log 2>&1
|
||||||
service $PROXY_SYSTEM configtest >> /var/log/hestia/debug.log 2>&1
|
if [ -f /etc/redhat-release ]; then
|
||||||
|
$BIN/v-check-service-config "$PROXY_SYSTEM" /var/log/hestia/debug.log
|
||||||
|
else
|
||||||
|
service $PROXY_SYSTEM configtest >> /var/log/hestia/debug.log 2>&1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
service $PROXY_SYSTEM configtest > /dev/null 2>&1
|
if [ -f /etc/redhat-release ]; then
|
||||||
|
$BIN/v-check-service-config "$PROXY_SYSTEM" /dev/null
|
||||||
|
else
|
||||||
|
service $PROXY_SYSTEM configtest > /dev/null 2>&1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
send_email_report
|
send_email_report
|
||||||
|
|||||||
@@ -28,7 +28,11 @@ send_email_report() {
|
|||||||
if [ "$WEB_SYSTEM" = "apache2" ]; then
|
if [ "$WEB_SYSTEM" = "apache2" ]; then
|
||||||
apache2ctl configtest >> "$tmpfile" 2>&1
|
apache2ctl configtest >> "$tmpfile" 2>&1
|
||||||
else
|
else
|
||||||
service $WEB_SYSTEM configtest >> "$tmpfile" 2>&1
|
if [ -f /etc/redhat-release ]; then
|
||||||
|
$BIN/v-check-service-config "$WEB_SYSTEM" "$tmpfile"
|
||||||
|
else
|
||||||
|
service $WEB_SYSTEM configtest >> "$tmpfile" 2>&1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$1" == "DO_RESTART" ]; then
|
if [ "$1" == "DO_RESTART" ]; then
|
||||||
service "$WEB_SYSTEM" restart >> "$tmpfile" 2>&1
|
service "$WEB_SYSTEM" restart >> "$tmpfile" 2>&1
|
||||||
@@ -74,9 +78,17 @@ if [ $WEB_SYSTEM = 'nginx' ]; then
|
|||||||
fi
|
fi
|
||||||
if [ "$DEBUG_MODE" = "true" ]; then
|
if [ "$DEBUG_MODE" = "true" ]; then
|
||||||
echo "[ $date | $WEB_SYSTEM | WEB ]" >> /var/log/hestia/debug.log 2>&1
|
echo "[ $date | $WEB_SYSTEM | WEB ]" >> /var/log/hestia/debug.log 2>&1
|
||||||
service $WEB_SYSTEM configtest >> /var/log/hestia/debug.log 2>&1
|
if [ -f /etc/redhat-release ]; then
|
||||||
|
$BIN/v-check-service-config "$WEB_SYSTEM"
|
||||||
|
else
|
||||||
|
service $WEB_SYSTEM configtest >> /var/log/hestia/debug.log 2>&1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
service $WEB_SYSTEM configtest > /dev/null 2>&1
|
if [ -f /etc/redhat-release ]; then
|
||||||
|
$BIN/v-check-service-config "$WEB_SYSTEM" /dev/null
|
||||||
|
else
|
||||||
|
service $WEB_SYSTEM configtest > /dev/null 2>&1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
send_email_report
|
send_email_report
|
||||||
@@ -93,6 +105,17 @@ elif [ $WEB_SYSTEM = 'apache2' ]; then
|
|||||||
send_email_report
|
send_email_report
|
||||||
check_result "$E_RESTART" "$WEB_SYSTEM restart failed"
|
check_result "$E_RESTART" "$WEB_SYSTEM restart failed"
|
||||||
fi
|
fi
|
||||||
|
elif [ $WEB_SYSTEM = 'httpd' ]; then
|
||||||
|
if [ "$DEBUG_MODE" = "true" ]; then
|
||||||
|
echo "[ $date | $WEB_SYSTEM | WEB ]" >> /var/log/hestia/debug.log 2>&1
|
||||||
|
$BIN/v-check-service-config "$WEB_SYSTEM" /var/log/hestia/debug.log
|
||||||
|
else
|
||||||
|
$BIN/v-check-service-config "$WEB_SYSTEM" /dev/null
|
||||||
|
fi
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
send_email_report
|
||||||
|
check_result "$E_RESTART" "$WEB_SYSTEM restart failed"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$BIN/v-restart-service "$WEB_SYSTEM" "$restart"
|
$BIN/v-restart-service "$WEB_SYSTEM" "$restart"
|
||||||
|
|||||||
@@ -147,7 +147,11 @@ prepare_web_backend() {
|
|||||||
|
|
||||||
# Delete web backend
|
# Delete 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 {} \;
|
find -L /etc/php/ -type f -name "$backend_type.conf" -exec rm -f {} \;
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prepare web aliases
|
# Prepare web aliases
|
||||||
|
|||||||
Reference in New Issue
Block a user