Lines of
starter.mk
from check-in f2a642cc7a
that are changed by the sequence of edits moving toward
check-in 1ae31ed8a2:
1: OTHER_TARGETS+=_service_pre
2:
3: STARTER?=svc
4:
5: _service_check: .USEBEFORE
6: # check whether service is enabled
7: if [ -z "$${DAEMON_$@_ENABLE}" -a -z "${FORCE}" ]; then \
8: exit 0 ;\
9: fi
10: # check for first present executable
11: for CHECK_CMD in ${DAEMON_$@_COMMAND}; do \
12: if [ -x $${CHECK_CMD} ]; then \
13: export CMD="$${CHECK_CMD}" ;\
14: break ;\
15: fi ;\
16: done
17: # bail out if binary not found
18: if [ -z $${CMD} ]; then \
19: echo "MRC:$@> Executable not found." ;\
20: exit 0 ;\
21: fi
22: # check for rtprio/idprio
23: if [ -n "$${DAEMON_$@_IDPRIO}" ]; then \
24: export CMD="/usr/sbin/idprio $${DAEMON_$@_IDPRIO} $${CMD}" ;\
25: elif [ -n "$${DAEMON_$@_RTPRIO}" ]; then \
26: export CMD="/usr/sbin/rtprio $${DAEMON_$@_RTPRIO} $${CMD}" ;\
27: fi
28:
29: _service_pre: .USEBEFORE
30: # kldload modules if any
31: echo "MRC:$@> Starting service." ;\
32: if [ -n "${DAEMON_$@_MODULES}" ]; then \
33: kldload -n ${DAEMON_$@_MODULES}; \
34: fi
35:
36: _service_post_exit: .USE
37: echo "MRC:${@:S/_exit//}> stopped."
38:
39: .for starter_source in ${:!find /etc/mrc -name '*.starter.mk'!:S/\/etc\/mrc\///}
40: starter:=${starter_source:S/.starter.mk$//}
41: Starter:=${starter:tu}
42:
43: OTHER_TARGETS:=${OTHER_TARGETS} _service_${starter} _service_${starter}_exit _service_${starter}_status
44:
45: # here we are inheriting pieces of different targets into one single target, so
46: # everything is appended in the order, but gets organized a little bit
47: # differently, all targets with .USEBEFORE are added before current target
48: # script, so after "_service_pre _service_check" we got that order inverted
49:
f2a642cc7a 2025-02-22 50: _SERVICE_${Starter}:=_service_pre DAEMON _service_${starter} _service_check
f2a642cc7a 2025-02-22 51: _EARLYSERVICE_${Starter}:=_service_pre SERVICE _service_${starter} _service_check
f2a642cc7a 2025-02-22 52: _SERVICE_${Starter}_EXIT:=_service_${starter}_exit _service_post_exit
53:
54: . if "${STARTER}" == "${starter}"
f2a642cc7a 2025-02-22 55: _SERVICE:=_service_pre DAEMON _service_${starter} _service_check
f2a642cc7a 2025-02-22 56: _EARLYSERVICE:=_service_pre SERVICE _service_${starter} _service_check
f2a642cc7a 2025-02-22 57: _SERVICE_EXIT:=_service_${starter}_exit _service_post_exit
58: . endif
59:
f2a642cc7a 2025-02-22 60: . export
61: . include "${starter_source}"
62: .endfor