diff options
author | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2022-09-01 07:25:33 +0000 |
---|---|---|
committer | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2022-09-01 07:25:33 +0000 |
commit | b591cc0908092f01b6a7ab4d6759fbf36f2f666a (patch) | |
tree | 1fa2d76b89157d3a800e41c4eda4f7dedbd42e7b /etc/rc.d | |
parent | f5af19729f3fad7548e8201734957a9825600ad7 (diff) |
Add a new action: "configtest", to check configuration syntax of the daemon.
A few adjustments will be done in the next days (like disabling this action if
there's no specific rc_configtest function defined).
e.g.
/etc/rc.d/sshd configtest
rcctl configtest sshd
idea from naddy@
Diffstat (limited to 'etc/rc.d')
-rw-r--r-- | etc/rc.d/rc.subr | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/etc/rc.d/rc.subr b/etc/rc.d/rc.subr index 542670c2c38..5be38a4b55d 100644 --- a/etc/rc.d/rc.subr +++ b/etc/rc.d/rc.subr @@ -1,4 +1,4 @@ -# $OpenBSD: rc.subr,v 1.156 2022/08/29 19:37:32 ajacoutot Exp $ +# $OpenBSD: rc.subr,v 1.157 2022/09/01 07:25:32 ajacoutot Exp $ # # Copyright (c) 2010, 2011, 2014-2022 Antoine Jacoutot <ajacoutot@openbsd.org> # Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -16,7 +16,7 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -_rc_actions="start stop restart reload check" +_rc_actions="start stop restart reload check configtest" readonly _rc_actions _rc_check_name() { @@ -219,6 +219,10 @@ rc_cmd() { echo $_n "${INRC:+ }${_name}" _rc_do rc_check && _rc_exit ok || _rc_exit failed ;; + configtest) + echo $_n "${INRC:+ }${_name}" + _rc_do rc_configtest && _rc_exit ok || _rc_exit failed + ;; start) if [ X"${daemon_flags}" = X"NO" ]; then _rc_err "$0: need -f to force $1 since ${_name}_flags=NO" @@ -226,9 +230,9 @@ rc_cmd() { [ -z "${INRC}" ] && _rc_do rc_check && exit 0 echo $_n "${INRC:+ }${_name}" while true; do # no real loop, only needed to break - # mostly useful for daemons whose child will not return - # a config parsing error to the parent during startup - # e.g. bgpd, httpd... + # running during start is mostly useful for daemons + # whose child will not return a config parsing error to + # the parent during startup; e.g. bgpd, httpd... _rc_do rc_configtest || break if type rc_pre >/dev/null; then _rc_do rc_pre || break |