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
|
||||
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
|
||||
pool=$(find -L /etc/php/ -name "$domain.conf" -exec dirname {} \;)
|
||||
fi
|
||||
|
||||
@@ -23,8 +23,12 @@ send_email_report() {
|
||||
email=$(echo "$email" | cut -f 2 -d "'")
|
||||
tmpfile=$(mktemp)
|
||||
subj="$(hostname): $FTP_SYSTEM restart failed"
|
||||
service "$FTP_SYSTEM" configtest >> $tmpfile 2>&1
|
||||
service "$FTP_SYSTEM" restart >> $tmpfile 2>&1
|
||||
if [ -f /etc/redhat-release ]; then
|
||||
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
|
||||
rm -f $tmpfile
|
||||
}
|
||||
|
||||
@@ -70,13 +70,20 @@ if [ -f "$HESTIA/web/inc/nginx_proxy" ]; then
|
||||
if [ "$1" = 'background' ]; then
|
||||
# Restart system
|
||||
sleep 15
|
||||
|
||||
# Preform a check if Nginx is valid as reload doesn't throw an error / exit
|
||||
if [ "$DEBUG_MODE" = "true" ]; then
|
||||
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
|
||||
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
|
||||
if [ $? -ne 0 ]; then
|
||||
send_email_report
|
||||
@@ -100,9 +107,17 @@ else
|
||||
# Preform a check if Nginx is valid as reload doesn't throw an error / exit
|
||||
if [ "$DEBUG_MODE" = "true" ]; then
|
||||
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
|
||||
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
|
||||
if [ $? -ne 0 ]; then
|
||||
send_email_report
|
||||
|
||||
@@ -28,7 +28,11 @@ send_email_report() {
|
||||
if [ "$WEB_SYSTEM" = "apache2" ]; then
|
||||
apache2ctl configtest >> "$tmpfile" 2>&1
|
||||
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
|
||||
if [ "$1" == "DO_RESTART" ]; then
|
||||
service "$WEB_SYSTEM" restart >> "$tmpfile" 2>&1
|
||||
@@ -74,9 +78,17 @@ if [ $WEB_SYSTEM = 'nginx' ]; then
|
||||
fi
|
||||
if [ "$DEBUG_MODE" = "true" ]; then
|
||||
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
|
||||
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
|
||||
if [ $? -ne 0 ]; then
|
||||
send_email_report
|
||||
@@ -93,6 +105,17 @@ elif [ $WEB_SYSTEM = 'apache2' ]; then
|
||||
send_email_report
|
||||
check_result "$E_RESTART" "$WEB_SYSTEM restart failed"
|
||||
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
|
||||
|
||||
$BIN/v-restart-service "$WEB_SYSTEM" "$restart"
|
||||
|
||||
Reference in New Issue
Block a user