-# $OpenBSD: rc.subr,v 1.156 2022/08/29 19:37:32 ajacoutot Exp $
+# $OpenBSD: rc.subr,v 1.157 2022/09/01 07:25:32 ajacoutot Exp $
#
# Copyright (c) 2010, 2011, 2014-2022 Antoine Jacoutot <ajacoutot@openbsd.org>
# Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-_rc_actions="start stop restart reload check"
+_rc_actions="start stop restart reload check configtest"
readonly _rc_actions
_rc_check_name() {
echo $_n "${INRC:+ }${_name}"
_rc_do rc_check && _rc_exit ok || _rc_exit failed
;;
+ configtest)
+ echo $_n "${INRC:+ }${_name}"
+ _rc_do rc_configtest && _rc_exit ok || _rc_exit failed
+ ;;
start)
if [ X"${daemon_flags}" = X"NO" ]; then
_rc_err "$0: need -f to force $1 since ${_name}_flags=NO"
[ -z "${INRC}" ] && _rc_do rc_check && exit 0
echo $_n "${INRC:+ }${_name}"
while true; do # no real loop, only needed to break
- # mostly useful for daemons whose child will not return
- # a config parsing error to the parent during startup
- # e.g. bgpd, httpd...
+ # 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
_rc_do rc_pre || break
-.\" $OpenBSD: rc.d.8,v 1.38 2022/05/26 11:27:03 ajacoutot Exp $
+.\" $OpenBSD: rc.d.8,v 1.39 2022/09/01 07:25:32 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: May 26 2022 $
+.Dd $Mdocdate: September 1 2022 $
.Dt RC.D 8
.Os
.Sh NAME
Each such script responds to the following
.Ar actions :
.Pp
-.Bl -tag -width restart -offset indent -compact
+.Bl -tag -width configtest -offset indent -compact
.It Cm start
Start the service, if not already running.
.It Cm stop
Perform a stop, then a start.
.It Cm check
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
#!/bin/ksh
#
-# $OpenBSD: rcctl.sh,v 1.113 2022/05/26 11:27:03 ajacoutot Exp $
+# $OpenBSD: rcctl.sh,v 1.114 2022/09/01 07:25:32 ajacoutot Exp $
#
# Copyright (c) 2014, 2015-2022 Antoine Jacoutot <ajacoutot@openbsd.org>
# Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
rcctl_err "service ${svc} does not exist" 2
done
;;
- disable|enable|start|stop|restart|reload|check)
+ disable|enable|start|stop|restart|reload|check|configtest)
shift 1
svcs="$*"
[ -z "${svcs}" ] && usage
needs_root ${action}
svc_set ${svc} "${var}" "${args}"
;;
- start|stop|restart|reload|check)
+ start|stop|restart|reload|check|configtest)
for svc in ${svcs}; do
if svc_is_special ${svc}; then
rcctl_err "\"${svc}\" is a special variable, no rc.d(8) script"