#!/bin/bash # info: restart service # options: service # # The function restarts system service. #----------------------------------------------------------# # Variable&Function # #----------------------------------------------------------# # Argument defenition service=$1 # Includes source $VESTA/func/main.sh #----------------------------------------------------------# # Verifications # #----------------------------------------------------------# check_args '1' "$#" 'SERVICE' #----------------------------------------------------------# # Action # #----------------------------------------------------------# if [ -x "/etc/init.d/$service" ]; then /etc/init.d/$service restart >/dev/null 2>&1 if [ $? -ne 0 ]; then if [ -e "$VESTA/web/inc/mail-wrapper.php" ]; then send_mail="$VESTA/web/inc/mail-wrapper.php" else send_mail=$(which mail) fi email=$(grep CONTACT $VESTA/data/users/admin/user.conf) email=$(echo "$email" | cut -f 2 -d "'") tmpfile=$(mktemp) subj="$(hostname): $service restart failed" /etc/init.d/$service configtest >> $tmpfile 2>&1 /etc/init.d/$service restart >> $tmpfile 2>&1 cat $tmpfile | $send_mail -s "$subj" $email rm -f $tmpfile exit $E_RESTART fi fi #----------------------------------------------------------# # Vesta # #----------------------------------------------------------# exit