NetBSD/etc/rc.d/postfix
2006-06-18 14:05:34 +00:00

61 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
#
# $NetBSD: postfix,v 1.10 2006/06/18 14:05:34 christos Exp $
#
# PROVIDE: mail
# REQUIRE: LOGIN
# we make mail start late, so that things like .forward's are not
# processed until the system is fully operational
$_rc_subr_loaded . /etc/rc.subr
name="postfix"
rcvar=$name
postfix_command="/usr/sbin/${name}"
required_files="/etc/${name}/main.cf"
start_precmd="postfix_precmd"
start_cmd="postfix_op"
stop_cmd="postfix_op"
reload_cmd="postfix_op"
extra_commands="reload"
spooletcdir="/var/spool/${name}/etc"
required_dirs=$spooletcdir
postfix_precmd()
{
# As this is called after the is_running and required_dir checks
# are made in run_rc_command(), we can safely assume ${spooletcdir}
# exists and postfix isn't running at this point (unless forcestart
# is used).
#
for f in localtime resolv.conf services; do
if [ -f /etc/$f ]; then
cmp -s /etc/$f ${spooletcdir}/$f || \
cp -p /etc/$f ${spooletcdir}/$f
fi
done
# check modifications on /etc/mail/aliases
if [ -f "/etc/mail/aliases.db" ]; then
if [ ! "/etc/mail/aliases" -ot "/etc/mail/aliases.db" ]; then
echo \
"${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating"
/usr/bin/newaliases
fi
else
echo \
"${name}: /etc/mail/aliases.db not present, generating"
/usr/bin/newaliases
fi
}
postfix_op()
{
${postfix_command} ${rc_arg}
}
load_rc_config $name
run_rc_command "$1"