postfix revision 1.12
11.1Sthorpej#!/bin/sh 21.1Sthorpej# 31.12Schristos# $NetBSD: postfix,v 1.12 2006/09/07 14:16:55 christos Exp $ 41.1Sthorpej# 51.1Sthorpej 61.1Sthorpej# PROVIDE: mail 71.1Sthorpej# REQUIRE: LOGIN 81.6Slukem# we make mail start late, so that things like .forward's are not 91.6Slukem# processed until the system is fully operational 101.1Sthorpej 111.9Smycroft$_rc_subr_loaded . /etc/rc.subr 121.1Sthorpej 131.3Slukemname="postfix" 141.5Slukemrcvar=$name 151.8Slukempostfix_command="/usr/sbin/${name}" 161.3Slukemrequired_files="/etc/${name}/main.cf" 171.6Slukemstart_precmd="postfix_precmd" 181.8Slukemstart_cmd="postfix_op" 191.8Slukemstop_cmd="postfix_op" 201.8Slukemreload_cmd="postfix_op" 211.5Slukemextra_commands="reload" 221.6Slukemspooletcdir="/var/spool/${name}/etc" 231.6Slukemrequired_dirs=$spooletcdir 241.12Schristos 251.12Schristos_rebuild() { 261.12Schristos echo "${name}: rebuilding ${1} ($2 ${1}.db)" 271.12Schristos $(postconf -h newaliases_path) 281.12Schristos} 291.6Slukem 301.6Slukempostfix_precmd() 311.6Slukem{ 321.6Slukem # As this is called after the is_running and required_dir checks 331.6Slukem # are made in run_rc_command(), we can safely assume ${spooletcdir} 341.6Slukem # exists and postfix isn't running at this point (unless forcestart 351.6Slukem # is used). 361.6Slukem # 371.6Slukem 381.6Slukem for f in localtime resolv.conf services; do 391.6Slukem if [ -f /etc/$f ]; then 401.6Slukem cmp -s /etc/$f ${spooletcdir}/$f || \ 411.6Slukem cp -p /etc/$f ${spooletcdir}/$f 421.6Slukem fi 431.6Slukem done 441.10Schristos 451.11Schristos for f in $(postconf -h alias_database); do 461.12Schristos OIFS="${IFS}" 471.12Schristos IFS="${IFS}:" 481.12Schristos set -- $f 491.12Schristos IFS="${OIFS}" 501.12Schristos case "$1" in 511.12Schristos hash) 521.12Schristos if [ -f "$2.db" ]; then 531.12Schristos if [ ! "$2" -ot "$2.db" ]; then 541.12Schristos _rebuild "$2" "out of date" 551.12Schristos fi 561.12Schristos else 571.12Schristos _rebuild "$2" "missing" 581.11Schristos fi 591.12Schristos ;; 601.12Schristos *) 611.12Schristos ;; 621.12Schristos esac 631.11Schristos done 641.6Slukem} 651.1Sthorpej 661.8Slukempostfix_op() 671.8Slukem{ 681.8Slukem ${postfix_command} ${rc_arg} 691.8Slukem} 701.8Slukem 711.4Slukemload_rc_config $name 721.3Slukemrun_rc_command "$1" 73