From 6a83587c67ca647c29002c03131a08a365d5d56b Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Mon, 19 Sep 2011 20:41:51 +0000 Subject: 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@ --- etc/rc.d/rc.subr | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'etc') 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 # Copyright (c) 2010, 2011 Ingo Schwarze @@ -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} -- cgit v1.2.3