mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 04:50:47 -07:00
simplified way to manage system services
This commit is contained in:
parent
96019af673
commit
c81a2bf123
4 changed files with 12 additions and 47 deletions
|
@ -23,14 +23,9 @@ get_srv_state() {
|
||||||
proc_name=${2-$1}
|
proc_name=${2-$1}
|
||||||
|
|
||||||
# Check service status
|
# Check service status
|
||||||
if [ -e "/etc/init.d/$srv" ]; then
|
status=1
|
||||||
/etc/init.d/$srv status > /dev/null 2>&1
|
if [ ! -z "$(service $srv status| grep running)" ]; then
|
||||||
status=$?
|
status=0
|
||||||
else
|
|
||||||
status=1
|
|
||||||
if [ ! -z "$(service $srv status| grep running)" ]; then
|
|
||||||
status=0
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $status -eq 0 ]; then
|
if [ $status -eq 0 ]; then
|
||||||
|
|
|
@ -27,25 +27,9 @@ check_args '1' "$#" 'SERVICE'
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
if [ -x "/etc/init.d/$service" ]; then
|
service $service restart >/dev/null 2>&1
|
||||||
/etc/init.d/$service restart >/dev/null 2>&1
|
if [ $? -ne 0 ]; then
|
||||||
if [ $? -ne 0 ]; then
|
exit $E_RESTART
|
||||||
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): $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
|
|
||||||
else
|
|
||||||
service $service restart >/dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,16 +27,9 @@ check_args '1' "$#" 'SERVICE'
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
if [ -x "/etc/init.d/$service" ]; then
|
service $service start >/dev/null 2>&1
|
||||||
/etc/init.d/$service start >/dev/null 2>&1
|
if [ $? -ne 0 ]; then
|
||||||
if [ $? -ne 0 ]; then
|
exit $E_RESTART
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
service $service start >/dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,16 +27,9 @@ check_args '1' "$#" 'SERVICE'
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
if [ -x "/etc/init.d/$service" ]; then
|
service $service stop >/dev/null 2>&1
|
||||||
/etc/init.d/$service stop >/dev/null 2>&1
|
if [ $? -ne 0 ]; then
|
||||||
if [ $? -ne 0 ]; then
|
exit $E_RESTART
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
service $service stop >/dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue