Check-in [1ae31ed8a2]
Logged in as anonymous
Overview
Comment:service startup/shutdown, bmake updates
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1ae31ed8a202e135c84678ab604aeb2590edbe1ca23be70b206027d8e50c6c91
User & Date: arcade on 2025-03-10 16:49:22.974
Other Links: manifest | tags
Context
2025-03-10
16:49
more services Leaf check-in: 1fa07fe6a0 user: arcade tags: trunk
16:49
service startup/shutdown, bmake updates check-in: 1ae31ed8a2 user: arcade tags: trunk
2025-02-22
07:01
add service post-actions check-in: 1f0bd9b2f0 user: arcade tags: trunk
Changes
Modified Makefile from [5d348d4b86] to [2ff65c2457].
1
2
3
4
5
6
7
8
9
10
11
.include "defaults.mk"
.include "order.mk"
.include "/etc/mrc.mk"
.export

.MAKE.JOBS?=	${NCPU}
.if !empty(.MAKE.MODE:Mcompat)
.error "ERROR: MRC doesn't support "compat" mode."
.endif

OTHER_TARGETS:=



|







1
2
3
4
5
6
7
8
9
10
11
.include "defaults.mk"
.include "order.mk"
.include "/etc/mrc.mk"
.export-all

.MAKE.JOBS?=	${NCPU}
.if !empty(.MAKE.MODE:Mcompat)
.error "ERROR: MRC doesn't support "compat" mode."
.endif

OTHER_TARGETS:=
40
41
42
43
44
45
46
47
48
#.info ${var}
.		undef ${var}
.	endif
.endfor

.undef ENABLED
.unexport-env
.export
#.info ${:!env!}







|

40
41
42
43
44
45
46
47
48
#.info ${var}
.		undef ${var}
.	endif
.endfor

.undef ENABLED
.unexport-env
.export-all
#.info ${:!env!}
1
2
3
4
5
6
7
8
DAEMON_dbus_COMMAND?=/usr/local/bin/dbus-daemon
DAEMON_dbus_FLAGS?=--system --syslog
DAEMON_dbus_BACKGROUND?=--fork
DAEMON_dbus_FOREGROUND?=--nofork --nopidfile

dbus: ${_SERVICE}
	mkdir -p /var/run/dbus /var/lib/dbus
	/usr/local/bin/dbus-uuidgen --ensure

|






1
2
3
4
5
6
7
8
DAEMON_dbus_COMMAND?=/usr/local/bin/dbus-daemon
DAEMON_dbus_FLAGS?=--system --syslog --print-address
DAEMON_dbus_BACKGROUND?=--fork
DAEMON_dbus_FOREGROUND?=--nofork --nopidfile

dbus: ${_SERVICE}
	mkdir -p /var/run/dbus /var/lib/dbus
	/usr/local/bin/dbus-uuidgen --ensure
1
2
3
4
5
6
7
8
_service_plain: .USE
	chroot -u ${DAEMON_$@_USER} -g ${DAEMON_$@_GROUP} ${DAEMON_$@_CWD} $${CMD} ${DAEMON_$@_FLAGS} ${DAEMON_$@_BACKGROUND}

_service_status: .USE
	echo "Plain service status doesn't work right now."

_service_exit: .USEBEFORE
	echo "Plain service exit doesn't work right now."



|


|
|
1
2
3
4
5
6
7
8
_service_plain: .USE
	chroot -u ${DAEMON_$@_USER} -g ${DAEMON_$@_GROUP} ${DAEMON_$@_CWD} $${CMD} ${DAEMON_$@_FLAGS} ${DAEMON_$@_BACKGROUND}

_service_plain_status: .USE
	echo "Plain service status doesn't work right now."

_service_plain_exit: .USEBEFORE
	export CMD="chroot -u ${DAEMON_$@_USER} -g ${DAEMON_$@_GROUP} ${DAEMON_$@_CWD} $${CMD} ${DAEMON_$@_FLAGS}"
15
16
17
18
19
20
21


22
23
24
25
26
27
28
		fi ;\
	done
	# bail out if binary not found
	if [ -z $${CMD} ]; then \
		echo "MRC:$@> Executable not found." ;\
		exit 0 ;\
	fi


	# check for rtprio/idprio
	if [ -n "$${DAEMON_$@_IDPRIO}" ]; then \
		export CMD="/usr/sbin/idprio $${DAEMON_$@_IDPRIO} $${CMD}" ;\
	elif [ -n "$${DAEMON_$@_RTPRIO}" ]; then \
		export CMD="/usr/sbin/rtprio $${DAEMON_$@_RTPRIO} $${CMD}" ;\
	fi








>
>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
		fi ;\
	done
	# bail out if binary not found
	if [ -z $${CMD} ]; then \
		echo "MRC:$@> Executable not found." ;\
		exit 0 ;\
	fi

_service_check_start: .USEBEFORE
	# check for rtprio/idprio
	if [ -n "$${DAEMON_$@_IDPRIO}" ]; then \
		export CMD="/usr/sbin/idprio $${DAEMON_$@_IDPRIO} $${CMD}" ;\
	elif [ -n "$${DAEMON_$@_RTPRIO}" ]; then \
		export CMD="/usr/sbin/rtprio $${DAEMON_$@_RTPRIO} $${CMD}" ;\
	fi

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
OTHER_TARGETS:=${OTHER_TARGETS} _service_${starter} _service_${starter}_exit _service_${starter}_status

# here we are inheriting pieces of different targets into one single target, so
# everything is appended in the order, but gets organized a little bit
# differently, all targets with .USEBEFORE are added before current target
# script, so after "_service_pre _service_check" we got that order inverted

_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} _service_check
_EARLYSERVICE:=_service_pre SERVICE _service_${starter} _service_check
_SERVICE_EXIT:=_service_${starter}_exit _service_post_exit
.	endif

.	export
.	include "${starter_source}"
.endfor







|
|
|


|
|
|


|


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
OTHER_TARGETS:=${OTHER_TARGETS} _service_${starter} _service_${starter}_exit _service_${starter}_status

# here we are inheriting pieces of different targets into one single target, so
# everything is appended in the order, but gets organized a little bit
# differently, all targets with .USEBEFORE are added before current target
# script, so after "_service_pre _service_check" we got that order inverted

_SERVICE_${Starter}:=_service_pre DAEMON _service_${starter} _service_check_start _service_check
_EARLYSERVICE_${Starter}:=_service_pre SERVICE _service_${starter} _service_check_start _service_check
_SERVICE_${Starter}_EXIT:=_service_${starter}_exit _service_post_exit _service_check

.	if "${STARTER}" == "${starter}"
_SERVICE:=${_SERVICE_${Starter}}
_EARLYSERVICE:=${_EARLYSERVICE_${Starter}}
_SERVICE_EXIT:=${_SERVICE_${Starter}_EXIT}
.	endif

.	export-all
.	include "${starter_source}"
.endfor
1
2
3
4
5
6
7
8
9
10
11
12
_service_svc: .USE
	cd ${DAEMON_$@_CWD} ;\
	svc list $@ | grep -q $@ || \
		svc -u ${DAEMON_$@_USER} -g ${DAEMON_$@_GROUP} ${DAEMON_$@_RESTART:D-r} ${DAEMON_$@_RESTART} init $@ $${CMD} ${DAEMON_$@_FLAGS} ${DAEMON_$@_FOREGROUND} > /dev/null

_service_svc_status: .USE
	svc status ${@:S/_status//}

_service_svc_exit: .USEBEFORE
	#svc list ${@:S/_exit//} | grep -q ${@:S/_exit//} || true &&
	lockf -kst 0 /var/run/service.${@:S/_exit//}.pid svc -t 0 kill ${@:S/_exit//} || \
		svc -s exit ${@:S/_exit//} > /dev/null









|


1
2
3
4
5
6
7
8
9
10
11
12
_service_svc: .USE
	cd ${DAEMON_$@_CWD} ;\
	svc list $@ | grep -q $@ || \
		svc -u ${DAEMON_$@_USER} -g ${DAEMON_$@_GROUP} ${DAEMON_$@_RESTART:D-r} ${DAEMON_$@_RESTART} init $@ $${CMD} ${DAEMON_$@_FLAGS} ${DAEMON_$@_FOREGROUND} > /dev/null

_service_svc_status: .USE
	svc status ${@:S/_status//}

_service_svc_exit: .USEBEFORE
	svc list ${@:S/_exit//} | grep -q ${@:S/_exit//} || true && \
	lockf -kst 0 /var/run/service.${@:S/_exit//}.pid svc -t 0 kill ${@:S/_exit//} || \
		svc -s exit ${@:S/_exit//} > /dev/null