-# $OpenBSD: rc.subr,v 1.157 2022/09/01 07:25:32 ajacoutot Exp $
+# $OpenBSD: rc.subr,v 1.158 2022/09/02 22:11:57 ajacoutot Exp $
#
# Copyright (c) 2010, 2011, 2014-2022 Antoine Jacoutot <ajacoutot@openbsd.org>
# Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
_rc_not_supported() {
local _a _enotsup _what=${1}
for _a in ${_rc_actions}; do
+ [ "${_what}" == "configtest" ] &&
+ ! typeset -f rc_configtest >/dev/null && _enotsup=NO &&
+ break
[ "${_what}" == "restart" ] && _what="stop"
if [ "${_what}" == "${_a}" ]; then
eval _enotsup=\${rc_${_what}}
return
}
-rc_configtest() {
- return 0
-}
-
rc_exec() {
local _rcexec="su -fl -c ${daemon_class} -s /bin/sh ${daemon_user} -c"
[ "${daemon_rtable}" -eq "$(id -R)" ] ||
# running during start is mostly useful for daemons
# whose child will not return a config parsing error to
# the parent during startup; e.g. bgpd, httpd...
- _rc_do rc_configtest || break
- if type rc_pre >/dev/null; then
+ if typeset -f rc_configtest >/dev/null; then
+ _rc_do rc_configtest || break
+ fi
+ if typeset -f rc_pre >/dev/null; then
_rc_do rc_pre || break
fi
# prevent hanging the boot sequence
done
# handle failure
_rc_do _rc_rm_runfile
- type rc_post >/dev/null && _rc_do rc_post
+ typeset -f rc_post >/dev/null && _rc_do rc_post
_rc_exit failed
;;
stop)
# KILL the process
_rc_do rc_check && _rc_do _rc_sendsig KILL && _exit="killed"
_rc_do _rc_rm_runfile
- if type rc_post >/dev/null; then
+ if typeset -f rc_post >/dev/null; then
_rc_do rc_post || _exit=failed
fi
_rc_exit ${_exit:=ok}
reload)
echo $_n "${INRC:+ }${_name}"
_rc_do rc_check || _rc_exit failed
- _rc_do rc_configtest || _rc_exit failed
+ if typeset -f rc_configtest >/dev/null; then
+ _rc_do rc_configtest || _rc_exit failed
+ fi
_rc_do rc_reload & _timer=$!
while ((SECONDS < daemon_timeout)); do
pkill -0 -P "$$" 2>/dev/null || break
_rc_exit ${_exit:=ok}
;;
restart)
- _rc_do rc_configtest || _rc_exit failed
+ if typeset -f rc_configtest >/dev/null; then
+ _rc_do rc_configtest || _rc_exit failed
+ fi
$0 ${_RC_DEBUG} ${_RC_FORCE} stop &&
$0 ${_RC_DEBUG} ${_RC_FORCE} start
;;
-.\" $OpenBSD: rc.d.8,v 1.39 2022/09/01 07:25:32 ajacoutot Exp $
+.\" $OpenBSD: rc.d.8,v 1.40 2022/09/02 22:11:57 ajacoutot Exp $
.\"
.\" Copyright (c) 2021 Antoine Jacoutot
.\" Copyright (c) 2011 Robert Nagy, Antoine Jacoutot, Ingo Schwarze
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: September 1 2022 $
+.Dd $Mdocdate: September 2 2022 $
.Dt RC.D 8
.Os
.Sh NAME
Return 0 if the daemon is running or 1 if it is not.
.It Cm configtest
Check that the daemon configuration is valid.
-Only useful if the
-.Nm rc.d
-script provides an
-.Ic rc_configtest
-function.
.El
.Sh ENVIRONMENT
Daemon control scripts use a fixed number of
-.\" $OpenBSD: rc.subr.8,v 1.47 2022/08/30 05:40:28 jmc Exp $
+.\" $OpenBSD: rc.subr.8,v 1.48 2022/09/02 22:11:57 ajacoutot Exp $
.\"
.\" Copyright (c) 2021, 2022 Antoine Jacoutot
.\" Copyright (c) 2011 Robert Nagy, Antoine Jacoutot, Ingo Schwarze
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: August 30 2022 $
+.Dd $Mdocdate: September 2 2022 $
.Dt RC.SUBR 8
.Os
.Sh NAME
.Cm start ,
.Cm reload
and
-.Cm restart .
-Defaults to
-.Sq return 0
-but can be overridden by the
+.Cm restart
+if implemented by the
.Xr rc.d 8
script.
.It Ic rc_exec
and
.Va daemon_logger
values.
+.It Ic rc_post
+This function is run after
+.Cm stop
+if implemented by the
+.Xr rc.d 8
+script.
+.It Ic rc_pre
+This function is run before
+.Cm start
+if implemented by the
+.Xr rc.d 8
+script.
.It Ic rc_reload
Send the
.Va rc_reload_signal