2015-05-10 04:26:45 +05:30
|
|
|
# start / stop / status functions for start-stop-daemon
|
2015-12-05 04:22:19 +05:30
|
|
|
|
|
|
|
# Copyright (c) 2007-2015 The OpenRC Authors.
|
|
|
|
# See the Authors file at the top-level directory of this distribution and
|
2021-12-21 06:37:00 +05:30
|
|
|
# https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
|
2015-12-05 04:22:19 +05:30
|
|
|
#
|
|
|
|
# This file is part of OpenRC. It is subject to the license terms in
|
|
|
|
# the LICENSE file found in the top-level directory of this
|
2021-12-21 06:37:00 +05:30
|
|
|
# distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE
|
2015-12-05 04:22:19 +05:30
|
|
|
# This file may not be copied, modified, propagated, or distributed
|
|
|
|
# except according to the terms contained in the LICENSE file.
|
2015-05-08 21:59:49 +05:30
|
|
|
|
2015-05-10 04:26:45 +05:30
|
|
|
ssd_start()
|
2015-05-08 21:59:49 +05:30
|
|
|
{
|
2015-10-03 03:04:15 +05:30
|
|
|
if [ -z "$command" ]; then
|
|
|
|
ewarn "The command variable is undefined."
|
|
|
|
ewarn "There is nothing for ${name:-$RC_SVCNAME} to start."
|
|
|
|
ewarn "If this is what you intend, please write a start function."
|
|
|
|
ewarn "This will become a failure in a future release."
|
|
|
|
return 0
|
|
|
|
fi
|
2015-05-08 21:59:49 +05:30
|
|
|
|
|
|
|
local _background=
|
|
|
|
ebegin "Starting ${name:-$RC_SVCNAME}"
|
|
|
|
if yesno "${command_background}"; then
|
|
|
|
if [ -z "${pidfile}" ]; then
|
|
|
|
eend 1 "command_background option used but no pidfile specified"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
if [ -n "${command_args_background}" ]; then
|
|
|
|
eend 1 "command_background used with command_args_background"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
_background="--background --make-pidfile"
|
|
|
|
fi
|
|
|
|
if yesno "$start_inactive"; then
|
|
|
|
local _inactive=false
|
|
|
|
service_inactive && _inactive=true
|
|
|
|
mark_service_inactive
|
|
|
|
fi
|
2018-10-13 03:46:23 +05:30
|
|
|
[ -n "$output_logger" ] &&
|
2018-06-16 04:14:39 +05:30
|
|
|
output_logger_arg="--stdout-logger \"$output_logger\""
|
2018-10-13 03:46:23 +05:30
|
|
|
[ -n "$error_logger" ] &&
|
2018-06-16 04:14:39 +05:30
|
|
|
error_logger_arg="--stderr-logger \"$error_logger\""
|
2016-09-20 21:53:46 +05:30
|
|
|
#the eval call is necessary for cases like:
|
|
|
|
# command_args="this \"is a\" test"
|
|
|
|
# to work properly.
|
|
|
|
eval start-stop-daemon --start \
|
2015-05-08 21:59:49 +05:30
|
|
|
--exec $command \
|
2016-05-20 04:28:14 +05:30
|
|
|
${chroot:+--chroot} $chroot \
|
2017-11-21 04:15:51 +05:30
|
|
|
${directory:+--chdir} $directory \
|
|
|
|
${output_log+--stdout} $output_log \
|
|
|
|
${error_log+--stderr} $error_log \
|
2018-06-16 04:14:39 +05:30
|
|
|
${output_logger_arg} \
|
|
|
|
${error_logger_arg} \
|
2015-05-08 21:59:49 +05:30
|
|
|
${procname:+--name} $procname \
|
|
|
|
${pidfile:+--pidfile} $pidfile \
|
|
|
|
${command_user+--user} $command_user \
|
2017-11-21 04:15:51 +05:30
|
|
|
${umask+--umask} $umask \
|
2015-05-08 21:59:49 +05:30
|
|
|
$_background $start_stop_daemon_args \
|
|
|
|
-- $command_args $command_args_background
|
2016-09-13 22:57:08 +05:30
|
|
|
if eend $? "Failed to start ${name:-$RC_SVCNAME}"; then
|
2015-05-08 21:59:49 +05:30
|
|
|
service_set_value "command" "${command}"
|
2016-05-20 04:28:14 +05:30
|
|
|
[ -n "${chroot}" ] && service_set_value "chroot" "${chroot}"
|
2015-05-08 21:59:49 +05:30
|
|
|
[ -n "${pidfile}" ] && service_set_value "pidfile" "${pidfile}"
|
|
|
|
[ -n "${procname}" ] && service_set_value "procname" "${procname}"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
if yesno "$start_inactive"; then
|
|
|
|
if ! $_inactive; then
|
|
|
|
mark_service_stopped
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2015-05-10 04:26:45 +05:30
|
|
|
ssd_stop()
|
2015-05-08 21:59:49 +05:30
|
|
|
{
|
2016-09-17 00:53:09 +05:30
|
|
|
local _progress=
|
2015-05-08 21:59:49 +05:30
|
|
|
local startcommand="$(service_get_value "command")"
|
2016-05-20 04:28:14 +05:30
|
|
|
local startchroot="$(service_get_value "chroot")"
|
2015-05-08 21:59:49 +05:30
|
|
|
local startpidfile="$(service_get_value "pidfile")"
|
|
|
|
local startprocname="$(service_get_value "procname")"
|
|
|
|
command="${startcommand:-$command}"
|
2016-05-20 04:28:14 +05:30
|
|
|
chroot="${startchroot:-$chroot}"
|
2015-05-08 21:59:49 +05:30
|
|
|
pidfile="${startpidfile:-$pidfile}"
|
|
|
|
procname="${startprocname:-$procname}"
|
|
|
|
[ -n "$command" -o -n "$procname" -o -n "$pidfile" ] || return 0
|
2016-09-17 00:53:09 +05:30
|
|
|
yesno "${command_progress}" && _progress=--progress
|
2015-05-08 21:59:49 +05:30
|
|
|
ebegin "Stopping ${name:-$RC_SVCNAME}"
|
|
|
|
start-stop-daemon --stop \
|
|
|
|
${retry:+--retry} $retry \
|
|
|
|
${command:+--exec} $command \
|
|
|
|
${procname:+--name} $procname \
|
2016-05-20 04:28:14 +05:30
|
|
|
${pidfile:+--pidfile} $chroot$pidfile \
|
2016-09-17 00:53:09 +05:30
|
|
|
${stopsig:+--signal} $stopsig \
|
|
|
|
${_progress}
|
2015-05-08 21:59:49 +05:30
|
|
|
|
2016-09-13 22:57:08 +05:30
|
|
|
eend $? "Failed to stop ${name:-$RC_SVCNAME}"
|
2015-05-08 21:59:49 +05:30
|
|
|
}
|
|
|
|
|
2015-05-10 04:26:45 +05:30
|
|
|
ssd_status()
|
2015-05-08 21:59:49 +05:30
|
|
|
{
|
|
|
|
_status
|
|
|
|
}
|