Page MenuHomeFreeBSD

D17113.id47896.diff
No OneTemporary

D17113.id47896.diff

Index: sbin/init/rc.conf
===================================================================
--- sbin/init/rc.conf
+++ sbin/init/rc.conf
@@ -706,6 +706,9 @@
jail_list="" # Space separated list of names of jails
jail_reverse_stop="NO" # Stop jails in reverse order
+service_use_rcconfd="NO" # Let service and rc scripts use separate files in
+ # /etc/rc.conf.d
+
##############################################################
### Define source_rc_confs, the mechanism used by /etc/rc.* ##
### scripts to source rc_conf_files overrides safely. ##
Index: sbin/init/rc.subr
===================================================================
--- sbin/init/rc.subr
+++ sbin/init/rc.subr
@@ -922,7 +922,7 @@
eval _override_command=\$${name}_program
command=${_override_command:-$command}
- _keywords="start stop restart rcvar enabled describe extracommands $extra_commands"
+ _keywords="start stop restart rcvar enable disable rcdelete enabled describe extracommands $extra_commands"
rc_pid=
_pidcmd=
_procname=${procname:-${command}}
@@ -977,13 +977,15 @@
if [ "$_elem" != "$rc_arg" ]; then
continue
fi
- # if ${rcvar} is set, $1 is not "rcvar" and not "describe"
- # and ${rc_pid} is not set, then run
+ # if ${rcvar} is set, $1 is not "rcvar", "describe",
+ # "enable" or "rcdelete" # and ${rc_pid} is not set,
+ # then run
# checkyesno ${rcvar}
# and return if that failed
#
if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" -a "$rc_arg" != "stop" \
- -a "$rc_arg" != "describe" ] ||
+ -a "$rc_arg" != "describe" -a "$rc_arg" != "enable" \
+ -a "$rc_arg" != "rcdelete" ] ||
[ -n "${rcvar}" -a "$rc_arg" = "stop" -a -z "${rc_pid}" ]; then
if ! checkyesno ${rcvar}; then
if [ -n "${rc_quiet}" ]; then
@@ -1004,6 +1006,13 @@
return 1
fi
+ if checkyesno service_use_rcconfd; then
+ sysrc_file="/etc/rc.conf.d/${name}"
+ sysrc_flags="-f ${sysrc_file}"
+ else
+ sysrc_file="/etc/rc.conf"
+ fi
+
# if there's a custom ${XXX_cmd},
# run that instead of the default
#
@@ -1028,6 +1037,50 @@
extracommands)
echo "$extra_commands"
+ ;;
+
+ enable)
+ /usr/sbin/sysrc "$rcvar=YES" > /dev/null
+ [ $? -eq 0 ] &&
+ echo "$name enabled in /etc/rc.conf"
+ ;;
+
+ disable)
+ /usr/sbin/sysrc "$rcvar=NO" > /dev/null
+ [ $? -eq 0 ] &&
+ echo "$name disabled in /etc/rc.conf"
+ ;;
+
+ rcdelete)
+ /usr/sbin/sysrc -x "$rcvar" > /dev/null
+ # XXX: sysrc(8) does still returns 0 when nothing is
+ # deleted. This conditional will work as designed when
+ # sysrc(8) is fixed.
+ [ $? -eq 0 ] &&
+ echo "$rcvar deleted in /etc/rc.conf"
+ ;;
+
+ enable)
+ /usr/sbin/sysrc ${sysrc_flags} "$rcvar=YES" > /dev/null
+ [ $? -eq 0 ] &&
+ echo "$name enabled in ${sysrc_file}"
+ ;;
+
+ disable)
+ /usr/sbin/sysrc ${sysrc_flags} "$rcvar=NO" > /dev/null
+ [ $? -eq 0 ] &&
+ echo "$name disabled in ${sysrc_file}"
+ ;;
+
+ rcdelete)
+ /usr/sbin/sysrc -x ${sysrc_flags} "$rcvar" > /dev/null
+ [ $? -eq 0 ] &&
+ echo "$rcvar deleted in ${sysrc_file}"
+ # Delete the file in /etc/rc.conf.d/ if it is empty.
+ if [ "${sysrc_file}" -a $(/usr/bin/stat -f %z "${sysrc_file}") -eq 0 ]; then
+ /bin/rm "${sysrc_file}"
+ echo "Empty file ${sysrc_file} removed"
+ fi
;;
status)
Index: share/man/man8/rc.8
===================================================================
--- share/man/man8/rc.8
+++ share/man/man8/rc.8
@@ -321,11 +321,30 @@
.Cm stop
then a
.Cm start .
-.It Cm status
-If the script starts a process (rather than performing a one-off
-operation), show the status of the process.
-Otherwise it is not necessary to support this argument.
-Defaults to displaying the process ID of the program (if running).
+.It Cm enable
+Add the service's
+.Xr rc.conf 5
+variable to enable the service.
+If
+.Li service_use_rcconfd
+is set to
+.Li "YES"
+the variable is added to
+.Pa /etc/rc.conf.d/$servicename
+else it is added to
+.Pa /etc/rc.conf
+.It Cm disable
+Disable the service's
+.Xr rc.conf 5
+variable.
+.It Cm rcdelete
+Remove the service's
+.Xr rc.conf 5
+variable from
+.Pa /etc/rc.conf
+or
+.Pa /etc/rc.conf.d/$servicename
+and delete the latter if it is empty afterwards.
.It Cm describe
Print a short description of what the script does.
.It Cm extracommands

File Metadata

Mime Type
text/plain
Expires
Sat, May 16, 12:42 PM (46 m, 53 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33129850
Default Alt Text
D17113.id47896.diff (4 KB)

Event Timeline