diff options
author | 2011-03-14 11:28:44 +0000 | |
---|---|---|
committer | 2011-03-14 11:28:44 +0000 | |
commit | 0080ba7753b94a374faea5b54d88727cc128a6ec (patch) | |
tree | 80feda655d5d96a7a08ec6c4106979b7423197b7 | |
parent | - sync help() after recent additions (diff) | |
download | wireguard-openbsd-0080ba7753b94a374faea5b54d88727cc128a6ec.tar.xz wireguard-openbsd-0080ba7753b94a374faea5b54d88727cc128a6ec.zip |
Return proper codes so that we don't rc_start if rc_pre failed and we
don't rc_post if rc_stop failed.
"I agree with the direction" sthen@
ok robert@
-rw-r--r-- | etc/rc.d/rc.subr | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/etc/rc.d/rc.subr b/etc/rc.d/rc.subr index 02058ba34fc..03a0e977ced 100644 --- a/etc/rc.d/rc.subr +++ b/etc/rc.d/rc.subr @@ -1,4 +1,4 @@ -# $OpenBSD: rc.subr,v 1.25 2011/03/10 10:21:39 ajacoutot Exp $ +# $OpenBSD: rc.subr,v 1.26 2011/03/14 11:28:44 ajacoutot Exp $ # Default functions and variables used by rc.d(8) scripts. @@ -37,20 +37,30 @@ rc_cmd() { rc_check >/dev/null ;; start) - if ! rc_check; then - type rc_pre >/dev/null && rc_pre - rc_start >/dev/null - fi + rc_check || \ + ( + if type rc_pre >/dev/null; then + rc_pre + fi + [ $? -eq 0 ] && rc_start >/dev/null + ) ;; stop) - rc_stop >/dev/null - i=0 - while [ $i -lt 5 ]; do - rc_check || break - sleep 1 - i=$((i+1)) - done - type rc_post >/dev/null && rc_post || return 0 + if rc_check; then rc_stop >/dev/null && \ + ( + i=0 + while [ $i -lt 5 ]; do + rc_check || break + sleep 1 + i=$((i+1)) + done + if [ $i -lt 5 ]; then + if type rc_post >/dev/null; then \ + rc_post + fi + fi + ) + fi ;; reload) rc_check && rc_reload >/dev/null |