summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2011-03-14 11:28:45 +0000
committerAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2011-03-14 11:28:45 +0000
commit1a0e157059573980ca06707d562d4998a720023c (patch)
tree6083ab9075b33a1e6f366f5e15b787406623868c /etc
parent0246ad5b0c0d611a948e9a1ddbd1208496f59534 (diff)
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@
Diffstat (limited to 'etc')
-rw-r--r--etc/rc.d/rc.subr36
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