Commit 6df9738b authored by Vitaly Lipatov's avatar Vitaly Lipatov

serv: separate enable/disable and on/off

parent 8f82819f
......@@ -132,7 +132,7 @@ print_version()
[ "$virt" = "(unknown)" ] || [ "$virt" = "(host system)" ] || on_text="(under $virt)"
echo "Service manager version @VERSION@ https://wiki.etersoft.ru/Epm"
echo "Running on $($DISTRVENDOR -e) $on_text with $SERVICETYPE"
echo "Copyright (c) Etersoft 2012-2019"
echo "Copyright (c) Etersoft 2012-2021"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
}
......@@ -176,10 +176,16 @@ check_command()
stop) # HELPCMD: stop service
serv_cmd=stop
;;
on|enable) # HELPCMD: add service to run on startup and start it now
on) # HELPCMD: add service to run on startup and start it now
serv_cmd=on
;;
off) # HELPCMD: remove service to run on startup and stop it now
serv_cmd=off
;;
enable) # HELPCMD: add service to run on startup (see 'on' also)
serv_cmd=enable
;;
off|disable) # HELPCMD: remove service to run on startup and stop it now
disable) # HELPCMD: remove service to run on startup (see 'off' also)
serv_cmd=disable
;;
log|journal) # HELPCMD: print log for the service (-f - follow, -r - reverse order)
......
#!/bin/sh
#
# Copyright (C) 2012, 2016 Etersoft
# Copyright (C) 2012, 2016 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2016, 2021 Etersoft
# Copyright (C) 2012, 2016, 2021 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -25,7 +25,6 @@ serv_disable()
{
local SERVICE="$1"
is_service_running $1 && { serv_stop $1 || return ; }
is_service_autostart $1 || { info "Service $1 already disabled for startup" && return ; }
case $SERVICETYPE in
......
#!/bin/sh
#
# Copyright (C) 2012, 2016 Etersoft
# Copyright (C) 2012, 2016 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2016, 2021 Etersoft
# Copyright (C) 2012, 2016, 2021 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -21,7 +21,7 @@ load_helper serv-start
load_helper serv-status
# Enable service by default
__serv_enable()
serv_enable()
{
local SERVICE="$1"
......@@ -58,13 +58,4 @@ __serv_enable()
fatal "Have no suitable command for $SERVICETYPE"
;;
esac
}
serv_enable()
{
__serv_enable "$1" || return
# start if need
is_service_running $1 && info "Service $1 is already running" && return
serv_start $1
}
#!/bin/sh
#
# Copyright (C) 2012, 2016, 2021 Etersoft
# Copyright (C) 2012, 2016, 2021 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper serv-stop
load_helper serv-disable
load_helper serv-status
# Enable service by default
serv_off()
{
local SERVICE="$1"
is_service_running $1 && { serv_stop $1 || return ; }
is_service_autostart $1 || { info "Service $1 already disabled for startup" && return ; }
serv_disable $SERVICE
}
#!/bin/sh
#
# Copyright (C) 2012, 2016, 2021 Etersoft
# Copyright (C) 2012, 2016, 2021 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper serv-start
load_helper serv-enable
load_helper serv-status
serv_on()
{
serv_enable "$1" || return
# start if need
is_service_running $1 && info "Service $1 is already running" && return
serv_start $1
}
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