postfix revision 1.18
11.1Sthorpej#!/bin/sh 21.1Sthorpej# 31.18Sriastrad# $NetBSD: postfix,v 1.18 2016/10/30 15:47:06 riastradh 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.18Sriastrad OIFS="${IFS}" 481.18Sriastrad IFS="${IFS}," 491.18Sriastrad for f in $($postconf -hx alias_database); do 501.18Sriastrad IFS="${OIFS}:" 511.12Schristos set -- $f 521.12Schristos IFS="${OIFS}" 531.12Schristos case "$1" in 541.12Schristos hash) 551.12Schristos if [ -f "$2.db" ]; then 561.12Schristos if [ ! "$2" -ot "$2.db" ]; then 571.12Schristos _rebuild "$2" "out of date" 581.12Schristos fi 591.12Schristos else 601.12Schristos _rebuild "$2" "missing" 611.11Schristos fi 621.12Schristos ;; 631.12Schristos *) 641.12Schristos ;; 651.12Schristos esac 661.11Schristos done 671.6Slukem} 681.1Sthorpej 691.8Slukempostfix_op() 701.8Slukem{ 711.8Slukem ${postfix_command} ${rc_arg} 721.8Slukem} 731.8Slukem 741.14Spavelcheck_use_postfix() 751.14Spavel{ 761.14Spavel _mta_path=$(awk '/^sendmail[ \t]/{print$2}' /etc/mailer.conf) 771.14Spavel _postfix_path="/usr/libexec/postfix/sendmail" 781.14Spavel _sendmail_path="/usr/libexec/sendmail/sendmail" 791.14Spavel 801.14Spavel if [ "${postfix}" != "check" ]; then 811.14Spavel echo "${postfix}" 821.14Spavel elif [ "${_mta_path}" = "${_postfix_path}" ]; then 831.14Spavel echo YES 841.14Spavel else 851.14Spavel echo "WARNING: default postfix not used as not selected in mailer.conf" >&2 861.14Spavel if [ "${_mta_path}" = "${_sendmail_path}" -a \ 871.14Spavel ! -x "${_mta_path}" ]; then 881.14Spavel echo "WARNING: mailer.conf points to the removed sendmail" >&2 891.14Spavel echo "update /etc/mailer.conf to get a working mailer configuration" >&2 901.14Spavel fi 911.14Spavel echo NO 921.14Spavel fi 931.14Spavel} 941.14Spavel 951.14Spavel# force re-evaluation of /etc/rc.conf and resetting of $sendmail 961.14Spavel_rc_conf_loaded=false 971.14Spavel_rc_d_postfix=check 981.4Slukemload_rc_config $name 991.14Spavelunset _rc_d_postfix 1001.14Spavelpostfix=$(check_use_postfix) 1011.3Slukemrun_rc_command "$1" 102