diff options
author | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2016-04-26 16:40:00 +0000 |
---|---|---|
committer | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2016-04-26 16:40:00 +0000 |
commit | 39ed2c499971fab17f879d01026fd41aa917bf30 (patch) | |
tree | 9f339449aa98b587e63e3a836a295113627232c0 /etc/rc.d | |
parent | 5a899185b19b1f196e919ccfd66d6c13ee782baa (diff) |
Extend _RC_RUNFILE (/var/run/rc.d/scriptname) content with:
daemon_class, daemon_flags, daemon_timeout, daemon_user, pexp
Add "pexp" as a valid variable to _rc_parse_conf() and sort the list while here.
Besides having an easy way to see how a daemon was started exactly, it opens the
door to rdomain/rtable support in rc.d(8). We need to have as much information
on a daemon as possible if we want to target a specific rtable (using -T) and it
also makes it easier to start multiple instances of the same daemon with similar
flags as a different user...
Of course that only works with rc.d scripts *not* overwritting the default rc_*
functions.
Man page tweaks coming later.
discussed with and ok robert@
Diffstat (limited to 'etc/rc.d')
-rw-r--r-- | etc/rc.d/rc.subr | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/etc/rc.d/rc.subr b/etc/rc.d/rc.subr index cd083d14439..83dc0251f5f 100644 --- a/etc/rc.d/rc.subr +++ b/etc/rc.d/rc.subr @@ -1,4 +1,4 @@ -# $OpenBSD: rc.subr,v 1.107 2016/03/26 13:59:36 ajacoutot Exp $ +# $OpenBSD: rc.subr,v 1.108 2016/04/26 16:39:59 ajacoutot Exp $ # # Copyright (c) 2010, 2011, 2014, 2015 Antoine Jacoutot <ajacoutot@openbsd.org> # Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -46,13 +46,13 @@ _rc_usage() { _rc_write_runfile() { [ -d ${_RC_RUNDIR} ] || mkdir -p ${_RC_RUNDIR} && \ - print -rn -- "${pexp}" > ${_RC_RUNFILE} -} - -_rc_read_runfile() { - local _new_pexp - [ -f ${_RC_RUNFILE} ] && _new_pexp=$(< ${_RC_RUNFILE}) - [ -n "${_new_pexp}" ] && pexp="${_new_pexp}" + cat >${_RC_RUNFILE} <<EOF +daemon_class=${daemon_class} +daemon_flags=${daemon_flags} +daemon_timeout=${daemon_timeout} +daemon_user=${daemon_user} +pexp=${pexp} +EOF } _rc_rm_runfile() { @@ -121,9 +121,8 @@ _rc_parse_conf() { typeset -l _key local _l _rcfile _val set -A _allowed_keys -- \ - spamd_black pf ipsec check_quotas accounting \ - multicast amd_master \ - shlib_dirs pkg_scripts nfs_server + accounting amd_master check_quotas ipsec multicast nfs_server \ + pexp pf pkg_scripts shlib_dirs spamd_black [ $# -gt 0 ] || set -- /etc/rc.conf /etc/rc.conf.local for _rcfile; do @@ -155,15 +154,15 @@ rc_start() { } rc_check() { - pgrep -q -xf "${pexp}" + pgrep -U "${daemon_user}" -q -xf "${pexp}" } rc_reload() { - pkill -HUP -xf "${pexp}" + pkill -U "${daemon_user}" -HUP -xf "${pexp}" } rc_stop() { - pkill -xf "${pexp}" + pkill -U "${daemon_user}" -xf "${pexp}" } rc_cmd() { @@ -183,7 +182,7 @@ rc_cmd() { [ X"${rc_bg}" = X"YES" ] && _bg="&" [ -n "${_RC_DEBUG}" ] || _n="-n" - _rc_do _rc_read_runfile + _rc_do _rc_parse_conf ${_RC_RUNFILE} case "$1" in check) |