summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorRobert Nagy <robert@cvs.openbsd.org>2011-09-19 20:41:51 +0000
committerRobert Nagy <robert@cvs.openbsd.org>2011-09-19 20:41:51 +0000
commit6a83587c67ca647c29002c03131a08a365d5d56b (patch)
treeaca396c718a2a34c4542a23c7fa41ed011de71ad /etc
parent0257be03553018891e610a6eb140229d50b113e1 (diff)
Use arugments for rc script instead of environment variables to indicate
debug mode. This commit also adds a force mode for the script to allow one to force operations even if daemon_flags is set to NO. In this case the sane default values will be used for each script. e.g.: "/etc/rc.d/foo -f start" will start sshd even if it's disabled ok ajacoutot@
Diffstat (limited to 'etc')
-rw-r--r--etc/rc.d/rc.subr13
1 files changed, 11 insertions, 2 deletions
diff --git a/etc/rc.d/rc.subr b/etc/rc.d/rc.subr
index e6f697b3e4d..727f01c60be 100644
--- a/etc/rc.d/rc.subr
+++ b/etc/rc.d/rc.subr
@@ -1,4 +1,4 @@
-# $OpenBSD: rc.subr,v 1.45 2011/07/31 20:22:34 robert Exp $
+# $OpenBSD: rc.subr,v 1.46 2011/09/19 20:41:50 robert Exp $
#
# Copyright (c) 2010, 2011 Antoine Jacoutot <ajacoutot@openbsd.org>
# Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -79,7 +79,7 @@ rc_cmd() {
[ $(id -u) -eq 0 ] || \
rc_err "$0: need root privileges"
- [ X"${daemon_flags}" = X"NO" ] && exit 1
+ [ -z "${RC_FORCE}" ] && [ X"${daemon_flags}" = X"NO" ] && exit 1
eval _enotsup=\${rc_${1}}
[ X"${_enotsup}" != X"NO" ] || rc_err "$0: $1 is not supported"
@@ -138,6 +138,14 @@ rc_cmd() {
[ -n "${daemon}" ] || rc_err "$0: daemon is not set"
+while getopts "df" c; do
+ case "$c" in
+ d) RC_DEBUG=1;;
+ f) RC_FORCE=1;;
+ esac
+done
+shift $((OPTIND-1))
+
_name=$(basename $0)
eval _rcflags=\${${_name}_flags}
eval _rcuser=\${${_name}_user}
@@ -148,6 +156,7 @@ getcap -f /etc/login.conf ${_name} 1>/dev/null 2>&1 && \
[ -z "${daemon_class}" ] && daemon_class=daemon
[ -z "${daemon_user}" ] && daemon_user=root
+[ -n "${RC_FORCE}" ] && [ X"${_rcflags}" = X"NO" ] && unset _rcflags
[ -n "${_rcflags}" ] && daemon_flags=${_rcflags}
[ -n "${_rcuser}" ] && daemon_user=${_rcuser}