3
# Copyright (C) 2012, 2013, 2016, 2017, 2021 Etersoft
4
# Copyright (C) 2012, 2013, 2016, 2017, 2021 Vitaly Lipatov <lav@etersoft.ru>
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Affero General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Affero General Public License for more details.
16
# You should have received a copy of the GNU Affero General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
# FIXME: sudo ask password, but we do not print command before
25
# TODO: real status can be checked only with grep output
27
service-chkconfig|service-upstart)
28
if is_anyservice $1 ; then
29
OUTPUT="$(sudorun anyservice $1 status 2>/dev/null)" || return 1
30
echo "$OUTPUT" | grep -q "is stopped" && return 1
33
OUTPUT="$(sudorun service $1 status 2>/dev/null)" || return 1
34
echo "$OUTPUT" | grep -q "is stopped" && return 1
37
service-initd|service-update)
38
sudorun $INITDIR/$1 status >/dev/null 2>/dev/null
41
a='' systemctl status $1 >/dev/null 2>/dev/null
44
sudorun sv status "$SERVICE" >/dev/null 2>/dev/null
47
fatal "Have no suitable command for $SERVICETYPE"
52
# FIXME: sudo ask password, but we do not print command before
58
service-chkconfig|service-upstart)
59
if is_anyservice $SERVICE; then
60
$ANYSERVICE $SERVICE isautostarted
64
# FIXME: check for current runlevel
65
LC_ALL=C sudorun chkconfig $1 --list | grep -q "[35]:on"
67
service-initd|service-update)
68
test -L "$(echo /etc/rc5.d/S??$1)"
71
a='' systemctl is-enabled $1
74
test -L "/var/service/$SERVICE"
77
fatal "Have no suitable command for $SERVICETYPE"
84
is_service_autostart $1 && echo "Service $1 is scheduled to run on startup" || echo "Service $1 will NOT run on startup"
90
service-chkconfig|service-upstart)
91
if is_anyservice $SERVICE ; then
92
sudocmd anyservice $SERVICE status
95
sudocmd service $SERVICE status "$@"
98
sudocmd $INITDIR/$SERVICE status "$@"
101
docmd systemctl -l status $SERVICE "$@"
104
sudocmd sv status "$SERVICE"
107
fatal "Have no suitable command for $SERVICETYPE"