local: misc cleanups
Remove references to @SYSCONFDIR@ since these can be calculated at runtime. Also style fixes.
This commit is contained in:
parent
53844fd0dc
commit
bb1bc6eeb7
@ -9,7 +9,10 @@
|
|||||||
# This file may not be copied, modified, propagated, or distributed
|
# This file may not be copied, modified, propagated, or distributed
|
||||||
# except according to the terms contained in the LICENSE file.
|
# except according to the terms contained in the LICENSE file.
|
||||||
|
|
||||||
description="Executes user programs in @SYSCONFDIR@/local.d"
|
conf_d_dir="${RC_SERVICE%/*/*}/conf.d"
|
||||||
|
local_d_dir="${RC_SERVICE%/*/*}/local.d"
|
||||||
|
|
||||||
|
description="Executes user programs in ${local_d_dir}"
|
||||||
|
|
||||||
depend()
|
depend()
|
||||||
{
|
{
|
||||||
@ -19,12 +22,12 @@ depend()
|
|||||||
|
|
||||||
start()
|
start()
|
||||||
{
|
{
|
||||||
ebegin "Starting local"
|
local file has_errors redirect retval
|
||||||
|
has_errors=0
|
||||||
local file has_errors=0 redirect retval
|
|
||||||
yesno $rc_verbose || redirect='> /dev/null 2>&1'
|
yesno $rc_verbose || redirect='> /dev/null 2>&1'
|
||||||
|
ebegin "Starting local"
|
||||||
eindent
|
eindent
|
||||||
for file in @SYSCONFDIR@/local.d/*.start; do
|
for file in "${local_d_dir}"/*.start; do
|
||||||
if [ -x "${file}" ]; then
|
if [ -x "${file}" ]; then
|
||||||
vebegin "Executing \"${file}\""
|
vebegin "Executing \"${file}\""
|
||||||
eval "${file}" $redirect
|
eval "${file}" $redirect
|
||||||
@ -38,32 +41,32 @@ start()
|
|||||||
eoutdent
|
eoutdent
|
||||||
|
|
||||||
if command -v local_start >/dev/null 2>&1; then
|
if command -v local_start >/dev/null 2>&1; then
|
||||||
ewarn "\"@SYSCONFDIR@/conf.d/local\" should be removed."
|
ewarn "\"${conf_d_dir}/local\" should be removed."
|
||||||
ewarn "Please move the code from the local_start function"
|
ewarn "Please move the code from the local_start function"
|
||||||
ewarn "to executable scripts with an .start extension"
|
ewarn "to executable scripts with an .start extension"
|
||||||
ewarn "in \"@SYSCONFDIR@/local.d\""
|
ewarn "in \"${local_d_dir}\""
|
||||||
local_start
|
local_start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
eend ${has_errors}
|
eend ${has_errors}
|
||||||
|
|
||||||
# We have to end with a zero exit code, because a failed execution
|
# 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
|
# of an executable ${local_d_dir}/*.start file shouldn't result in
|
||||||
# marking the local service as failed. Otherwise we are unable to
|
# marking the local service as failed. Otherwise we are unable to
|
||||||
# execute any executable @SYSCONFDIR@/local.d/*.stop file, because a failed
|
# execute any executable ${local_d_dir}/*.stop file, because a failed
|
||||||
# marked service cannot be stopped (and the stop function would
|
# marked service cannot be stopped (and the stop function would
|
||||||
# actually call the executable @SYSCONFDIR@/local.d/*.stop file(s)).
|
# actually call the executable ${local_d_dir}/*.stop file(s)).
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
stop()
|
stop()
|
||||||
{
|
{
|
||||||
ebegin "Stopping local"
|
local file has_errors redirect retval
|
||||||
|
has_errors=0
|
||||||
local file has_errors=0 redirect retval
|
|
||||||
yesno $rc_verbose || redirect='> /dev/null 2>&1'
|
yesno $rc_verbose || redirect='> /dev/null 2>&1'
|
||||||
|
ebegin "Stopping local"
|
||||||
eindent
|
eindent
|
||||||
for file in @SYSCONFDIR@/local.d/*.stop; do
|
for file in "${local_d_dir}"/*.stop; do
|
||||||
if [ -x "${file}" ]; then
|
if [ -x "${file}" ]; then
|
||||||
vebegin "Executing \"${file}\""
|
vebegin "Executing \"${file}\""
|
||||||
eval "${file}" $redirect
|
eval "${file}" $redirect
|
||||||
@ -77,16 +80,16 @@ stop()
|
|||||||
eoutdent
|
eoutdent
|
||||||
|
|
||||||
if command -v local_stop >/dev/null 2>&1; then
|
if command -v local_stop >/dev/null 2>&1; then
|
||||||
ewarn "\"@SYSCONFDIR@/conf.d/local\" should be removed."
|
ewarn "\"${conf_d_dir}/local\" should be removed."
|
||||||
ewarn "Please move the code from the local_stop function"
|
ewarn "Please move the code from the local_stop function"
|
||||||
ewarn "to executable scripts with an .stop extension"
|
ewarn "to executable scripts with an .stop extension"
|
||||||
ewarn "in \"@SYSCONFDIR@/local.d\""
|
ewarn "in \"${local_d_dir}\""
|
||||||
local_stop
|
local_stop
|
||||||
fi
|
fi
|
||||||
|
|
||||||
eend ${has_errors}
|
eend ${has_errors}
|
||||||
|
|
||||||
# An executable @SYSCONFDIR@/local.d/*.stop file which failed with a
|
# An executable ${local_d_dir}/*.stop file which failed with a
|
||||||
# non-zero exit status is not a reason to mark this service
|
# non-zero exit status is not a reason to mark this service
|
||||||
# as failed, therefore we have to end with a zero exit code.
|
# as failed, therefore we have to end with a zero exit code.
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
Reference in New Issue
Block a user