Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -1,14 +1,21 @@ .include "/etc/mrc.conf" .export -DAEMONIZER?=svc.daemon +OTHER_TARGETS:=_daemon _service +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: - -.include "${DAEMONIZER}" +#.SILENT: .if defined(AUTOBOOT) SCRIPTS=${:!find /etc/mrc -name '*.init' -o -name '*.service'!:S/\/etc\/mrc\///} .ERROR: @@ -17,17 +24,48 @@ : ${.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 Index: NETWORK.init ================================================================== --- NETWORK.init +++ NETWORK.init @@ -1,3 +1,3 @@ # vim:ft=make: -NETWORK: ifconfig dhcpcd devd +NETWORK: ifconfig devd hostname Index: automountd.service ================================================================== --- automountd.service +++ automountd.service @@ -1,8 +1,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 Index: dbus.service ================================================================== --- dbus.service +++ dbus.service @@ -3,7 +3,10 @@ DAEMON_dbus_COMMAND?=/usr/local/bin/dbus-daemon DAEMON_dbus_ENABLE?=no DAEMON_dbus_FLAGS?=--system dbus: _daemon - /usr/local/bin/dbus-uuidgen --ensure - mkdir -p /var/run/dbus +.export DAEMON_$@_ENABLE + test -z "$${DAEMON_$@_ENABLE}" || { \ + /usr/local/bin/dbus-uuidgen --ensure; \ + mkdir -p /var/run/dbus; \ + } Index: devd.service ================================================================== --- devd.service +++ devd.service @@ -1,9 +1,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 -.endif +devd: _service +.export DAEMON_$@_ENABLE + test -z "$${DAEMON_$@_ENABLE}" || sysctl hw.bus.devctl_disable=1 Index: dhcpcd.service ================================================================== --- dhcpcd.service +++ dhcpcd.service @@ -2,6 +2,6 @@ DAEMON_dhcpcd_COMMAND?=/sbin/dhcpcd DAEMON_dhcpcd_ENABLE?=no DAEMON_dhcpcd_FLAGS?=-B -dhcpcd: _service mount cleanvar ifconfig +dhcpcd: _service mount cleanvar NETWORK Index: dumpon.init ================================================================== --- dumpon.init +++ dumpon.init @@ -1,9 +1,7 @@ # vim:ft=make: DUMPDEV?=no dumpon: random -.if empty(DUMPDEV:tl:Mno) : Setting dumpon device. - dumpon -v ${DUMPDEV} -.endif + test -e ${DUMPDEV} && dumpon -v ${DUMPDEV} || true Index: mountlate.init ================================================================== --- mountlate.init +++ mountlate.init @@ -1,5 +1,5 @@ # vim:ft=make: -mountlate: NETWORK mount cleanvar runshm +mountlate: NETWORK mount cleanvar runshm devd : Mount late FS. mount -a Index: node_exporter.service ================================================================== --- node_exporter.service +++ node_exporter.service @@ -6,6 +6,8 @@ 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} Index: slim.service ================================================================== --- slim.service +++ slim.service @@ -1,7 +1,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 Index: smartd.service ================================================================== --- smartd.service +++ smartd.service @@ -3,8 +3,11 @@ 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; \ + } DELETED svc.daemon Index: svc.daemon ================================================================== --- svc.daemon +++ /dev/null @@ -1,17 +0,0 @@ -# vim:ft=make: - -_daemon: DAEMON .USE -.if empty(DAEMON_$@_ENABLE:tl:Mno) -.if !empty(DAEMON_$@_MODULES) - kldload -n ${DAEMON_$@_MODULES} -.endif - svc -u ${DAEMON_$@_USER:Uroot} -g ${DAEMON_$@_GROUP:Uwheel} init $@ ${DAEMON_$@_COMMAND} ${DAEMON_$@_FLAGS} -.endif - -_service: .USE -.if empty(DAEMON_$@_ENABLE:tl:Mno) -.if !empty(DAEMON_$@_MODULES) - kldload -n ${DAEMON_$@_MODULES} -.endif - svc -u ${DAEMON_$@_USER:Uroot} -g ${DAEMON_$@_GROUP:Uwheel} init $@ ${DAEMON_$@_COMMAND} ${DAEMON_$@_FLAGS} -.endif ADDED svc.daemon.mk Index: svc.daemon.mk ================================================================== --- /dev/null +++ svc.daemon.mk @@ -0,0 +1,25 @@ +LOCAL_TARGETS:=_daemon_svc _service_svc +OTHER_TARGETS+=${LOCAL_TARGETS} +.if ${DAEMONIZER} == "svc" +LOCAL_TARGETS:=${LOCAL_TARGETS} ${LOCAL_TARGETS:S/_svc//} +.endif + +.for target in ${LOCAL_TARGETS} +${target}: ${target:M_daemon:DDAEMON} .USE +#.export DAEMON_$@_ENABLE + env | grep $@ + test -z "$${DAEMON_$@_ENABLE}" || { \ + test -n "${DAEMON_$@_MODULES}" && kldload -n ${DAEMON_$@_MODULES} || true; \ + svc -u ${DAEMON_$@_USER:Uroot} -g ${DAEMON_$@_GROUP:Uwheel} init $@ ${DAEMON_$@_COMMAND} ${DAEMON_$@_FLAGS}; \ + } +.endfor + +#_service: .USE +#.export DAEMON_$@_ENABLE +# env | grep $@ +# test -z "$${DAEMON_$@_ENABLE}" || { \ +# test -n "${DAEMON_$@_MODULES}" && kldload -n ${DAEMON_$@_MODULES} || true; \ +# svc -u ${DAEMON_$@_USER:Uroot} -g ${DAEMON_$@_GROUP:Uwheel} init $@ ${DAEMON_$@_COMMAND} ${DAEMON_$@_FLAGS}; \ +# } + +.undef LOCAL_TARGETS Index: syslogd.service ================================================================== --- syslogd.service +++ syslogd.service @@ -1,6 +1,7 @@ # vim:ft=make: DAEMON_syslogd_COMMAND?=/usr/sbin/syslogd +DAEMON_syslogd_ENABLE?=yes DAEMON_syslogd_FLAGS?=-ss8cc syslogd: _service