2013-01-19 23:07:26 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# info: restart cron service
|
|
|
|
# options: NONE
|
|
|
|
#
|
|
|
|
# The function tells crond service to reread its configuration files.
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
|
|
# Variable&Function #
|
|
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
|
|
# Includes
|
|
|
|
source $VESTA/func/main.sh
|
2013-10-09 00:50:08 +03:00
|
|
|
source $VESTA/conf/vesta.conf
|
2016-08-09 17:36:36 +03:00
|
|
|
PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
|
2013-01-19 23:07:26 +02:00
|
|
|
|
2013-10-09 14:11:07 +03:00
|
|
|
send_email_report() {
|
|
|
|
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
|
|
|
|
email=$(echo "$email" | cut -f 2 -d "'")
|
|
|
|
tmpfile=$(mktemp)
|
|
|
|
subj="$(hostname): $CRON_SYSTEM restart failed"
|
2014-12-17 02:12:55 +02:00
|
|
|
service $CRON_SYSTEM configtest >> $tmpfile 2>&1
|
|
|
|
service $CRON_SYSTEM restart >> $tmpfile 2>&1
|
2016-06-24 16:31:43 +03:00
|
|
|
cat $tmpfile |$SENDMAIL -s "$subj" $email
|
2013-10-09 14:11:07 +03:00
|
|
|
rm -f $tmpfile
|
|
|
|
}
|
|
|
|
|
2013-01-19 23:07:26 +02:00
|
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
|
|
# Action #
|
|
|
|
#----------------------------------------------------------#
|
|
|
|
|
2016-11-09 17:45:43 +02:00
|
|
|
# Exit
|
|
|
|
if [ "$1" = "no" ]; then
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2013-06-01 14:25:44 +03:00
|
|
|
# Schedule restart
|
|
|
|
if [ "$1" = 'scheduled' ]; then
|
|
|
|
echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then
|
|
|
|
echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2014-03-23 16:14:21 +02:00
|
|
|
if [ -z "$CRON_SYSTEM" ] || [ "$CRON_SYSTEM" = 'remote' ]; then
|
2013-10-09 14:11:07 +03:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2013-06-01 14:25:44 +03:00
|
|
|
# Restart system
|
2014-12-17 02:12:55 +02:00
|
|
|
service $CRON_SYSTEM reload >/dev/null 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
service $CRON_SYSTEM restart >/dev/null 2>&1
|
2013-05-31 11:08:25 +03:00
|
|
|
if [ $? -ne 0 ]; then
|
2013-10-09 14:11:07 +03:00
|
|
|
send_email_report
|
2016-06-24 16:31:43 +03:00
|
|
|
check_result $E_RESTART "$CRON_SYSTEM restart failed"
|
2013-01-19 23:07:26 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2013-06-01 14:25:44 +03:00
|
|
|
# Update restart queue
|
|
|
|
if [ -e "$VESTA/data/queue/restart.pipe" ]; then
|
|
|
|
sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe
|
|
|
|
fi
|
|
|
|
|
2013-01-19 23:07:26 +02:00
|
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
|
|
# Vesta #
|
|
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
|
|
exit
|