Commit 812284b6 authored by Vitaly Lipatov's avatar Vitaly Lipatov

add serv try-restart|condrestart command

parent bb60d622
......@@ -129,9 +129,14 @@ check_command()
status) # HELPCMD: show service status
serv_cmd=status
;;
#restart) # HELPCMD: restart service
#reload) # HELPCMD: reload service
start) # HELPCMD: start service
serv_cmd=start
;;
try-restart|condrestart) # HELPCMD: Restart service if running
serv_cmd=try_restart
;;
stop) # HELPCMD: stop service
serv_cmd=stop
;;
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
load_helper serv-status
# Try restart service (if it is running)
serv_try_restart()
{
case $SERVICETYPE in
service-chkconfig)
is_service_running $1 || return 0
sudocmd service $1 restart
;;
service-update)
is_service_running $1 || return 0
sudocmd /etc/init.d/$1 restart
;;
systemd)
sudocmd systemctl try-restart $1
;;
*)
fatal "Do not known command for $SERVICETYPE"
;;
esac
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment