Expand PMF_FN_* macros.
[netbsd-mini2440.git] / etc / rc.d / postfix
blobe24dec643faf4b33512c88720dc33c7aa54d3b5a
1 #!/bin/sh
3 # $NetBSD: postfix,v 1.15 2009/04/15 22:03:54 perry Exp $
6 # PROVIDE: mail
7 # REQUIRE: LOGIN
8 # we make mail start late, so that things like .forward's are not
9 # processed until the system is fully operational
11 $_rc_subr_loaded . /etc/rc.subr
13 name="postfix"
14 rcvar=$name
15 postfix_command="/usr/sbin/${name}"
16 required_files="/etc/${name}/main.cf"
17 start_precmd="postfix_precmd"
18 start_cmd="postfix_op"
19 stop_cmd="postfix_op"
20 reload_cmd="postfix_op"
21 extra_commands="reload"
22 spooletcdir="/var/spool/${name}/etc"
23 postconf="/usr/sbin/postconf"
24 required_dirs=$spooletcdir
26 _rebuild() {
27 echo "${name}: rebuilding ${1} ($2 ${1}.db)"
28 $($postconf -h newaliases_path)
31 postfix_precmd()
33 # As this is called after the is_running and required_dir checks
34 # are made in run_rc_command(), we can safely assume ${spooletcdir}
35 # exists and postfix isn't running at this point (unless forcestart
36 # is used).
39 for f in localtime resolv.conf services; do
40 if [ -f /etc/$f ]; then
41 cmp -s /etc/$f ${spooletcdir}/$f || \
42 cp -p /etc/$f ${spooletcdir}/$f
44 done
46 for f in $($postconf -h alias_database); do
47 OIFS="${IFS}"
48 IFS="${IFS}:"
49 set -- $f
50 IFS="${OIFS}"
51 case "$1" in
52 hash)
53 if [ -f "$2.db" ]; then
54 if [ ! "$2" -ot "$2.db" ]; then
55 _rebuild "$2" "out of date"
57 else
58 _rebuild "$2" "missing"
63 esac
64 done
67 postfix_op()
69 ${postfix_command} ${rc_arg}
72 check_use_postfix()
74 _mta_path=$(awk '/^sendmail[ \t]/{print$2}' /etc/mailer.conf)
75 _postfix_path="/usr/libexec/postfix/sendmail"
76 _sendmail_path="/usr/libexec/sendmail/sendmail"
78 if [ "${postfix}" != "check" ]; then
79 echo "${postfix}"
80 elif [ "${_mta_path}" = "${_postfix_path}" ]; then
81 echo YES
82 else
83 echo "WARNING: default postfix not used as not selected in mailer.conf" >&2
84 if [ "${_mta_path}" = "${_sendmail_path}" -a \
85 ! -x "${_mta_path}" ]; then
86 echo "WARNING: mailer.conf points to the removed sendmail" >&2
87 echo "update /etc/mailer.conf to get a working mailer configuration" >&2
89 echo NO
93 # force re-evaluation of /etc/rc.conf and resetting of $sendmail
94 _rc_conf_loaded=false
95 _rc_d_postfix=check
96 load_rc_config $name
97 unset _rc_d_postfix
98 postfix=$(check_use_postfix)
99 run_rc_command "$1"