2013-12-22 02:21:11 +05:30
|
|
|
#!@SBINDIR@/openrc-run
|
2009-05-01 19:41:40 +05:30
|
|
|
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
|
2011-06-30 05:16:31 +05:30
|
|
|
# Released under the 2-clause BSD license.
|
2007-11-14 20:52:04 +05:30
|
|
|
|
2011-01-06 23:43:33 +05:30
|
|
|
description="Executes user programs in @SYSCONFDIR@/local.d"
|
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()
|
|
|
|
{
|
2014-06-10 18:53:17 +05:30
|
|
|
ebegin "Starting local"
|
2011-01-06 23:43:33 +05:30
|
|
|
|
2014-07-06 01:00:33 +05:30
|
|
|
local file has_errors=0 retval
|
2014-06-10 18:53:17 +05:30
|
|
|
eindent
|
|
|
|
for file in @SYSCONFDIR@/local.d/*.start; do
|
|
|
|
if [ -x "${file}" ]; then
|
|
|
|
vebegin "Executing \"${file}\""
|
|
|
|
"${file}" 2>&1 >/dev/null
|
|
|
|
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
|
2014-06-10 18:53:17 +05:30
|
|
|
ewarn "\"@SYSCONFDIR@/conf.d/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"
|
|
|
|
ewarn "in \"@SYSCONFDIR@/local.d\""
|
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
|
|
|
|
# of an executable @SYSCONFDIR@/local.d/*.start file shouldn't result in
|
|
|
|
# marking the local service as failed. Otherwise we are unable to
|
|
|
|
# execute any executable @SYSCONFDIR@/local.d/*.stop file, because a failed
|
|
|
|
# marked service cannot be stopped (and the stop function would
|
|
|
|
# actually call the executable @SYSCONFDIR@/local.d/*.stop file(s)).
|
|
|
|
return 0
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
stop()
|
|
|
|
{
|
2014-06-10 18:53:17 +05:30
|
|
|
ebegin "Stopping local"
|
2011-01-06 23:43:33 +05:30
|
|
|
|
2014-07-06 01:00:33 +05:30
|
|
|
local file has_errors=0 retval
|
2014-06-10 18:53:17 +05:30
|
|
|
eindent
|
2011-01-06 23:43:33 +05:30
|
|
|
for file in @SYSCONFDIR@/local.d/*.stop; do
|
2014-06-10 18:53:17 +05:30
|
|
|
if [ -x "${file}" ]; then
|
|
|
|
vebegin "Executing \"${file}\""
|
|
|
|
"${file}" 2>&1 >/dev/null
|
|
|
|
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
|
2014-06-10 18:53:17 +05:30
|
|
|
ewarn "\"@SYSCONFDIR@/conf.d/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"
|
|
|
|
ewarn "in \"@SYSCONFDIR@/local.d\""
|
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
|
|
|
|
|
|
|
# An executable @SYSCONFDIR@/local.d/*.stop file which failed with a
|
|
|
|
# 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
|
|
|
}
|