Check-in [be5654b61b]
Logged in as anonymous
Overview
Comment:add defaults, add CWD
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: be5654b61b5f6b8b1ba0988215ae1f7d16deb8dd68f43d5c2c3e90a39c054b47
User & Date: arcade on 2023-08-18 13:37:40.124
Other Links: manifest | tags
Context
2023-08-18
13:38
add arpwatch check-in: 9967ffe6bc user: arcade tags: trunk
13:37
add defaults, add CWD check-in: be5654b61b user: arcade tags: trunk
2023-08-13
07:15
Load kernel modules one by one (so all possible would be loaded) check-in: 625f7382df user: arcade tags: trunk
Changes
Modified Makefile from [7ada1edf35] to [2681177168].
1
2
3
4
5
6
7
8
9
10
11
12
13
.include "defaults.mk"
.include "order.mk"
.include "/etc/mrc.mk"
.export

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

OTHER_TARGETS:=

.include "starter.mk"





|







1
2
3
4
5
6
7
8
9
10
11
12
13
.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:=

.include "starter.mk"
32
33
34
35
36
37
38
39










40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

56
57
58
59
60
61
62

test:
	echo Empty target.

# Create service targets
.for service in ${SCRIPTS}
.	include "${service}.service.mk"











# Service creation targets
.	if !target(${service})
${service}: ${SERVICE_EXIT} ${_SERVICE}
.	endif

# Service status targets
.	if !target(${service}_status)
${service}_status: ${_SERVICE_STATUS}
.	endif

# Service exit targets
.	if !target(${service}_exit)
${service}_exit: ${_SERVICE_EXIT} ${DAEMON_${service}_DEPS:S/$/_exit/}
.	endif

DAEMON_EXIT: ${service}_exit

.endfor

.MAIN: ${SCRIPTS} ${TARGETS}

.PHONY: ${SCRIPTS} ${OTHER_TARGETS} ${TARGETS}
.undef OTHER_TARGETS SCRIPTS TARGETS









>
>
>
>
>
>
>
>
>
>

|

|


|

|


|

|


>







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

test:
	echo Empty target.

# Create service targets
.for service in ${SCRIPTS}
.	include "${service}.service.mk"

# Set DAEMON defaults
DAEMON_${service}_CWD?=	/
DAEMON_${service}_ENABLE?=	no
DAEMON_${service}_USER?=	root
DAEMON_${service}_GROUP?=	wheel

.	if !defined(DAEMON_${service}_COMMAND)
.		warning MRC> Service [${service}] defunct: no COMMAND specified
.	else

# Service creation targets
.		if !target(${service})
${service}: ${SERVICE_EXIT} ${_SERVICE}
.		endif

# Service status targets
.		if !target(${service}_status)
${service}_status: ${_SERVICE_STATUS}
.		endif

# Service exit targets
.		if !target(${service}_exit)
${service}_exit: ${_SERVICE_EXIT} ${DAEMON_${service}_DEPS:S/$/_exit/}
.		endif

DAEMON_EXIT: ${service}_exit
.	endif
.endfor

.MAIN: ${SCRIPTS} ${TARGETS}

.PHONY: ${SCRIPTS} ${OTHER_TARGETS} ${TARGETS}
.undef OTHER_TARGETS SCRIPTS TARGETS

1

2
3
4
5
6
7
8
_service_daemon: .USE

	daemon -c -u ${DAEMON_$@_USER:Uroot} -r -P /var/run/daemon.$@.pid ${DAEMON_$@_COMMAND} ${DAEMON_$@_FLAGS} ${DAEMON$@_FOREGROUND}

_service_daemon_status: .USE
	echo "Not supported yet."

_service_daemon_exit: .USEBEFORE
	kill -TERM /var/run/daemon.${@:S/_exit//}.pid

>
|






1
2
3
4
5
6
7
8
9
_service_daemon: .USE
	cd ${DAEMON_$@_CWD}
	daemon -u ${DAEMON_$@_USER} -r -P /var/run/daemon.$@.pid ${DAEMON_$@_COMMAND} ${DAEMON_$@_FLAGS} ${DAEMON$@_FOREGROUND}

_service_daemon_status: .USE
	echo "Not supported yet."

_service_daemon_exit: .USEBEFORE
	kill -TERM /var/run/daemon.${@:S/_exit//}.pid
1
2
3
4
5
6
7
8






9
10
11
12
13
14
15
# vim:ft=make:

# command to start service
DAEMON_example_COMMAND?=/path/service

# flags to force daemonizing
DAEMON_example_BACKGROUND?=







# enabled by default?
DAEMON_example_ENABLE?=no

# general service flags
DAEMON_example_FLAGS?=

# flags to prevent daemonizing


<
<
<



>
>
>
>
>
>







1
2



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# vim:ft=make:




# flags to force daemonizing
DAEMON_example_BACKGROUND?=

# default working directory
DAEMON_example_CWD?=/some/path

# command to start service
DAEMON_example_COMMAND?=/path/service

# enabled by default?
DAEMON_example_ENABLE?=no

# general service flags
DAEMON_example_FLAGS?=

# flags to prevent daemonizing
1
2
3
4
5
6
7
8
_service_plain: .USE
	chroot -u ${DAEMON_$@_USER:Uroot} -g ${DAEMON_$@_GROUP:Uwheel} / ${DAEMON_$@_COMMAND} ${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} ${DAEMON_$@_COMMAND} ${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
9
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}

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

_service_svc_exit: .USEBEFORE
	svc list ${@:S/_exit//} | grep -q ${@:S/_exit//} || true && \
		svc -s exit ${@:S/_exit//}

>

|







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

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

_service_svc_exit: .USEBEFORE
	svc list ${@:S/_exit//} | grep -q ${@:S/_exit//} || true && \
		svc -s exit ${@:S/_exit//}