diff options
author | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2014-10-15 07:38:25 +0000 |
---|---|---|
committer | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2014-10-15 07:38:25 +0000 |
commit | 4daac913cc6b2cf410c1de81aa09fcc4be25cf95 (patch) | |
tree | 17fc03a0e85451a4e390f312f9459296d60ed6da /usr.sbin | |
parent | 37c03430de7150b37b88580a8a15b9123f31be20 (diff) |
Add a new ls_rcscripts() function to properly get all rc.d(8) scripts
ignoring irrelevant stuffs under /etc/rc.d.
reworked based on a submission from Craig R. Skinner
ok schwarze@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/rcctl/rcctl.sh | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.sbin/rcctl/rcctl.sh b/usr.sbin/rcctl/rcctl.sh index 2cf0a3f9919..30a0f0d4ad2 100644 --- a/usr.sbin/rcctl/rcctl.sh +++ b/usr.sbin/rcctl/rcctl.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $OpenBSD: rcctl.sh,v 1.44 2014/10/13 19:06:53 schwarze Exp $ +# $OpenBSD: rcctl.sh,v 1.45 2014/10/15 07:38:24 ajacoutot Exp $ # # Copyright (c) 2014 Antoine Jacoutot <ajacoutot@openbsd.org> # Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -36,6 +36,16 @@ needs_root() [ "$(id -u)" -ne 0 ] && _rc_err "${0##*/} $1: need root privileges" } +ls_rcscripts() { + local _s + + cd /etc/rc.d && set -- * + for _s; do + [ "${_s}" = "rc.subr" ] && continue + [ ! -d "${_s}" ] && echo "${_s}" + done +} + rcconf_edit_begin() { _TMP_RCCONF=$(mktemp -p /etc -t rc.conf.local.XXXXXXXXXX) || exit 1 @@ -93,7 +103,7 @@ svc_get_defaults() print -r -- "$(svc_default_enabled_flags ${_svc})" svc_default_enabled ${_svc} else - for _i in $(ls -A /etc/rc.d | grep -v rc.subr); do + for _i in $(ls_rcscripts); do echo "${_i}_flags=$(svc_default_enabled_flags ${_i})" done for _i in ${_special_services}; do @@ -134,7 +144,7 @@ svc_get_status() svc_get_flags ${_svc} svc_is_enabled ${_svc} else - for _i in $(ls -A /etc/rc.d | grep -v rc.subr); do + for _i in $(ls_rcscripts); do echo "${_i}_flags=$(svc_get_flags ${_i})" done for _i in ${_special_services}; do |