1 #!/bin/sh 2 # 3 # $NetBSD: postfix,v 1.11 2006/09/05 22:10:51 christos Exp $ 4 # 5 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 10 11 $_rc_subr_loaded . /etc/rc.subr 12 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 required_dirs=$spooletcdir 24 newaliases="/usr/bin/newaliases" 25 26 postfix_precmd() 27 { 28 # As this is called after the is_running and required_dir checks 29 # are made in run_rc_command(), we can safely assume ${spooletcdir} 30 # exists and postfix isn't running at this point (unless forcestart 31 # is used). 32 # 33 34 for f in localtime resolv.conf services; do 35 if [ -f /etc/$f ]; then 36 cmp -s /etc/$f ${spooletcdir}/$f || \ 37 cp -p /etc/$f ${spooletcdir}/$f 38 fi 39 done 40 41 for f in $(postconf -h alias_database); do 42 dbfile="${f#*:}" 43 if [ -f "${dbfile}.db" ]; then 44 if [ ! "${dbfile}" -ot "${dbfile}.db" ]; then 45 echo \ 46 "${name}: ${dbfile} newer than ${dbfile}.db, running $newaliases" 47 $newaliases 48 fi 49 else 50 echo \ 51 "${name}: ${dbfile}.db not present, running $newaliases" 52 $newaliases 53 fi 54 done 55 } 56 57 postfix_op() 58 { 59 ${postfix_command} ${rc_arg} 60 } 61 62 load_rc_config $name 63 run_rc_command "$1" 64