Check-in [716b0393df]
Logged in as anonymous
Overview
Comment:rework daemonization, export enable variables and add checks for them
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 716b0393dfbad8c5922c0555989de312956dad9dede937c1d49e0c2b87ef07ba
User & Date: arcade on 2019-10-21 10:37:45.158
Other Links: manifest | tags
Context
2019-10-21
14:21
fix devd, fix order, change daemonizing process, adding nfsd check-in: 67838bd249 user: arcade tags: trunk
10:37
rework daemonization, export enable variables and add checks for them check-in: 716b0393df user: arcade tags: trunk
2019-10-20
12:31
add cloned interfaces, make sure interfaces are initialized after module loading check-in: 380071b4cc user: arcade tags: trunk
Changes
Modified Makefile from [af62bbb687] to [b46cb7ad36].
1
2
3

4

5








6
7

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22















23
24
25
26
27
28
29

30


31

32
33














1
2
3
4

5
6
7
8
9
10
11
12
13
14
15

16


17
18
19
20
21
22
23
24
25
26
27
28

29
30
31
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



+
-
+

+
+
+
+
+
+
+
+

-
+
-
-












-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+






-
+

+
+

+


+
+
+
+
+
+
+
+
+
+
+
+
+
+
.include "/etc/mrc.conf"
.export

OTHER_TARGETS:=_daemon _service
DAEMONIZER?=svc.daemon
DAEMONIZER?=svc

.for daemonizer in ${:!find /etc/mrc -name '*.daemon.mk'!:S/\/etc\/mrc\///}
.include "${daemonizer}"
.endfor

.if !target(_daemon) || !target(_service)
.error No daemonizer defined.
.endif

#.MAKE.JOBS?=2
.SILENT:
#.SILENT:

.include "${DAEMONIZER}"

.if defined(AUTOBOOT)
SCRIPTS=${:!find /etc/mrc -name '*.init' -o -name '*.service'!:S/\/etc\/mrc\///}

.ERROR:
	: ERROR: ABORTING BOOT (sending SIGTERM to parent)!
	: target ${.ERROR_TARGET} failed to execute:
	: ${.ERROR_CMD}
	kill 1
.else
SCRIPTS=${:!find /etc/mrc -name '*.service'!:S/\/etc\/mrc\///}

DAEMON:
DAEMON: NETWORK SERVERS

LOGIN: DAEMON

NETWORK:

SERVERS:

mountlate: mount cleanvar

mount:

cleanvar: mount

nfsclient: NETWORK
.endif

TARGETS:=${SCRIPTS:S/.init//:S/.service//}

.MAIN: ${TARGETS}

.PHONY: ${TARGETS} _daemon _service
.PHONY: ${TARGETS} ${OTHER_TARGETS}

.undef TARGETS OTHER_TARGETS

.for file in ${SCRIPTS}
.info ${file}
.include "${file}"
.endfor

.undef SCRIPTS

ENABLED=${:!env!:C/=.*//:M*_ENABLE}

.for var in ${ENABLED}
.if !empty(${var}:tl:Mno)
#.info ${var}
.undef ${var}
.unexport ${var}
.endif
.endfor

.undef ENABLED
1
2
3

1
2

3


-
+
# vim:ft=make:

NETWORK: ifconfig dhcpcd devd
NETWORK: ifconfig devd hostname
1
2
3
4
5
6
7
8



1
2
3
4

5
6

7
8
9




-


-
+
+
+
# vim:ft=make:

DAEMON_automountd_COMMAND?=/usr/sbin/autmountd
DAEMON_automountd_ENABLE?=no
DAEMON_automountd_FLAGS?=-d
DAEMON_automountd_MODULES=autofs

automountd: _daemon
automountd: _daemon nfsclient
.export DAEMON_$@_ENABLE
	test -z "$${DAEMON_$@_ENABLE}" || /usr/sbin/automount
1
2
3
4
5
6
7


8
9



1
2
3
4
5
6
7
8
9


10
11
12







+
+
-
-
+
+
+
# vim:ft=make:

DAEMON_dbus_COMMAND?=/usr/local/bin/dbus-daemon
DAEMON_dbus_ENABLE?=no
DAEMON_dbus_FLAGS?=--system

dbus: _daemon
.export DAEMON_$@_ENABLE
	test -z "$${DAEMON_$@_ENABLE}" || { \
	/usr/local/bin/dbus-uuidgen --ensure
	mkdir -p /var/run/dbus
	  /usr/local/bin/dbus-uuidgen --ensure; \
	  mkdir -p /var/run/dbus; \
	}
1
2
3

4
5
6
7
8



9
1
2
3
4
5
6



7
8
9




+


-
-
-
+
+
+
-
# vim:ft=make:

DAEMON_devd_COMMAND?=/sbin/devd
DAEMON_devd_ENABLE?=yes
DAEMON_devd_FLAGS?=-dq

devd: _service ifconfig
.if !empty(DAEMON_devd_ENABLE:tl:Mno)
	sysctl hw.bus.devctl_disable=1
devd: _service
.export DAEMON_$@_ENABLE
	test -z "$${DAEMON_$@_ENABLE}" || sysctl hw.bus.devctl_disable=1
.endif
1
2
3
4
5
6
7

1
2
3
4
5
6

7






-
+
# vim:ft=make:

DAEMON_dhcpcd_COMMAND?=/sbin/dhcpcd
DAEMON_dhcpcd_ENABLE?=no
DAEMON_dhcpcd_FLAGS?=-B

dhcpcd: _service mount cleanvar ifconfig
dhcpcd: _service mount cleanvar NETWORK
1
2
3
4
5
6
7
8

9
1
2
3
4
5

6

7






-

-
+
-
# vim:ft=make:

DUMPDEV?=no

dumpon: random
.if empty(DUMPDEV:tl:Mno)
	: Setting dumpon device.
	dumpon -v ${DUMPDEV}
	test -e ${DUMPDEV} && dumpon -v ${DUMPDEV} || true
.endif
1
2
3

4
5
1
2

3
4
5


-
+


# vim:ft=make:

mountlate: NETWORK mount cleanvar runshm
mountlate: NETWORK mount cleanvar runshm devd
	: Mount late FS.
	mount -a
1
2
3
4
5
6
7
8
9
10


11
1
2
3
4
5
6
7
8
9
10
11
12
13










+
+

# vim:ft=make:

DAEMON_node_exporter_COMMAND?=/usr/local/bin/node_exporter --web.listen-address=${DAEMON_node_exporter_LISTEN_ADDRESS} --collector.textfile.directory=${DAEMON_node_exporter_TEXTFILE_DIR}
DAEMON_node_exporter_ENABLE?=no
DAEMON_node_exporter_LISTEN_ADDRESS?=:9100
DAEMON_node_exporter_TEXTFILE_DIR?=/var/tmp/node_exporter
DAEMON_node_exporter_USER?=nobody
DAEMON_node_exporter_GROUP?=nobody

node_exporter: _daemon
.export DAEMON_$@_ENABLE
	test -z "$${DAEMON_$@_ENABLE}" || \
	install -d -o ${DAEMON_node_exporter_USER} -g ${DAEMON_node_exporter_GROUP} -m1755 ${DAEMON_node_exporter_TEXTFILE_DIR}
1
2
3
4
5
6

7
1
2
3
4
5

6
7





-
+

# vim:ft=make:

DAEMON_slim_COMMAND?=/usr/local/bin/slim
DAEMON_slim_ENABLE?=no

slim: _daemon
slim: _daemon dbus
	rm -f /var/run/slim.auth
1
2
3
4
5
6
7


8
9
10


1
2
3
4
5
6
7
8
9
10
11

12
13







+
+


-
+
+
# vim:ft=make:

DAEMON_smartd_COMMAND?=/usr/local/sbin/smartd
DAEMON_smartd_ENABLE?=no
DAEMON_smartd_FLAGS?=-c /usr/local/etc/smartd.conf -n

smartd: _daemon
.export DAEMON_$@_ENABLE
	test -z "$${DAEMON_$@_ENABLE}" || \
	test -f /usr/local/etc/smartd.conf || { \
	  echo smartd requires config file to start. ; \
	  exit 0 ; } \
	  false; \
	}




1

2

3
4
5
6





7
8
9



10
11
12
13
14





15
16
17




1
2
3
4

5
6
7




8
9
10
11
12



13
14
15
16




17
18
19
20
21



22
23
24
25
+
+
+
+
-
+

+
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+

-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+
LOCAL_TARGETS:=_daemon_svc _service_svc
OTHER_TARGETS+=${LOCAL_TARGETS}
.if ${DAEMONIZER} == "svc"
LOCAL_TARGETS:=${LOCAL_TARGETS} ${LOCAL_TARGETS:S/_svc//}
# vim:ft=make:
.endif

.for target in ${LOCAL_TARGETS}
_daemon: DAEMON .USE
.if empty(DAEMON_$@_ENABLE:tl:Mno)
.if !empty(DAEMON_$@_MODULES)
	kldload -n ${DAEMON_$@_MODULES}
${target}: ${target:M_daemon:DDAEMON} .USE
#.export DAEMON_$@_ENABLE
	env | grep $@
	test -z "$${DAEMON_$@_ENABLE}" || { \
	  test -n "${DAEMON_$@_MODULES}" && kldload -n ${DAEMON_$@_MODULES} || true; \
.endif
	svc -u ${DAEMON_$@_USER:Uroot} -g ${DAEMON_$@_GROUP:Uwheel} init $@ ${DAEMON_$@_COMMAND} ${DAEMON_$@_FLAGS}
.endif
	  svc -u ${DAEMON_$@_USER:Uroot} -g ${DAEMON_$@_GROUP:Uwheel} init $@ ${DAEMON_$@_COMMAND} ${DAEMON_$@_FLAGS}; \
	}
.endfor

_service: .USE
.if empty(DAEMON_$@_ENABLE:tl:Mno)
.if !empty(DAEMON_$@_MODULES)
	kldload -n ${DAEMON_$@_MODULES}
#_service: .USE
#.export DAEMON_$@_ENABLE
#	env | grep $@
#	test -z "$${DAEMON_$@_ENABLE}" || { \
#	  test -n "${DAEMON_$@_MODULES}" && kldload -n ${DAEMON_$@_MODULES} || true; \
.endif
	svc -u ${DAEMON_$@_USER:Uroot} -g ${DAEMON_$@_GROUP:Uwheel} init $@ ${DAEMON_$@_COMMAND} ${DAEMON_$@_FLAGS}
.endif
#	  svc -u ${DAEMON_$@_USER:Uroot} -g ${DAEMON_$@_GROUP:Uwheel} init $@ ${DAEMON_$@_COMMAND} ${DAEMON_$@_FLAGS}; \
#	}

.undef LOCAL_TARGETS
1
2
3

4
5
6
1
2
3
4
5
6
7



+



# vim:ft=make:

DAEMON_syslogd_COMMAND?=/usr/sbin/syslogd
DAEMON_syslogd_ENABLE?=yes
DAEMON_syslogd_FLAGS?=-ss8cc

syslogd: _service