mirror of
https://github.com/myvesta/vesta.git
synced 2024-12-21 11:31:21 -08:00
76 lines
2.0 KiB
Bash
Executable File
76 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: restart backend server
|
|
# options: NONE
|
|
#
|
|
# The function reloads backend server configuration.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/conf/vesta.conf
|
|
PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
|
|
|
|
send_email_report() {
|
|
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
|
|
email=$(echo "$email" | cut -f 2 -d "'")
|
|
tmpfile=$(mktemp)
|
|
subj="$(hostname): $WEB_BACKEND restart failed"
|
|
service $WEB_BACKEND configtest >> $tmpfile 2>&1
|
|
service $WEB_BACKEND restart >> $tmpfile 2>&1
|
|
cat $tmpfile |$SENDMAIL -s "$subj" $email
|
|
rm -f $tmpfile
|
|
}
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Exit
|
|
if [ "$1" = "no" ]; then
|
|
exit
|
|
fi
|
|
|
|
# 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
|
|
|
|
if [ -z "$WEB_BACKEND" ] || [ "$WEB_BACKEND" = 'remote' ]; then
|
|
exit
|
|
fi
|
|
|
|
# Restart system
|
|
php_fpm=$(ls /etc/init.d/php*-fpm* 2>/dev/null |cut -f 4 -d / |head -n 1)
|
|
if [ -z "$php_fpm" ]; then
|
|
service $WEB_BACKEND restart >/dev/null 2>&1
|
|
else
|
|
service $php_fpm restart >/dev/null 2>&1
|
|
fi
|
|
|
|
if [ $? -ne 0 ]; then
|
|
send_email_report
|
|
check_result $E_RESTART "$WEB_BACKEND restart failed"
|
|
fi
|
|
|
|
# Update restart queue
|
|
if [ -e "$VESTA/data/queue/restart.pipe" ]; then
|
|
sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe
|
|
fi
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
exit
|