postfix revision 1.17
11.1Sthorpej#!/bin/sh 21.1Sthorpej# 31.17Sriz# $NetBSD: postfix,v 1.17 2015/07/23 17:12:16 riz Exp $ 41.1Sthorpej# 51.1Sthorpej 61.16Sperry# 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.17Srizstatus_cmd="postfix_op" 221.17Srizextra_commands="reload status" 231.6Slukemspooletcdir="/var/spool/${name}/etc" 241.13Schristospostconf="/usr/sbin/postconf" 251.6Slukemrequired_dirs=$spooletcdir 261.12Schristos 271.12Schristos_rebuild() { 281.12Schristos echo "${name}: rebuilding ${1} ($2 ${1}.db)" 291.13Schristos $($postconf -h newaliases_path) 301.12Schristos} 311.6Slukem 321.6Slukempostfix_precmd() 331.6Slukem{ 341.6Slukem # As this is called after the is_running and required_dir checks 351.6Slukem # are made in run_rc_command(), we can safely assume ${spooletcdir} 361.6Slukem # exists and postfix isn't running at this point (unless forcestart 371.6Slukem # is used). 381.6Slukem # 391.6Slukem 401.6Slukem for f in localtime resolv.conf services; do 411.6Slukem if [ -f /etc/$f ]; then 421.6Slukem cmp -s /etc/$f ${spooletcdir}/$f || \ 431.6Slukem cp -p /etc/$f ${spooletcdir}/$f 441.6Slukem fi 451.6Slukem done 461.10Schristos 471.13Schristos for f in $($postconf -h alias_database); do 481.12Schristos OIFS="${IFS}" 491.12Schristos IFS="${IFS}:" 501.12Schristos set -- $f 511.12Schristos IFS="${OIFS}" 521.12Schristos case "$1" in 531.12Schristos hash) 541.12Schristos if [ -f "$2.db" ]; then 551.12Schristos if [ ! "$2" -ot "$2.db" ]; then 561.12Schristos _rebuild "$2" "out of date" 571.12Schristos fi 581.12Schristos else 591.12Schristos _rebuild "$2" "missing" 601.11Schristos fi 611.12Schristos ;; 621.12Schristos *) 631.12Schristos ;; 641.12Schristos esac 651.11Schristos done 661.6Slukem} 671.1Sthorpej 681.8Slukempostfix_op() 691.8Slukem{ 701.8Slukem ${postfix_command} ${rc_arg} 711.8Slukem} 721.8Slukem 731.14Spavelcheck_use_postfix() 741.14Spavel{ 751.14Spavel _mta_path=$(awk '/^sendmail[ \t]/{print$2}' /etc/mailer.conf) 761.14Spavel _postfix_path="/usr/libexec/postfix/sendmail" 771.14Spavel _sendmail_path="/usr/libexec/sendmail/sendmail" 781.14Spavel 791.14Spavel if [ "${postfix}" != "check" ]; then 801.14Spavel echo "${postfix}" 811.14Spavel elif [ "${_mta_path}" = "${_postfix_path}" ]; then 821.14Spavel echo YES 831.14Spavel else 841.14Spavel echo "WARNING: default postfix not used as not selected in mailer.conf" >&2 851.14Spavel if [ "${_mta_path}" = "${_sendmail_path}" -a \ 861.14Spavel ! -x "${_mta_path}" ]; then 871.14Spavel echo "WARNING: mailer.conf points to the removed sendmail" >&2 881.14Spavel echo "update /etc/mailer.conf to get a working mailer configuration" >&2 891.14Spavel fi 901.14Spavel echo NO 911.14Spavel fi 921.14Spavel} 931.14Spavel 941.14Spavel# force re-evaluation of /etc/rc.conf and resetting of $sendmail 951.14Spavel_rc_conf_loaded=false 961.14Spavel_rc_d_postfix=check 971.4Slukemload_rc_config $name 981.14Spavelunset _rc_d_postfix 991.14Spavelpostfix=$(check_use_postfix) 1001.3Slukemrun_rc_command "$1" 101