#!/bin/bash # info: restart proxy server # options: NONE # # The function reloads proxy server configuration. #----------------------------------------------------------# # Variable&Function # #----------------------------------------------------------# # Includes source $VESTA/conf/vesta.conf source $VESTA/func/main.sh #----------------------------------------------------------# # Action # #----------------------------------------------------------# # 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 # Restart system if [ ! -z "$PROXY_SYSTEM" ]; then /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 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 fi fi # Update restart queue if [ -e "$VESTA/data/queue/restart.pipe" ]; then sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe fi #----------------------------------------------------------# # Vesta # #----------------------------------------------------------# exit