Lines 20-50
Link Here
|
20 |
# read configuration and set defaults |
20 |
# read configuration and set defaults |
21 |
load_rc_config ${name} |
21 |
load_rc_config ${name} |
22 |
: ${dovecot_enable:="NO"} |
22 |
: ${dovecot_enable:="NO"} |
|
|
23 |
: ${dovecot_config:="%%PREFIX%%/etc/${name}.conf"} |
23 |
|
24 |
|
24 |
command="%%PREFIX%%/sbin/${name}" |
25 |
command="%%PREFIX%%/sbin/${name}" |
25 |
command_args="-c ${dovecot_config:="%%PREFIX%%/etc/${name}.conf"}" |
|
|
26 |
required_files="${dovecot_config}" |
27 |
start_precmd="start_precmd" |
26 |
start_precmd="start_precmd" |
28 |
stop_postcmd="stop_postcmd" |
27 |
stop_postcmd="stop_postcmd" |
29 |
extra_commands="restart" |
28 |
restart_cmd="restart_cmd" |
30 |
|
|
|
31 |
base_dir=$(${command} ${command_args} -a | /usr/bin/awk -F ': ' '/^base_dir:/ { print $2 }') |
32 |
login_dir=$(${command} ${command_args} -a | /usr/bin/awk -F ': ' '/^login_dir:/ { print $2 }') |
33 |
login_user=$(${command} ${command_args} -a | /usr/bin/awk -F ': ' '/^login_user:/ { print $2 }') |
34 |
|
35 |
pidfile="${base_dir}/master.pid" |
36 |
|
29 |
|
37 |
start_precmd() |
30 |
start_precmd() |
38 |
{ # Ensure runtime directories exist with correct permissions |
31 |
{ # Ensure runtime directories exist with correct permissions |
39 |
local gid |
32 |
local login_user login_gid |
40 |
gid=$(/usr/sbin/pw usershow -n "${login_user}" 2>/dev/null | /usr/bin/cut -d: -f4) |
33 |
login_user=$(${command} ${command_args} -a | /usr/bin/awk -F ': ' '/^login_user:/ { print $2 }') |
|
|
34 |
login_gid=$(/usr/sbin/pw usershow -n "${login_user}" 2>/dev/null | /usr/bin/cut -d: -f4) |
41 |
/usr/bin/install -o root -g wheel -m 0755 -d ${base_dir} |
35 |
/usr/bin/install -o root -g wheel -m 0755 -d ${base_dir} |
42 |
/usr/bin/install -o root -g ${gid} -m 0750 -d ${login_dir} |
36 |
/usr/bin/install -o root -g ${login_gid} -m 0750 -d ${login_dir} |
43 |
} |
37 |
} |
44 |
|
38 |
|
45 |
stop_postcmd() |
39 |
stop_postcmd() |
46 |
{ # Cleanup runtime directories |
40 |
{ # Cleanup runtime directories |
47 |
rm -rf ${base_dir} 2>/dev/null |
41 |
rm -rf ${login_dir} ${base_dir} 2>/dev/null |
|
|
42 |
} |
43 |
|
44 |
restart_cmd() |
45 |
{ # Overriding makes rc.subr run this once for each instance |
46 |
run_rc_command stop |
47 |
run_rc_command start |
48 |
} |
48 |
} |
49 |
|
49 |
|
50 |
run_rc_command "$1" |
50 |
# To start multiple instances of dovecot set dovecot_config to |
|
|
51 |
# a space seperated list of configuration files. |
52 |
for config in ${dovecot_config}; do |
53 |
required_files="${config}" |
54 |
command_args="-c ${config}" |
55 |
base_dir=$(${command} ${command_args} -a | /usr/bin/awk -F ': ' '/^base_dir:/ { print $2 }') |
56 |
login_dir=$(${command} ${command_args} -a | /usr/bin/awk -F ': ' '/^login_dir:/ { print $2 }') |
57 |
pidfile="${base_dir}/master.pid" |
58 |
run_rc_command "$1" |
59 |
done |