2015-05-12 04:37:28 +05:30
|
|
|
# Start / stop / status functions for s6 support
|
2015-12-05 04:22:19 +05:30
|
|
|
|
|
|
|
# Copyright (c) 2015 The OpenRC Authors.
|
|
|
|
# See the Authors file at the top-level directory of this distribution and
|
|
|
|
# https://github.com/OpenRC/openrc/blob/master/AUTHORS
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
|
|
|
|
# This file may not be copied, modified, propagated, or distributed
|
|
|
|
# except according to the terms contained in the LICENSE file.
|
2015-05-12 04:37:28 +05:30
|
|
|
|
2015-05-14 01:17:35 +05:30
|
|
|
[ -z "${s6_service_path}" ] && s6_service_path="/var/svc.d/${RC_SVCNAME}"
|
2015-05-12 04:37:28 +05:30
|
|
|
|
|
|
|
s6_start()
|
|
|
|
{
|
|
|
|
if [ ! -d "${s6_service_path}" ]; then
|
|
|
|
eerror "${s6_service_path} does not exist."
|
|
|
|
return 1
|
|
|
|
fi
|
2015-05-14 01:17:35 +05:30
|
|
|
s6_service_link="${RC_SVCDIR}/s6-scan/${s6_service_path##*/}"
|
2015-05-12 04:37:28 +05:30
|
|
|
ebegin "Starting ${name:-$RC_SVCNAME}"
|
2015-05-14 01:17:35 +05:30
|
|
|
ln -sf "${s6_service_path}" "${s6_service_link}"
|
2015-05-15 00:56:52 +05:30
|
|
|
s6-svscanctl -na "${RC_SVCDIR}"/s6-scan
|
|
|
|
sleep 1.5
|
2015-05-14 01:17:35 +05:30
|
|
|
s6-svc -u "${s6_service_link}"
|
2015-05-12 04:37:28 +05:30
|
|
|
if [ -n "$s6_svwait_options_start" ]; then
|
2015-05-14 01:17:35 +05:30
|
|
|
s6-svwait ${s6_svwait_options_start} "${s6_service_link}"
|
2015-05-12 04:37:28 +05:30
|
|
|
fi
|
2015-05-14 01:17:35 +05:30
|
|
|
sleep 1.5
|
|
|
|
set -- $(s6-svstat "${s6_service_link}")
|
|
|
|
[ "$1" = "up" ]
|
2016-09-13 22:57:08 +05:30
|
|
|
eend $? "Failed to start ${name:-$RC_SVCNAME}"
|
2015-05-12 04:37:28 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
s6_stop()
|
|
|
|
{
|
|
|
|
if [ ! -d "${s6_service_path}" ]; then
|
|
|
|
eerror "${s6_service_path} does not exist."
|
|
|
|
return 1
|
|
|
|
fi
|
2015-05-14 01:17:35 +05:30
|
|
|
s6_service_link="${RC_SVCDIR}/s6-scan/${s6_service_path##*/}"
|
2015-05-12 04:37:28 +05:30
|
|
|
ebegin "Stopping ${name:-$RC_SVCNAME}"
|
2015-09-14 13:13:42 +05:30
|
|
|
s6-svc -wD -d -T ${s6_service_timeout_stop:-10000} "${s6_service_link}"
|
2015-05-14 01:17:35 +05:30
|
|
|
set -- $(s6-svstat "${s6_service_link}")
|
2015-05-14 03:21:55 +05:30
|
|
|
[ "$1" = "down" ]
|
2016-09-13 22:57:08 +05:30
|
|
|
eend $? "Failed to stop ${name:-$RC_SVCNAME}"
|
2015-05-12 04:37:28 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
s6_status()
|
|
|
|
{
|
2015-05-14 01:17:35 +05:30
|
|
|
s6_service_link="${RC_SVCDIR}/s6-scan/${s6_service_path##*/}"
|
2015-05-14 03:21:55 +05:30
|
|
|
if [ -L "${s6_service_link}" ]; then
|
|
|
|
s6-svstat "${s6_service_link}"
|
|
|
|
else
|
|
|
|
_status
|
|
|
|
fi
|
2015-05-12 04:37:28 +05:30
|
|
|
}
|