summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorajacoutot <ajacoutot@openbsd.org>2016-06-19 10:54:20 +0000
committerajacoutot <ajacoutot@openbsd.org>2016-06-19 10:54:20 +0000
commit4727ebb7e6af02d52957a1de00b9fd0af4eb47f1 (patch)
tree7fbfbb55939960c453af35430930f3100f8c6e0f
parentCache result of often used functions (svc_is_{base,meta,special}). (diff)
downloadwireguard-openbsd-4727ebb7e6af02d52957a1de00b9fd0af4eb47f1.tar.xz
wireguard-openbsd-4727ebb7e6af02d52957a1de00b9fd0af4eb47f1.zip
Implement rcctl get|getdef all.
With this and the previous 2 commits, we can move from constructs like: $ for i in $(rcctl ls all); do rcctl get $i; done to just: $ rcctl get all Shrinking the run by a factor of more than 3.5. prodded by and discussed with reyk@ at BSDcan2016 ok robert@
-rw-r--r--usr.sbin/rcctl/rcctl.812
-rw-r--r--usr.sbin/rcctl/rcctl.sh19
2 files changed, 22 insertions, 9 deletions
diff --git a/usr.sbin/rcctl/rcctl.8 b/usr.sbin/rcctl/rcctl.8
index 727191f4fab..ba91693a3df 100644
--- a/usr.sbin/rcctl/rcctl.8
+++ b/usr.sbin/rcctl/rcctl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: rcctl.8,v 1.32 2016/04/26 17:58:42 ajacoutot Exp $
+.\" $OpenBSD: rcctl.8,v 1.33 2016/06/19 10:54:20 ajacoutot Exp $
.\"
.\" Copyright (c) 2014 Antoine Jacoutot <ajacoutot@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: April 26 2016 $
+.Dd $Mdocdate: June 19 2016 $
.Dt RCCTL 8
.Os
.Sh NAME
@@ -91,6 +91,14 @@ or
variables and values in a format
compatible with
.Xr rc.conf 8 .
+When
+.Ar daemon
+is set to
+.Qq all ,
+.Ar variable
+must not be set and
+.Nm
+will display all services and daemons variables.
.It Cm getdef Ar service | daemon Op Ar variable
Like
.Cm get
diff --git a/usr.sbin/rcctl/rcctl.sh b/usr.sbin/rcctl/rcctl.sh
index 4011ab45307..ad347ed7d76 100644
--- a/usr.sbin/rcctl/rcctl.sh
+++ b/usr.sbin/rcctl/rcctl.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $OpenBSD: rcctl.sh,v 1.98 2016/06/19 10:50:27 ajacoutot Exp $
+# $OpenBSD: rcctl.sh,v 1.99 2016/06/19 10:54:20 ajacoutot Exp $
#
# Copyright (c) 2014, 2015 Antoine Jacoutot <ajacoutot@openbsd.org>
# Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -503,9 +503,10 @@ case ${action} in
svc=$2
var=$3
[ -z "${svc}" ] && usage
- svc_is_avail ${svc} || \
+ [ "${svc}" = "all" ] || svc_is_avail ${svc} || \
rcctl_err "service ${svc} does not exist" 2
if [ -n "${var}" ]; then
+ [ "${svc}" = "all" ] && usage
[[ ${var} != @(class|flags|status|rtable|timeout|user) ]] && usage
if svc_is_meta ${svc}; then
[ "${var}" != "status" ] && \
@@ -560,11 +561,15 @@ case ${action} in
done
exit ${ret}
;;
- get)
- svc_get ${svc} "${var}"
- ;;
- getdef)
- ( svc_getdef ${svc} "${var}" )
+ get|getdef)
+ if [ "${svc}" = "all" ]; then
+ for svc in $(svc_ls all); do
+ ( svc_${action} ${svc} "${var}" )
+ done
+ return 0 # we do not want the svc status
+ else
+ ( svc_${action} ${svc} "${var}" )
+ fi
;;
ls)
# some rc.d(8) scripts need root for rc_check()