|
Lines 10-54
Link Here
|
| 10 |
# |
10 |
# |
| 11 |
# knot_enable="YES": Set to NO by default. |
11 |
# knot_enable="YES": Set to NO by default. |
| 12 |
# Set it to YES to enable knot. |
12 |
# Set it to YES to enable knot. |
| 13 |
# knot_config="": Set to /usr/local/etc/knot/knot.conf |
13 |
# knot_config="": Set to %%PREFIX%%/etc/knot/knot.conf |
| 14 |
# by default. |
14 |
# by default. |
|
|
15 |
# |
| 16 |
# ----------------------------------------------------------------------------- |
| 17 |
# |
| 18 |
# This script supports running multiple instances of knot. |
| 19 |
# To run additional instances link this script to something like |
| 20 |
# % ln -s knot knot_foo |
| 21 |
# and define additional knot_foo_* variables in one of |
| 22 |
# /etc/rc.conf, /etc/rc.conf.local or /etc/rc.conf.d/knot_foo |
| 23 |
# |
| 24 |
# Below NAME should be substituted with the name of this script. By default |
| 25 |
# it is knot, so read as knot_enable. If you linked the script to |
| 26 |
# knot_foo, then read as knot_foo_enable etc. |
| 27 |
# |
| 28 |
# The following variables are supported (defaults are shown). |
| 29 |
# You can place them in any of |
| 30 |
# /etc/rc.conf, /etc/rc.conf.local or /etc/rc.conf.d/NAME |
| 31 |
# |
| 32 |
# NAME_enable="NO" # set to YES to enable knot |
| 33 |
# |
| 34 |
# # optional: |
| 35 |
# NAME_config="%%PREFIX%%/etc/knot/NAME.conf" # (-c)onfig file |
| 36 |
# NAME_diruser="%%USERS%%" # /var/db/NAME and /var/run/NAME are created if they |
| 37 |
# NAME_dirgroup="%%GROUPS%%" # don't exist. These don't control the user/group knot |
| 38 |
# # runs as, the config file has a setting for that. |
| 39 |
# |
| 40 |
# You also need to set the rundir directive in the server section of the |
| 41 |
# config file to /var/run/NAME (if using a NAME other than the default) |
| 42 |
# and you will want the storage directive(s) declared in the zone section |
| 43 |
# to point to /var/db/NAME overriding the default of /var/db/knot. |
| 44 |
# |
| 45 |
# For further documentation, please see knot.conf(5). |
| 15 |
|
46 |
|
| 16 |
. /etc/rc.subr |
47 |
. /etc/rc.subr |
| 17 |
|
48 |
|
| 18 |
name=knot |
49 |
case "$0" in |
| 19 |
rcvar=knot_enable |
50 |
/etc/rc*) |
|
|
51 |
# during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown), |
| 52 |
# so get the name of the script from $_file |
| 53 |
name="$_file" |
| 54 |
;; |
| 55 |
*) |
| 56 |
name="$0" |
| 57 |
;; |
| 58 |
esac |
| 20 |
|
59 |
|
|
|
60 |
name="${name##*/}" |
| 61 |
rcvar=${name}_enable |
| 62 |
|
| 21 |
load_rc_config ${name} |
63 |
load_rc_config ${name} |
| 22 |
|
64 |
|
| 23 |
: ${knot_enable:=NO} |
65 |
eval ": \${${name}_enable:=\"NO\"}" |
| 24 |
: ${knot_config="%%PREFIX%%/etc/knot/knot.conf"} |
66 |
eval ": \${${name}_diruser:=\"%%USERS%%\"}" |
|
|
67 |
eval ": \${${name}_dirgroup:=\"%%GROUPS%%\"}" |
| 68 |
eval ": \${${name}_config:=\"%%PREFIX%%/etc/knot/${name}.conf\"}" |
| 25 |
|
69 |
|
|
|
70 |
configfile="$(eval echo \${${name}_config})" |
| 71 |
diruser="$(eval echo \${${name}_diruser})" |
| 72 |
dirgroup="$(eval echo \${${name}_dirgroup})" |
| 73 |
|
| 26 |
command=%%PREFIX%%/sbin/knotd |
74 |
command=%%PREFIX%%/sbin/knotd |
| 27 |
command_args="-c ${knot_config} -d" |
75 |
command_args="-c ${configfile} -d" |
| 28 |
control=%%PREFIX%%/sbin/knotc |
76 |
control=%%PREFIX%%/sbin/knotc |
| 29 |
pidfile=/var/run/knot/knot.pid |
77 |
pidfile=/var/run/${name}/knot.pid |
| 30 |
|
78 |
|
| 31 |
required_files=${knot_config} |
79 |
required_files=${configfile} |
| 32 |
|
80 |
|
| 33 |
extra_commands=reload |
81 |
extra_commands=reload |
| 34 |
reload_cmd="${name}_reload" |
82 |
reload_cmd="knot_reload" |
| 35 |
start_precmd="${name}_prestart" |
83 |
start_precmd="knot_prestart" |
| 36 |
|
84 |
|
| 37 |
knot_prestart() |
85 |
knot_prestart() |
| 38 |
{ |
86 |
{ |
| 39 |
if [ ! -d /var/run/knot ]; then |
87 |
if [ ! -d /var/run/${name} ]; then |
| 40 |
install -d -o %%USERS%% -g %%GROUPS%% /var/run/knot |
88 |
install -d -o ${diruser} -g ${dirgroup} /var/run/${name} |
| 41 |
fi |
89 |
fi |
| 42 |
if [ ! -d /var/db/knot ]; then |
90 |
if [ ! -d /var/db/${name} ]; then |
| 43 |
install -d -o %%USERS%% -g %%GROUPS%% /var/db/knot |
91 |
install -d -o ${diruser} -g ${dirgroup} /var/db/${name} |
| 44 |
fi |
92 |
fi |
| 45 |
${control} -c ${knot_config} checkconf |
93 |
${control} -c ${configfile} checkconf |
| 46 |
} |
94 |
} |
| 47 |
|
95 |
|
| 48 |
knot_reload() |
96 |
knot_reload() |
| 49 |
{ |
97 |
{ |
| 50 |
echo "Reloading ${name}." |
98 |
echo "Reloading ${name}." |
| 51 |
${control} -c ${knot_config} reload |
99 |
${control} -c ${configfile} reload |
| 52 |
} |
100 |
} |
| 53 |
|
101 |
|
| 54 |
run_rc_command "$1" |
102 |
run_rc_command "$1" |