2010-11-27 05:53:35 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: dovecot
|
|
|
|
# REQUIRE: %%REQUIRE%%
|
|
|
|
# KEYWORD: shutdown
|
|
|
|
|
|
|
|
# Define dovecot_* variables in one of these files:
|
|
|
|
# /etc/rc.conf
|
|
|
|
# /etc/rc.conf.local
|
|
|
|
# /etc/rc.conf.d/dovecot
|
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name=dovecot
|
2012-01-14 08:57:23 +00:00
|
|
|
rcvar=dovecot_enable
|
2010-11-27 05:53:35 +00:00
|
|
|
|
|
|
|
# read configuration and set defaults
|
|
|
|
load_rc_config ${name}
|
|
|
|
: ${dovecot_enable:="NO"}
|
2011-02-05 16:51:50 +00:00
|
|
|
: ${dovecot_config:="%%ETCDIR%%/${name}.conf"}
|
2010-11-27 05:53:35 +00:00
|
|
|
|
|
|
|
command="%%PREFIX%%/sbin/${name}"
|
|
|
|
start_precmd="start_precmd"
|
|
|
|
stop_postcmd="stop_postcmd"
|
|
|
|
restart_cmd="restart_cmd"
|
|
|
|
|
|
|
|
start_precmd()
|
|
|
|
{ # Ensure runtime directories exist with correct permissions
|
|
|
|
local login_user login_gid
|
|
|
|
login_user=$(${command} ${command_args} -a | /usr/bin/awk -F '= ' '/^default_login_user =/ { print $2 }')
|
|
|
|
login_gid=$(/usr/sbin/pw usershow -n "${login_user}" 2>/dev/null | /usr/bin/cut -d: -f4)
|
|
|
|
/usr/bin/install -o root -g wheel -m 0755 -d ${base_dir}
|
|
|
|
}
|
|
|
|
|
|
|
|
stop_postcmd()
|
|
|
|
{ # Cleanup runtime directories
|
|
|
|
rm -rf ${base_dir} 2>/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
restart_cmd()
|
|
|
|
{ # Overriding makes rc.subr run this once for each instance
|
|
|
|
run_rc_command stop
|
|
|
|
run_rc_command start
|
|
|
|
}
|
|
|
|
|
|
|
|
# To start multiple instances of dovecot set dovecot_config to
|
|
|
|
# a space seperated list of configuration files.
|
|
|
|
if checkyesno ${name}_enable; then
|
|
|
|
for config in ${dovecot_config}; do
|
|
|
|
required_files="${config}"
|
|
|
|
command_args="-c ${config}"
|
|
|
|
base_dir=$(${command} ${command_args} -a | /usr/bin/awk -F '= ' '/^base_dir =/ { print $2 }')
|
|
|
|
pidfile="${base_dir}/master.pid"
|
|
|
|
run_rc_command "$1"
|
|
|
|
done
|
|
|
|
fi
|