mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
rc.subr(8): introduce ${name}_offcmd
New variable ${name}_offcmd may be used to supply commands
executed if named service is not enabled. Previously start_precmd
could be used for such a task but now rc.subr(8) does not call it
if a service is not enabled.
Fix devd startup script to use it instead of start_precmd.
PR: 279198
MFC after: 2 weeks
Reported by: Dmitry S. Lukhtionov
Tested by: Dmitry S. Lukhtionov
This commit is contained in:
parent
39c4f65c72
commit
32a579e4fc
3 changed files with 27 additions and 9 deletions
|
|
@ -14,7 +14,8 @@ desc="Device state change daemon"
|
|||
rcvar="devd_enable"
|
||||
command="/sbin/${name}"
|
||||
|
||||
start_precmd=${name}_prestart
|
||||
devd_offcmd=devd_off
|
||||
start_precmd=find_pidfile
|
||||
stop_precmd=find_pidfile
|
||||
|
||||
find_pidfile()
|
||||
|
|
@ -26,10 +27,8 @@ find_pidfile()
|
|||
fi
|
||||
}
|
||||
|
||||
devd_prestart()
|
||||
devd_off()
|
||||
{
|
||||
find_pidfile
|
||||
|
||||
# If devd is disabled, turn it off in the kernel to avoid unnecessary
|
||||
# memory usage.
|
||||
if ! checkyesno ${rcvar}; then
|
||||
|
|
|
|||
|
|
@ -982,6 +982,8 @@ startmsg()
|
|||
#
|
||||
# ${name}_limits n limits(1) to apply to ${command}.
|
||||
#
|
||||
# ${name}_offcmd n If set, run if a service is not enabled.
|
||||
#
|
||||
# ${rc_arg}_cmd n If set, use this as the method when invoked;
|
||||
# Otherwise, use default command (see below)
|
||||
#
|
||||
|
|
@ -1270,13 +1272,13 @@ run_rc_command()
|
|||
-a "$rc_arg" != "describe" -a "$rc_arg" != "status" ] ||
|
||||
[ -n "${rcvar}" -a "$rc_arg" = "stop" -a -z "${rc_pid}" ]; then
|
||||
if ! checkyesno ${rcvar}; then
|
||||
if [ -n "${rc_quiet}" ]; then
|
||||
return 0
|
||||
fi
|
||||
[ "$rc_arg" = "start" ] && _run_rc_offcmd
|
||||
if [ -z "${rc_quiet}" ]; then
|
||||
echo -n "Cannot '${rc_arg}' $name. Set ${rcvar} to "
|
||||
echo -n "YES in /etc/rc.conf or use 'one${rc_arg}' "
|
||||
echo "instead of '${rc_arg}'."
|
||||
return 0
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -1643,11 +1645,26 @@ $_cpusetcmd $command $rc_flags $command_args"
|
|||
#
|
||||
# name R/W
|
||||
# ------------------
|
||||
# _offcmd R
|
||||
# _precmd R
|
||||
# _postcmd R
|
||||
# _return W
|
||||
# _setup R
|
||||
#
|
||||
_run_rc_offcmd()
|
||||
{
|
||||
eval _offcmd=\$${name}_offcmd
|
||||
if [ -n "$_offcmd" ]; then
|
||||
if [ -n "$_env" ]; then
|
||||
eval "export -- $_env"
|
||||
fi
|
||||
debug "run_rc_command: ${rc_arg}_offcmd: $_offcmd $rc_extra_args"
|
||||
eval "$_offcmd $rc_extra_args"
|
||||
_return=$?
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
_run_rc_precmd()
|
||||
{
|
||||
check_required_before "$rc_arg" || return 1
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd May 28, 2024
|
||||
.Dd June 2, 2024
|
||||
.Dt RC.SUBR 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
|
@ -773,6 +773,8 @@ Login class to use with
|
|||
.Va ${name}_limits .
|
||||
Defaults to
|
||||
.Dq Li daemon .
|
||||
.It Va ${name}_offcmd
|
||||
Shell commands to run if a service is not enabled.
|
||||
.It Va ${name}_oomprotect
|
||||
.Xr protect 1
|
||||
.Va command
|
||||
|
|
|
|||
Loading…
Reference in a new issue