mirror of
https://github.com/myvesta/vesta.git
synced 2025-03-12 04:35:23 -07:00
improved restart function
This commit is contained in:
parent
fd902a9066
commit
e7c94357a4
@ -13,6 +13,18 @@
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
send_email_report() {
|
||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
|
||||
email=$(echo "$email" | cut -f 2 -d "'")
|
||||
tmpfile=$(mktemp)
|
||||
subj="$(hostname): $CRON_SYSTEM restart failed"
|
||||
/etc/init.d/$CRON_SYSTEM configtest >> $tmpfile 2>&1
|
||||
/etc/init.d/$CRON_SYSTEM restart >> $tmpfile 2>&1
|
||||
cat $tmpfile | $send_mail -s "$subj" $email
|
||||
rm -f $tmpfile
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
@ -28,23 +40,19 @@ if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -z "$CRON_SYSTEM" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Restart system
|
||||
if [ ! -z "$CRON_SYSTEM" ]; then
|
||||
if [ -e "/var/run/crond.pid" ]; then
|
||||
/etc/init.d/$CRON_SYSTEM reload >/dev/null 2>&1
|
||||
reload cron >/dev/null 2>&1
|
||||
else
|
||||
/etc/init.d/$CRON_SYSTEM restart >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
/etc/init.d/$CRON_SYSTEM restart >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
|
||||
email=$(echo "$email" | cut -f 2 -d "'")
|
||||
tmpfile=$(mktemp)
|
||||
subj="$(hostname): $CRON_SYSTEM restart failed"
|
||||
/etc/init.d/$CRON_SYSTEM configtest >> $tmpfile 2>&1
|
||||
/etc/init.d/$CRON_SYSTEM restart >> $tmpfile 2>&1
|
||||
cat $tmpfile | $send_mail -s "$subj" $email
|
||||
rm -f $tmpfile
|
||||
exit $E_RESTART
|
||||
fi
|
||||
send_email_report
|
||||
exit $E_RESTART
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -13,6 +13,24 @@
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
send_email_report() {
|
||||
if [ -e '/etc/named.conf' ]; then
|
||||
dns_conf='/etc/named.conf'
|
||||
else
|
||||
dns_conf='/etc/bind/named.conf'
|
||||
fi
|
||||
|
||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
|
||||
email=$(echo "$email" | cut -f 2 -d "'")
|
||||
tmpfile=$(mktemp)
|
||||
subj="$(hostname): $DNS_SYSTEM restart failed"
|
||||
named-checkconf $dns_conf >> $tmpfile 2>&1
|
||||
/etc/init.d/$DNS_SYSTEM restart >> $tmpfile 2>&1
|
||||
cat $tmpfile | $send_mail -s "$subj" $email
|
||||
rm -f $tmpfile
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
@ -28,30 +46,17 @@ if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Restart system
|
||||
if [ ! -z "$DNS_SYSTEM" ]; then
|
||||
/etc/init.d/$DNS_SYSTEM reload >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
/etc/init.d/$DNS_SYSTEM restart >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
|
||||
email=$(echo "$email" | cut -f 2 -d "'")
|
||||
tmpfile=$(mktemp)
|
||||
subj="$(hostname): $DNS_SYSTEM restart failed"
|
||||
if [ -z "$DNS_SYSTEM" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Get dns config path
|
||||
if [ -e '/etc/named.conf' ]; then
|
||||
dns_conf='/etc/named.conf'
|
||||
else
|
||||
dns_conf='/etc/bind/named.conf'
|
||||
fi
|
||||
named-checkconf $dns_conf >> $tmpfile 2>&1
|
||||
/etc/init.d/$DNS_SYSTEM restart >> $tmpfile 2>&1
|
||||
cat $tmpfile | $send_mail -s "$subj" $email
|
||||
rm -f $tmpfile
|
||||
exit $E_RESTART
|
||||
fi
|
||||
# Restart system
|
||||
/etc/init.d/$DNS_SYSTEM reload >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
/etc/init.d/$DNS_SYSTEM restart >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
send_email_report
|
||||
exit $E_RESTART
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -13,6 +13,18 @@
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
send_email_report() {
|
||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
|
||||
email=$(echo "$email" | cut -f 2 -d "'")
|
||||
tmpfile=$(mktemp)
|
||||
subj="$(hostname): $FTP_SYSTEM restart failed"
|
||||
/etc/init.d/$FTP_SYSTEM configtest >> $tmpfile 2>&1
|
||||
/etc/init.d/$FTP_SYSTEM restart >> $tmpfile 2>&1
|
||||
cat $tmpfile | $send_mail -s "$subj" $email
|
||||
rm -f $tmpfile
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
@ -28,24 +40,15 @@ if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -z "$FTP_SYSTEM" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Restart system
|
||||
if [ ! -z "$FTP_SYSTEM" ]; then
|
||||
/etc/init.d/$FTP_SYSTEM reload >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
/etc/init.d/$FTP_SYSTEM restart >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
|
||||
email=$(echo "$email" | cut -f 2 -d "'")
|
||||
tmpfile=$(mktemp)
|
||||
subj="$(hostname): $FTP_SYSTEM restart failed"
|
||||
/etc/init.d/$FTP_SYSTEM configtest >> $tmpfile 2>&1
|
||||
/etc/init.d/$FTP_SYSTEM restart >> $tmpfile 2>&1
|
||||
cat $tmpfile | $send_mail -s "$subj" $email
|
||||
rm -f $tmpfile
|
||||
exit $E_RESTART
|
||||
fi
|
||||
fi
|
||||
/etc/init.d/$FTP_SYSTEM restart >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
send_email_report
|
||||
exit $E_RESTART
|
||||
fi
|
||||
|
||||
# Update restart queue
|
||||
|
@ -13,6 +13,18 @@
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
send_email_report() {
|
||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
|
||||
email=$(echo "$email" | cut -f 2 -d "'")
|
||||
tmpfile=$(mktemp)
|
||||
subj="$(hostname): $MAIL_SYSTEM restart failed"
|
||||
/etc/init.d/$MAIL_SYSTEM configtest >> $tmpfile 2>&1
|
||||
/etc/init.d/$MAIL_SYSTEM restart >> $tmpfile 2>&1
|
||||
cat $tmpfile | $send_mail -s "$subj" $email
|
||||
rm -f $tmpfile
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
@ -28,24 +40,16 @@ if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$MAIL_SYSTEM" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Restart system
|
||||
if [ ! -z "$MAIL_SYSTEM" ]; then
|
||||
/etc/init.d/$MAIL_SYSTEM reload >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
/etc/init.d/$MAIL_SYSTEM restart >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
|
||||
email=$(echo "$email" | cut -f 2 -d "'")
|
||||
tmpfile=$(mktemp)
|
||||
subj="$(hostname): $MAIL_SYSTEM restart failed"
|
||||
/etc/init.d/$MAIL_SYSTEM configtest >> $tmpfile 2>&1
|
||||
/etc/init.d/$MAIL_SYSTEM restart >> $tmpfile 2>&1
|
||||
cat $tmpfile | $send_mail -s "$subj" $email
|
||||
rm -f $tmpfile
|
||||
exit $E_RESTART
|
||||
fi
|
||||
fi
|
||||
/etc/init.d/$MAIL_SYSTEM restart >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
send_email_report
|
||||
exit $E_RESTART
|
||||
fi
|
||||
|
||||
# Update restart queue
|
||||
|
@ -13,6 +13,18 @@
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
send_email_report() {
|
||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
|
||||
email=$(echo "$email" | cut -f 2 -d "'")
|
||||
tmpfile=$(mktemp)
|
||||
subj="$(hostname): $PROXY_SYSTEM restart failed"
|
||||
/etc/init.d/$PROXY_SYSTEM configtest >> $tmpfile 2>&1
|
||||
/etc/init.d/$PROXY_SYSTEM restart >> $tmpfile 2>&1
|
||||
cat $tmpfile | $send_mail -s "$subj" $email
|
||||
rm -f $tmpfile
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
@ -28,23 +40,17 @@ if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -z "$PROXY_SYSTEM" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Restart system
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
/etc/init.d/$PROXY_SYSTEM reload >/dev/null 2>&1
|
||||
/etc/init.d/$PROXY_SYSTEM reload >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
/etc/init.d/$PROXY_SYSTEM restart >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
/etc/init.d/$PROXY_SYSTEM restart >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
|
||||
email=$(echo "$email" | cut -f 2 -d "'")
|
||||
tmpfile=$(mktemp)
|
||||
subj="$(hostname): $PROXY_SYSTEM restart failed"
|
||||
/etc/init.d/$PROXY_SYSTEM configtest >> $tmpfile 2>&1
|
||||
/etc/init.d/$PROXY_SYSTEM restart >> $tmpfile 2>&1
|
||||
cat $tmpfile | $send_mail -s "$subj" $email
|
||||
rm -f $tmpfile
|
||||
exit $E_RESTART
|
||||
fi
|
||||
send_email_report
|
||||
exit $E_RESTART
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -13,6 +13,18 @@
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/conf/vesta.conf
|
||||
|
||||
send_email_report() {
|
||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
|
||||
email=$(echo "$email" | cut -f 2 -d "'")
|
||||
tmpfile=$(mktemp)
|
||||
subj="$(hostname): $WEB_SYSTEM restart failed"
|
||||
/etc/init.d/$WEB_SYSTEM configtest >> $tmpfile 2>&1
|
||||
/etc/init.d/$WEB_SYSTEM restart >> $tmpfile 2>&1
|
||||
cat $tmpfile | $send_mail -s "$subj" $email
|
||||
rm -f $tmpfile
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
@ -28,21 +40,28 @@ if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$WEB_SYSTEM" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Restart system
|
||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||
if [ "$WEB_SYSTEM" == 'apache2' ]; then
|
||||
if [ -e "/var/run/apache2.pid" ]; then
|
||||
/etc/init.d/$WEB_SYSTEM reload >/dev/null 2>&1
|
||||
else
|
||||
/etc/init.d/$WEB_SYSTEM restart >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
send_email_report
|
||||
exit $E_RESTART
|
||||
fi
|
||||
fi
|
||||
else
|
||||
/etc/init.d/$WEB_SYSTEM reload >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
/etc/init.d/$WEB_SYSTEM restart >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
send_mail="$VESTA/web/inc/mail-wrapper.php"
|
||||
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
|
||||
email=$(echo "$email" | cut -f 2 -d "'")
|
||||
tmpfile=$(mktemp)
|
||||
subj="$(hostname): $WEB_SYSTEM restart failed"
|
||||
/etc/init.d/$WEB_SYSTEM configtest >> $tmpfile 2>&1
|
||||
/etc/init.d/$WEB_SYSTEM restart >> $tmpfile 2>&1
|
||||
cat $tmpfile | $send_mail -s "$subj" $email
|
||||
rm -f $tmpfile
|
||||
send_email_report
|
||||
exit $E_RESTART
|
||||
fi
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user