summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorEugene Grosbein <eugen@FreeBSD.org>2024-06-02 19:13:42 +0000
committerEugene Grosbein <eugen@FreeBSD.org>2024-06-17 04:57:53 +0000
commitefb1717d21c2cc488955914cb4fe9f3683b9cbe5 (patch)
tree4031faf533c241ea3cfd2fa2b91de656f92c0360 /libexec
parentf14b540dc4c17f6b60e23274153985fb7a2f0cb7 (diff)
Diffstat (limited to 'libexec')
-rwxr-xr-xlibexec/rc/rc.d/devd7
-rw-r--r--libexec/rc/rc.subr25
2 files changed, 24 insertions, 8 deletions
diff --git a/libexec/rc/rc.d/devd b/libexec/rc/rc.d/devd
index 43fb9d5928dd..fe19abd817b4 100755
--- a/libexec/rc/rc.d/devd
+++ b/libexec/rc/rc.d/devd
@@ -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
diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr
index 332718dc6f2c..a662b878860b 100644
--- a/libexec/rc/rc.subr
+++ b/libexec/rc/rc.subr
@@ -816,6 +816,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)
#
@@ -1051,13 +1053,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
@@ -1347,10 +1349,25 @@ $_cpusetcmd $command $rc_flags $command_args"
#
# name R/W
# ------------------
+# _offcmd R
# _precmd R
# _postcmd R
# _return W
#
+_run_rc_offcmd()
+{
+ eval _offcmd=\$${name}_offcmd
+ if [ -n "$_offcmd" ]; then
+ if [ -n "$_env" ]; then
+ eval "export -- $_env"
+ fi
+ debug "run_rc_command: ${name}_offcmd: $_offcmd $rc_extra_args"
+ eval "$_offcmd $rc_extra_args"
+ _return=$?
+ fi
+ return 0
+}
+
_run_rc_precmd()
{
check_required_before "$rc_arg" || return 1