]>
git.ipfire.org Git - people/stevee/network.git/blob - src/functions/functions.service
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2010 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
26 # Don't start anything if this is already running
27 if service_is_active
"${name}"; then
31 systemctl start
"${name}"
33 # Check, if the service was successfully started and
34 # return a proper exit code.
35 service_is_active
"${name}"
38 log INFO
"Started service '${name}', code=${ret}."
47 systemctl stop
"${name}"
54 systemctl restart
"${name}"
61 if service_status
"${name}"; then
62 systemctl reload
"${name}"
65 log WARNING
"Cannot reload service '${name}' which is currently not running."
73 systemctl status
"${name}" >/dev
/null
2>&1
77 # This function calls the "enable" command from systemd,
78 # to mark services to be automatically started during
84 systemctl
enable "${name}" >/dev
/null
2>&1
87 # This function calls the "disable" command of systemd,
88 # to drop the autostart ability of the service during the
94 systemctl disable
"${name}" >/dev
/null
2>&1
97 # This function uses the systemd command "is-enabled" to check,
98 # if a service has been enabled or not.
99 service_is_enabled
() {
103 systemctl is-enabled
"${name}" >/dev
/null
2>&1
107 service_is_active
() {
111 systemctl is-active
"${name}" >/dev
/null
2>&1
115 service_get_exitcode
() {
119 local output
=$
(systemctl show
"${name}" --property="ExecMainStatus")
120 cli_get_val
"${output}"