2013-12-22 02:21:11 +05:30
|
|
|
#!@SBINDIR@/openrc-run
|
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.
|
2007-11-14 20:52:04 +05:30
|
|
|
|
2017-12-15 00:14:45 +05:30
|
|
|
conf_d_dir="${RC_SERVICE%/*/*}/conf.d"
|
|
|
|
local_d_dir="${RC_SERVICE%/*/*}/local.d"
|
|
|
|
|
|
|
|
description="Executes user programs in ${local_d_dir}"
|
2007-07-11 00:39:41 +05:30
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
depend()
|
|
|
|
{
|
2007-04-05 16:48:42 +05:30
|
|
|
after *
|
2009-07-01 04:37:32 +05:30
|
|
|
keyword -timeout
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
start()
|
|
|
|
{
|
2017-12-15 00:14:45 +05:30
|
|
|
local file has_errors redirect retval
|
|
|
|
has_errors=0
|
2015-01-26 03:53:47 +05:30
|
|
|
yesno $rc_verbose || redirect='> /dev/null 2>&1'
|
2017-12-15 00:14:45 +05:30
|
|
|
ebegin "Starting local"
|
2014-06-10 18:53:17 +05:30
|
|
|
eindent
|
2017-12-15 00:14:45 +05:30
|
|
|
for file in "${local_d_dir}"/*.start; do
|
2014-06-10 18:53:17 +05:30
|
|
|
if [ -x "${file}" ]; then
|
|
|
|
vebegin "Executing \"${file}\""
|
2015-04-03 07:51:46 +05:30
|
|
|
eval "${file}" $redirect
|
2014-06-10 18:53:17 +05:30
|
|
|
retval=$?
|
|
|
|
if [ ${retval} -ne 0 ]; then
|
|
|
|
has_errors=1
|
|
|
|
fi
|
2014-07-06 01:00:33 +05:30
|
|
|
veend ${retval} "Execution of \"${file}\" failed."
|
2014-06-10 18:53:17 +05:30
|
|
|
fi
|
2011-01-06 23:43:33 +05:30
|
|
|
done
|
2014-06-10 18:53:17 +05:30
|
|
|
eoutdent
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2013-12-02 06:55:01 +05:30
|
|
|
if command -v local_start >/dev/null 2>&1; then
|
2017-12-15 00:14:45 +05:30
|
|
|
ewarn "\"${conf_d_dir}/local\" should be removed."
|
2011-01-06 23:43:33 +05:30
|
|
|
ewarn "Please move the code from the local_start function"
|
2014-06-10 18:53:17 +05:30
|
|
|
ewarn "to executable scripts with an .start extension"
|
2017-12-15 00:14:45 +05:30
|
|
|
ewarn "in \"${local_d_dir}\""
|
2007-12-14 19:42:38 +05:30
|
|
|
local_start
|
|
|
|
fi
|
|
|
|
|
2014-07-06 01:00:33 +05:30
|
|
|
eend ${has_errors}
|
2014-06-10 18:53:17 +05:30
|
|
|
|
|
|
|
# We have to end with a zero exit code, because a failed execution
|
2017-12-15 00:14:45 +05:30
|
|
|
# of an executable ${local_d_dir}/*.start file shouldn't result in
|
2014-06-10 18:53:17 +05:30
|
|
|
# marking the local service as failed. Otherwise we are unable to
|
2017-12-15 00:14:45 +05:30
|
|
|
# execute any executable ${local_d_dir}/*.stop file, because a failed
|
2014-06-10 18:53:17 +05:30
|
|
|
# marked service cannot be stopped (and the stop function would
|
2017-12-15 00:14:45 +05:30
|
|
|
# actually call the executable ${local_d_dir}/*.stop file(s)).
|
2014-06-10 18:53:17 +05:30
|
|
|
return 0
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
stop()
|
|
|
|
{
|
2017-12-15 00:14:45 +05:30
|
|
|
local file has_errors redirect retval
|
|
|
|
has_errors=0
|
2015-01-26 03:53:47 +05:30
|
|
|
yesno $rc_verbose || redirect='> /dev/null 2>&1'
|
2017-12-15 00:14:45 +05:30
|
|
|
ebegin "Stopping local"
|
2014-06-10 18:53:17 +05:30
|
|
|
eindent
|
2017-12-15 00:14:45 +05:30
|
|
|
for file in "${local_d_dir}"/*.stop; do
|
2014-06-10 18:53:17 +05:30
|
|
|
if [ -x "${file}" ]; then
|
|
|
|
vebegin "Executing \"${file}\""
|
2015-04-03 07:51:46 +05:30
|
|
|
eval "${file}" $redirect
|
2014-06-10 18:53:17 +05:30
|
|
|
retval=$?
|
|
|
|
if [ ${retval} -ne 0 ]; then
|
|
|
|
has_errors=1
|
|
|
|
fi
|
2014-07-06 01:00:33 +05:30
|
|
|
veend ${retval} "Execution of \"${file}\" failed."
|
2014-06-10 18:53:17 +05:30
|
|
|
fi
|
2011-01-06 23:43:33 +05:30
|
|
|
done
|
2014-06-10 18:53:17 +05:30
|
|
|
eoutdent
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2013-12-02 06:55:01 +05:30
|
|
|
if command -v local_stop >/dev/null 2>&1; then
|
2017-12-15 00:14:45 +05:30
|
|
|
ewarn "\"${conf_d_dir}/local\" should be removed."
|
2011-01-06 23:43:33 +05:30
|
|
|
ewarn "Please move the code from the local_stop function"
|
2014-06-10 18:53:17 +05:30
|
|
|
ewarn "to executable scripts with an .stop extension"
|
2017-12-15 00:14:45 +05:30
|
|
|
ewarn "in \"${local_d_dir}\""
|
2007-12-14 19:42:38 +05:30
|
|
|
local_stop
|
|
|
|
fi
|
|
|
|
|
2014-07-06 01:00:33 +05:30
|
|
|
eend ${has_errors}
|
2014-06-10 18:53:17 +05:30
|
|
|
|
2017-12-15 00:14:45 +05:30
|
|
|
# An executable ${local_d_dir}/*.stop file which failed with a
|
2014-06-10 18:53:17 +05:30
|
|
|
# non-zero exit status is not a reason to mark this service
|
|
|
|
# as failed, therefore we have to end with a zero exit code.
|
|
|
|
return 0
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|