summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sysrc
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2014-09-26 22:54:10 +0000
committerdteske <dteske@FreeBSD.org>2014-09-26 22:54:10 +0000
commitb381042f0d278d89c806f97c50b8c888d0922d94 (patch)
treef17f4f092937a280dec0d8441d111543d0a6483b /usr.sbin/sysrc
parentc60179fc3c7373df6621acbd14a4a663a7d913c6 (diff)
downloadFreeBSD-src-b381042f0d278d89c806f97c50b8c888d0922d94.zip
FreeBSD-src-b381042f0d278d89c806f97c50b8c888d0922d94.tar.gz
MFC revisions 268860, 268863:
r268860: Minor enhancements, bug fixes, and man-page adjustments. r268863: Bump .Dd in manual Reported by: lme Approved by: re (gjb)
Diffstat (limited to 'usr.sbin/sysrc')
-rw-r--r--usr.sbin/sysrc/sysrc43
-rw-r--r--usr.sbin/sysrc/sysrc.829
2 files changed, 42 insertions, 30 deletions
diff --git a/usr.sbin/sysrc/sysrc b/usr.sbin/sysrc/sysrc
index bc603b1..f37a496 100644
--- a/usr.sbin/sysrc/sysrc
+++ b/usr.sbin/sysrc/sysrc
@@ -1,6 +1,6 @@
#!/bin/sh
#-
-# Copyright (c) 2010-2013 Devin Teske
+# Copyright (c) 2010-2014 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -40,7 +40,7 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
#
# Version information
#
-SYSRC_VERSION="6.0 Nov-07,2013"
+SYSRC_VERSION="6.1 Jul-18,2014"
#
# Options
@@ -102,7 +102,7 @@ help()
f_err "$optfmt" "-A" \
"Dump a list of all configuration variables (incl. defaults)."
f_err "$optfmt" "-c" \
- "Check. Return success if no changes needed, else error."
+ "Check. Return success if set or no changes, else error."
f_err "$optfmt" "-d" \
"Print a description of the given variable."
f_err "$optfmt" "-D" \
@@ -134,7 +134,7 @@ help()
f_err "$optfmt" "-N" \
"Show only variable names, not their values."
f_err "$optfmt" "-q" \
- "Quiet. Ignore previous \`-v' and/or SYSRC_VERBOSE."
+ "Quiet. Disable verbose and hide certain errors."
f_err "$optfmt" "-R dir" \
"Operate within the root directory \`dir' rather than \`/'."
f_err "$optfmt" "-v" \
@@ -152,8 +152,6 @@ help()
"Override default rc_conf_files (even if set to NULL)."
f_err "$envfmt" "RC_DEFAULTS" \
"Location of \`/etc/defaults/rc.conf' file."
- f_err "$envfmt" "SYSRC_VERBOSE" \
- "Default verbosity. Set to non-NULL to enable."
die
}
@@ -527,7 +525,7 @@ fi
#
# Process command-line arguments
#
-costatus=$SUCCESS
+status=$SUCCESS
while [ $# -gt 0 ]; do
NAME="${1%%=*}"
@@ -558,7 +556,7 @@ while [ $# -gt 0 ]; do
# desire to set some value
#
if [ "$DELETE" ]; then
- f_sysrc_delete "$NAME"
+ f_sysrc_delete "$NAME" || status=$FAILURE
shift 1
continue
fi
@@ -568,10 +566,23 @@ while [ $# -gt 0 ]; do
#
if [ "$CHECK_ONLY" ]; then
if ! IGNORED=$( f_sysrc_get "$NAME?" ); then
- costatus=$FAILURE
- else
- value=$( f_sysrc_get "$NAME" )
- [ "$value" = "${1#*=}" ] || costatus=$FAILURE
+ status=$FAILURE
+ [ "$SYSRC_VERBOSE" ] &&
+ echo "$NAME: not currently set"
+ shift 1
+ continue
+ fi
+ value=$( f_sysrc_get "$NAME" )
+ if [ "$value" != "${1#*=}" ]; then
+ status=$FAILURE
+ if [ "$SYSRC_VERBOSE" ]; then
+ echo -n "$( f_sysrc_find "$NAME" ): "
+ echo -n "$NAME: would change from "
+ echo "\`$value' to \`${1#*=}'"
+ fi
+ elif [ "$SYSRC_VERBOSE" ]; then
+ echo -n "$( f_sysrc_find "$NAME" ): "
+ echo "$NAME: already set to \`$value'"
fi
shift 1
continue
@@ -604,10 +615,10 @@ while [ $# -gt 0 ]; do
;;
*)
if ! IGNORED=$( f_sysrc_get "$NAME?" ); then
- [ "$IGNORE_UNKNOWNS" ] ||
+ [ "$IGNORE_UNKNOWNS" -o "$QUIET" ] ||
echo "$pgm: unknown variable '$NAME'"
shift 1
- costatus=$FAILURE
+ status=$FAILURE
continue
fi
@@ -631,7 +642,7 @@ while [ $# -gt 0 ]; do
# If `-x' or `-X' is passed, delete the variable
#
if [ "$DELETE" ]; then
- f_sysrc_delete "$NAME"
+ f_sysrc_delete "$NAME" || status=$FAILURE
shift 1
continue
fi
@@ -667,7 +678,7 @@ while [ $# -gt 0 ]; do
shift 1
done
-[ ! "$CHECK_ONLY" ] || exit $costatus
+exit $status # $SUCCESS unless error occurred with either `-c' or `-x'
################################################################################
# END
diff --git a/usr.sbin/sysrc/sysrc.8 b/usr.sbin/sysrc/sysrc.8
index e3b873f..ebe5651 100644
--- a/usr.sbin/sysrc/sysrc.8
+++ b/usr.sbin/sysrc/sysrc.8
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2011-2013 Devin Teske
+.\" Copyright (c) 2011-2014 Devin Teske
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd Nov 20, 2013
+.Dd Jul 18, 2014
.Dt SYSRC 8
.Os
.Sh NAME
@@ -58,11 +58,14 @@ Dump a list of all non-default configuration variables.
Dump a list of all configuration variables
.Pq incl. defaults .
.It Fl c
-Check if the value will change when assigning a new value.
+Check only.
+For querying, return success if all requested variables are set
+.Pq even if NULL ,
+otherwise return error status.
+For assignments, return success if no changes are required, otherwise failure.
If verbose
.Pq see Dq Fl v
-prints a message stating whether a change would occur.
-Exits with success if no change is necessary, else returns error status.
+prints a message stating whether variables are set and/or changes are required.
.It Fl d
Print a description of the given variable.
.It Fl D
@@ -108,14 +111,12 @@ Show only variable values, not their names.
Show only variable names, not their values.
.It Fl q
Quiet.
-Ignore previous occurrences of
-.Fl v
-flag.
+Disable verbose and hide certain errors.
.It Fl R Ar dir
Operate within the root directory
-.Pq Sq Ar dir
+.Sq Ar dir
rather than
-.Pq Sq / .
+.Sq / .
.It Fl v
Verbose.
Print the pathname of the specific
@@ -127,13 +128,13 @@ Print version information to stdout and exit.
Remove variable(s) from specified file(s).
.El
.Pp
-This utility works similar to
+This utility has a similar syntax to
.Xr sysctl 8 .
It shares the `-e' and `-n' options
.Pq detailed above
and also has the same
.Ql name[=value]
-syntax for querying/setting configuration options.
+syntax for making queries/assignments.
.Pp
However, while
.Xr sysctl 8
@@ -304,5 +305,5 @@ utility first appeared in
.An Devin Teske Aq dteske@FreeBSD.org
.Sh THANKS TO
Brandon Gooch, Garrett Cooper, Julian Elischer, Pawel Jakub Dawidek,
-Cyrille Lefevre, Ross West, Stefan Esser, Marco Steinbach, and Jilles Tjoelker
-for suggestions and help.
+Cyrille Lefevre, Ross West, Stefan Esser, Marco Steinbach, Jilles Tjoelker,
+Allan Jude, and Lars Engels for suggestions, help, and testing.
OpenPOWER on IntegriCloud