xref: /freebsd/contrib/blocklist/etc/rc.d/blacklistd (revision 5f4c09dd85bff675e0ca63c55ea3c517e0fddfcc)
1#!/bin/sh
2#
3# $NetBSD: blacklistd,v 1.2 2016/10/17 22:47:16 christos Exp $
4#
5
6# PROVIDE: blacklistd
7# REQUIRE: npf
8# BEFORE:  SERVERS
9
10$_rc_subr_loaded . /etc/rc.subr
11
12name="blacklistd"
13rcvar=$name
14command="/sbin/${name}"
15pidfile="/var/run/${name}.pid"
16required_files="/etc/${name}.conf"
17start_precmd="${name}_precmd"
18extra_commands="reload"
19
20_sockfile="/var/run/${name}.sockets"
21_sockname="blacklistd.sock"
22
23blacklistd_precmd()
24{
25	#	Create default list of blacklistd sockets to watch
26	#
27	( umask 022 ; > $_sockfile )
28
29	#	Find /etc/rc.d scripts with "chrootdir" rcorder(8) keyword,
30	#	and if $${app}_chrootdir is a directory, add appropriate
31	#	blacklistd socket to list of sockets to watch.
32	#
33	for _lr in $(rcorder -k chrootdir /etc/rc.d/*); do
34	    (
35		_l=${_lr##*/}
36		load_rc_config ${_l}
37		eval _ldir=\$${_l}_chrootdir
38		if checkyesno $_l && [ -n "$_ldir" ]; then
39			echo "${_ldir}/var/run/${_sockname}" >> $_sockfile
40		fi
41	    )
42	done
43
44	#	If other sockets have been provided, change run_rc_command()'s
45	#	internal copy of $blacklistd_flags to force use of specific
46	#	blacklistd sockets.
47	#
48	if [ -s $_sockfile ]; then
49		echo "/var/run/${_sockname}" >> $_sockfile
50		rc_flags="-P $_sockfile $rc_flags"
51	fi
52
53	return 0
54}
55
56load_rc_config $name
57run_rc_command "$1"
58