9dfb85d5d2
The local service now redirects stdout and stderr for the scripts it runs to /dev/null unless it is run in verbose mode. X-Gentoo-Bug: 537444 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=537444
87 lines
2.2 KiB
Plaintext
87 lines
2.2 KiB
Plaintext
#!@SBINDIR@/openrc-run
|
|
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
|
|
# Released under the 2-clause BSD license.
|
|
|
|
description="Executes user programs in @SYSCONFDIR@/local.d"
|
|
|
|
depend()
|
|
{
|
|
after *
|
|
keyword -timeout
|
|
}
|
|
|
|
start()
|
|
{
|
|
ebegin "Starting local"
|
|
|
|
local file has_errors=0 redirect retval
|
|
yesno $rc_verbose || redirect='> /dev/null 2>&1'
|
|
eindent
|
|
for file in @SYSCONFDIR@/local.d/*.start; do
|
|
if [ -x "${file}" ]; then
|
|
vebegin "Executing \"${file}\""
|
|
"${file}" $redirect
|
|
retval=$?
|
|
if [ ${retval} -ne 0 ]; then
|
|
has_errors=1
|
|
fi
|
|
veend ${retval} "Execution of \"${file}\" failed."
|
|
fi
|
|
done
|
|
eoutdent
|
|
|
|
if command -v local_start >/dev/null 2>&1; then
|
|
ewarn "\"@SYSCONFDIR@/conf.d/local\" should be removed."
|
|
ewarn "Please move the code from the local_start function"
|
|
ewarn "to executable scripts with an .start extension"
|
|
ewarn "in \"@SYSCONFDIR@/local.d\""
|
|
local_start
|
|
fi
|
|
|
|
eend ${has_errors}
|
|
|
|
# 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
|
|
}
|
|
|
|
stop()
|
|
{
|
|
ebegin "Stopping local"
|
|
|
|
local file has_errors=0 redirect retval
|
|
yesno $rc_verbose || redirect='> /dev/null 2>&1'
|
|
eindent
|
|
for file in @SYSCONFDIR@/local.d/*.stop; do
|
|
if [ -x "${file}" ]; then
|
|
vebegin "Executing \"${file}\""
|
|
"${file}" $redirect
|
|
retval=$?
|
|
if [ ${retval} -ne 0 ]; then
|
|
has_errors=1
|
|
fi
|
|
veend ${retval} "Execution of \"${file}\" failed."
|
|
fi
|
|
done
|
|
eoutdent
|
|
|
|
if command -v local_stop >/dev/null 2>&1; then
|
|
ewarn "\"@SYSCONFDIR@/conf.d/local\" should be removed."
|
|
ewarn "Please move the code from the local_stop function"
|
|
ewarn "to executable scripts with an .stop extension"
|
|
ewarn "in \"@SYSCONFDIR@/local.d\""
|
|
local_stop
|
|
fi
|
|
|
|
eend ${has_errors}
|
|
|
|
# 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
|
|
}
|