2015-05-12 04:37:28 +05:30
|
|
|
# Start / stop / status functions for s6 support
|
|
|
|
# Copyright (c) 2015 William Hubbs <w.d.hubbs@gmail.com>
|
|
|
|
# Released under the 2-clause BSD license.
|
|
|
|
|
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}"
|
|
|
|
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" ]
|
|
|
|
eend $? "Failed to start $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-05-14 22:10:29 +05:30
|
|
|
s6-svc -Dd -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" ]
|
2015-05-14 01:17:35 +05:30
|
|
|
eend $? "Failed to stop $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
|
|
|
}
|