Lines 22-28
Link Here
|
22 |
# You could set alternative config with |
22 |
# You could set alternative config with |
23 |
# unbound_config="/path/to/config" |
23 |
# unbound_config="/path/to/config" |
24 |
# |
24 |
# |
|
|
25 |
# A fib can be set for unbound with |
26 |
# unbound_fib=1 |
25 |
# |
27 |
# |
|
|
28 |
# Chroot dir is read from unbound_config by default but can be |
29 |
# overriden with |
30 |
# unbound_chrootdir="/my/own/path" |
31 |
# |
26 |
# Multiple profiles are supported with |
32 |
# Multiple profiles are supported with |
27 |
# |
33 |
# |
28 |
# unbound_profiles="name1 name2" |
34 |
# unbound_profiles="name1 name2" |
Lines 34-39
Link Here
|
34 |
# A fib can be set for each profile as in |
40 |
# A fib can be set for each profile as in |
35 |
# unbound_name1_fib=1 |
41 |
# unbound_name1_fib=1 |
36 |
# |
42 |
# |
|
|
43 |
# Specify custom chroot dir for each profile |
44 |
# unbound_name1_chrootdir="/path/to/chroot1" |
45 |
# |
46 |
# |
47 |
# N.B. unbound runs in chrooted enviroment with logs being sent to syslog(2) |
48 |
# Be sure to enable alternative log socket to allow continious log flow. |
49 |
# For syslogd(8) additional sockets can be configured with |
50 |
# altlog_proglist="${altlog_proglist} unbound" |
51 |
# unbound_chrootdir="%%PREFIX%%/etc/unbound" |
52 |
# |
53 |
# Please note that setting unbound_chrootdir is a MUST in this case. You must |
54 |
# create %%PREFIX%%/var/run manually also to make it actually work. |
55 |
# |
37 |
|
56 |
|
38 |
. /etc/rc.subr |
57 |
. /etc/rc.subr |
39 |
|
58 |
|
Lines 55-63
Link Here
|
55 |
esac |
74 |
esac |
56 |
} |
75 |
} |
57 |
|
76 |
|
|
|
77 |
unbound_mount_devfs() { |
78 |
if [ -z "${unbound_chrootdir}" ]; then |
79 |
return; |
80 |
fi |
81 |
echo "Mounting devfs for chroot environment ${unbound_chrootdir}" |
82 |
umount "${unbound_chrootdir}/dev" 2>/dev/null |
83 |
mkdir -p ${unbound_chrootdir}/dev |
84 |
devfs_domount ${unbound_chrootdir}/dev devfsrules_hide_all |
85 |
devfs_apply_ruleset devfsrules_unhide_basic ${unbound_chrootdir}/dev |
86 |
} |
87 |
|
88 |
unbound_poststop() { |
89 |
if [ -z "${unbound_chrootdir}" ]; then |
90 |
return; |
91 |
fi |
92 |
umount "${unbound_chrootdir}/dev" 2>/dev/null |
93 |
} |
94 |
|
95 |
|
58 |
start_precmd() |
96 |
start_precmd() |
59 |
{ |
97 |
{ |
60 |
unbound_startfib |
98 |
unbound_startfib |
|
|
99 |
unbound_mount_devfs |
61 |
|
100 |
|
62 |
echo -n "Obtaining a trust anchor.." |
101 |
echo -n "Obtaining a trust anchor.." |
63 |
if [ "${unbound_anchorflags}T" = "T" ]; then |
102 |
if [ "${unbound_anchorflags}T" = "T" ]; then |
Lines 66-72
Link Here
|
66 |
su -m unbound -c "%%PREFIX%%/sbin/unbound-anchor ${unbound_anchorflags}" |
105 |
su -m unbound -c "%%PREFIX%%/sbin/unbound-anchor ${unbound_anchorflags}" |
67 |
fi |
106 |
fi |
68 |
echo . |
107 |
echo . |
69 |
%%PREFIX%%/sbin/unbound-checkconf ${unbound_conf} > /dev/null |
108 |
%%PREFIX%%/sbin/unbound-checkconf ${unbound_config} > /dev/null |
70 |
return $? |
109 |
return $? |
71 |
} |
110 |
} |
72 |
|
111 |
|
Lines 76-82
Link Here
|
76 |
: ${unbound_config:=%%PREFIX%%/etc/unbound/unbound.conf} |
115 |
: ${unbound_config:=%%PREFIX%%/etc/unbound/unbound.conf} |
77 |
|
116 |
|
78 |
# Set PID file |
117 |
# Set PID file |
79 |
pidfile=$(%%PREFIX%%/sbin/unbound-checkconf -o pidfile %%PREFIX%%/etc/unbound/unbound.conf) |
118 |
pidfile=$(%%PREFIX%%/sbin/unbound-checkconf -o pidfile ${unbound_config}) |
80 |
|
119 |
|
81 |
required_files=${unbound_config} |
120 |
required_files=${unbound_config} |
82 |
command="%%PREFIX%%/sbin/${name}" |
121 |
command="%%PREFIX%%/sbin/${name}" |
Lines 84-91
Link Here
|
84 |
unbound_anchorflags=${unbound_anchorflags:-""} |
123 |
unbound_anchorflags=${unbound_anchorflags:-""} |
85 |
extra_commands="reload" |
124 |
extra_commands="reload" |
86 |
start_precmd="start_precmd" |
125 |
start_precmd="start_precmd" |
87 |
reload_precmd="%%PREFIX%%/sbin/unbound-checkconf ${unbound_conf} >/dev/null" |
126 |
reload_precmd="%%PREFIX%%/sbin/unbound-checkconf ${unbound_config} >/dev/null" |
|
|
127 |
stop_postcmd=unbound_poststop |
88 |
|
128 |
|
|
|
129 |
_cfgchrootdir=$(%%PREFIX%%/sbin/unbound-checkconf -o chroot ${unbound_config}) |
130 |
unbound_chrootdir=${unbound_chrootdir:-${_cfgchrootdir}} |
131 |
|
89 |
load_rc_config "${name}" |
132 |
load_rc_config "${name}" |
90 |
|
133 |
|
91 |
if [ -n "$2" ]; then |
134 |
if [ -n "$2" ]; then |
Lines 101-106
Link Here
|
101 |
# Replace default value with profile-based (defined in the config file) |
144 |
# Replace default value with profile-based (defined in the config file) |
102 |
_cfgpidfile=$(%%PREFIX%%/sbin/unbound-checkconf -o pidfile ${unbound_config}) |
145 |
_cfgpidfile=$(%%PREFIX%%/sbin/unbound-checkconf -o pidfile ${unbound_config}) |
103 |
_defaultpidfile=$(%%PREFIX%%/sbin/unbound-checkconf -o pidfile /dev/null) |
146 |
_defaultpidfile=$(%%PREFIX%%/sbin/unbound-checkconf -o pidfile /dev/null) |
|
|
147 |
_cfgchrootdir=$(%%PREFIX%%/sbin/unbound-checkconf -o chroot ${unbound_config}) |
148 |
|
149 |
eval unbound_chrootdir="\${unbound_${profile}_chrootdir:-${_cfgchrootdir}}" |
104 |
|
150 |
|
105 |
if [ "x${_cfgpidfile}" = "x" -o "x${_cfgpidfile}" = "x${_defaultpidfile}" ] ; then |
151 |
if [ "x${_cfgpidfile}" = "x" -o "x${_cfgpidfile}" = "x${_defaultpidfile}" ] ; then |
106 |
pidfile=${_defaultpidfile} |
152 |
pidfile=${_defaultpidfile} |