summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin Teske <dteske@FreeBSD.org>2018-10-31 20:37:12 +0000
committerDevin Teske <dteske@FreeBSD.org>2018-10-31 20:37:12 +0000
commitda45b4da83c6a68c3bc3a1682ec77d44141164d2 (patch)
tree2b8b0a3b274b0b8d630092cad2311fad17fd7c15
parent9319dded3d53a39ab6ba093c87bcbc42115ae968 (diff)
downloadsrc-test2-da45b4da83c6a68c3bc3a1682ec77d44141164d2.tar.gz
src-test2-da45b4da83c6a68c3bc3a1682ec77d44141164d2.zip
Notes
-rw-r--r--libexec/rc/rc.conf1
-rw-r--r--libexec/rc/rc.subr32
-rw-r--r--share/man/man5/rc.conf.511
-rw-r--r--share/man/man8/rc.817
4 files changed, 56 insertions, 5 deletions
diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf
index 7ecacfdee64b..f77694b9a3a5 100644
--- a/libexec/rc/rc.conf
+++ b/libexec/rc/rc.conf
@@ -617,6 +617,7 @@ savecore_enable="YES" # Extract core from dump devices if any
savecore_flags="-m 10" # Used if dumpdev is enabled above, and present.
# By default, only the 10 most recent kernel dumps
# are saved.
+service_delete_empty="NO" # Have 'service delete' remove empty rc.conf.d files.
crashinfo_enable="YES" # Automatically generate crash dump summary.
crashinfo_program="/usr/sbin/crashinfo" # Script to generate crash dump summary.
quota_enable="NO" # turn on quotas on startup (or NO).
diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr
index 56eccdb15b0d..072eda2cebf6 100644
--- a/libexec/rc/rc.subr
+++ b/libexec/rc/rc.subr
@@ -922,7 +922,7 @@ run_rc_command()
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 delete enabled describe extracommands $extra_commands"
rc_pid=
_pidcmd=
_procname=${procname:-${command}}
@@ -977,12 +977,13 @@ run_rc_command()
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 "delete", and ${rc_pid} is not set, run:
# checkyesno ${rcvar}
# and return if that failed
#
if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" -a "$rc_arg" != "stop" \
+ -a "$rc_arg" != "delete" -a "$rc_arg" != "enable" \
-a "$rc_arg" != "describe" ] ||
[ -n "${rcvar}" -a "$rc_arg" = "stop" -a -z "${rc_pid}" ]; then
if ! checkyesno ${rcvar}; then
@@ -1030,6 +1031,31 @@ run_rc_command()
echo "$extra_commands"
;;
+ enable)
+ _out=$(/usr/sbin/sysrc -vs "$name" "$rcvar=YES") &&
+ echo "$name enabled in ${_out%%:*}"
+ ;;
+
+ disable)
+ _out=$(/usr/sbin/sysrc -vs "$name" "$rcvar=NO") &&
+ echo "$name disabled in ${_out%%:*}"
+ ;;
+
+ delete)
+ _files=
+ for _file in $(sysrc -lEs "$name"); do
+ _out=$(sysrc -Fif $_file "$rcvar") && _files="$_files $_file"
+ done
+ /usr/sbin/sysrc -x "$rcvar" && echo "$rcvar deleted in ${_files# }"
+ # delete file in rc.conf.d if desired and empty.
+ checkyesno service_delete_empty || _files=
+ for _file in $_files; do
+ [ "$_file" = "${_file#*/rc.conf.d/}" ] && continue
+ [ $(/usr/bin/stat -f%z $_file) -gt 0 ] && continue
+ /bin/rm "$_file" && echo "Empty file $_file removed"
+ done
+ ;;
+
status)
_run_rc_precmd || return 1
if [ -n "$rc_pid" ]; then
diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5
index 02d53a962f86..67f4553ed34f 100644
--- a/share/man/man5/rc.conf.5
+++ b/share/man/man5/rc.conf.5
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 22, 2018
+.Dd October 24, 2018
.Dt RC.CONF 5
.Os
.Sh NAME
@@ -4509,6 +4509,14 @@ at boot time.
The directory where the files exported by USB LUN are located.
The default directory is
.Pa /var/cfumass .
+.It Va service_delete_empty
+.Pq Vt bool
+If set to
+.Dq Li YES ,
+.Ql Li service delete
+removes empty
+.Dq Li rc.conf.d
+files.
.El
.Sh FILES
.Bl -tag -width ".Pa /etc/defaults/rc.conf" -compact
@@ -4597,6 +4605,7 @@ The default directory is
.Xr rwhod 8 ,
.Xr savecore 8 ,
.Xr sdpd 8 ,
+.Xr service 8 ,
.Xr sshd 8 ,
.Xr swapon 8 ,
.Xr sysctl 8 ,
diff --git a/share/man/man8/rc.8 b/share/man/man8/rc.8
index 96d71c9d35b1..eb05171a9026 100644
--- a/share/man/man8/rc.8
+++ b/share/man/man8/rc.8
@@ -31,7 +31,7 @@
.\" @(#)rc.8 8.2 (Berkeley) 12/11/93
.\" $FreeBSD$
.\"
-.Dd April 25, 2017
+.Dd September 18, 2018
.Dt RC 8
.Os
.Sh NAME
@@ -327,6 +327,21 @@ 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
+Enable the service in
+.Xr rc.conf 5 .
+.It Cm disable
+Disable the service in
+.Xr rc.conf 5 .
+.It Cm delete
+Remove the service from
+.Xr rc.conf 5 .
+If
+.Ql Li service_delete_empty
+is set to
+.Dq Li YES ,
+.Pa /etc/rc.conf.d/$servicename
+will be deleted if empty after modification.
.It Cm describe
Print a short description of what the script does.
.It Cm extracommands