Index: boinc-client.service.mk ================================================================== --- boinc-client.service.mk +++ boinc-client.service.mk @@ -1,4 +1,5 @@ DAEMON_boinc-client_COMMAND?=/usr/local/bin/boinc_client -DAEMON_boinc-client_FLAGS?=--redirectio --dir /var/db/boinc +DAEMON_boinc-client_FLAGS?=--redirectio --dir /var/db/boinc DAEMON_boinc-client_BACKGROUND?=-daemon +DAEMON_boinc-client_ENABLE?=no DAEMON_boinc-client_USER?=boinc Index: bsdstat.service.mk ================================================================== --- bsdstat.service.mk +++ bsdstat.service.mk @@ -1,6 +1,6 @@ -DAEMON_bsdstats_COMMAND?=/usr/local/etc/periodic/monthly/300.statistics -DAEMON_bsdstats_ENABLE?=no -DAEMON_bsdstats_FLAGS?=-nodelay +DAEMON_bsdstat_COMMAND?=/usr/local/etc/periodic/monthly/300.statistics +DAEMON_bsdstat_ENABLE?=no +DAEMON_bsdstat_FLAGS?=-nodelay -bsdstats: _service_plain -bsdstats_exit: +bsdstat: ${_SERVICE_PLAIN} +bsdstat_exit: Index: daemon.starter.mk ================================================================== --- daemon.starter.mk +++ daemon.starter.mk @@ -3,6 +3,6 @@ _service_daemon_status: .USE echo "Not supported yet." _service_daemon_exit: .USEBEFORE - kill -TERM /var/run/daemon.$@.pid + kill -TERM /var/run/daemon.${@:S/_exit//}.pid Index: example.service_mk ================================================================== --- example.service_mk +++ example.service_mk @@ -23,16 +23,12 @@ # user to run service as DAEMON_example_USER?=root # extra commands to execute before starting service -# _earlyservice - starts after root mount appear -# _service - doesn't required for early boot +# ${_SERVICE} - starts after root mount appear +# ${_EARLYSERVICE} - not required on early boot # you also can select specific starter by inheriting class by full name: -# _(daemon|plain|svc)_(early)?service -example: _earlyservice - test -n "$${DAEMON_$@_ENABLE}" || echo service is always execute - -# you can't be sure whether service is enabled on the first run, when future -# targets are only assembled, as service can be enabled later in the chain -# somake sure to check whether service is enabled in scripts you are running -# not in make constructs +# ${_(EARLY)?SERVICE(_(SVC|DAEMON|PLAIN))?} + +example: ${_EARLYSERVICE} + : run commands that should go before the service start Index: nfsd.service.mk ================================================================== --- nfsd.service.mk +++ nfsd.service.mk @@ -9,7 +9,5 @@ nfsd: mountd ${_SERVICE} rpcbind .if empty(NFS_RESERVED_PORT_ONLY:tl:Mno) sysctl vfs.nfs.nfs_privport=1 .endif - -nfsd_exit: Index: starter.mk ================================================================== --- starter.mk +++ starter.mk @@ -1,35 +1,40 @@ OTHER_TARGETS+=_service_pre STARTER?=svc -_service_pre: .USEBEFORE +_service_check: .USEBEFORE # check whether service is enabled if [ -z "$${DAEMON_$@_ENABLE}" ]; then \ exit 0; \ - fi; \ + fi + +_service_pre: .USEBEFORE echo "MRC:$@> Starting service." # kldload modules if any if [ -n "${DAEMON_$@_MODULES}" ]; then \ kldload -n ${DAEMON_$@_MODULES}; \ - fi; \ + fi + +_service_post_exit: .USE + echo "MRC:${@:S/_exit//}> stopped." .for starter_source in ${:!find /etc/mrc -name '*.starter.mk'!:S/\/etc\/mrc\///} starter:=${starter_source:S/.starter.mk$//} Starter:=${starter:tu} OTHER_TARGETS:=${OTHER_TARGETS} _service_${starter} _service_${starter}_exit _service_${starter}_status -_SERVICE_${Starter}:=_service_pre DAEMON _service_${starter} -_EARLYSERVICE_${Starter}:=_service_pre SERVICE _service_${starter} -_SERVICE_${Starter}_EXIT:=_service_${starter}_exit +_SERVICE_${Starter}:=_service_pre DAEMON _service_${starter} _service_check +_EARLYSERVICE_${Starter}:=_service_pre SERVICE _service_${starter} _service_check +_SERVICE_${Starter}_EXIT:=_service_${starter}_exit _service_post_exit .if "${STARTER}" == "${starter}" -_SERVICE:=_service_pre DAEMON _service_${starter} -_EARLYSERVICE:=_service_pre SERVICE _service_${starter} -_SERVICE_EXIT:=_service_${starter}_exit +_SERVICE:=_service_pre DAEMON _service_${starter} _service_check +_EARLYSERVICE:=_service_pre SERVICE _service_${starter} _service_check +_SERVICE_EXIT:=_service_${starter}_exit _service_post_exit .endif .export .include "${starter_source}" .endfor Index: svc.starter.mk ================================================================== --- svc.starter.mk +++ svc.starter.mk @@ -1,9 +1,10 @@ _service_svc: .USE svc list $@ | grep -q $@ || \ - svc -u ${DAEMON_$@_USER:Uroot} -g ${DAEMON_$@_GROUP:Uwheel} ${DAEMON_$@_RESTART:D-r} ${DAEMON_$@_RESTART} init $@ ${DAEMON_$@_COMMAND} ${DAEMON_$@_FLAGS} ${DAEMON_$@_FOREGROUND} + svc -u ${DAEMON_$@_USER:Uroot} -g ${DAEMON_$@_GROUP:Uwheel} ${DAEMON_$@_RESTART:D-r} ${DAEMON_$@_RESTART} init $@ ${DAEMON_$@_COMMAND} ${DAEMON_$@_FLAGS} ${DAEMON_$@_FOREGROUND} _service_svc_status: .USE - svc status $@ + svc status ${@:S/_status//} _service_svc_exit: .USEBEFORE - svc exit $@ + svc list ${@:S/_exit//} | grep -q ${@:S/_exit//} || true && \ + svc -s exit ${@:S/_exit//}