Home | History | Annotate | Line # | Download | only in rc.d
postfix revision 1.10
      1 #!/bin/sh
      2 #
      3 # $NetBSD: postfix,v 1.10 2006/06/18 14:05:34 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 
     25 postfix_precmd()
     26 {
     27 	# As this is called after the is_running and required_dir checks
     28 	# are made in run_rc_command(), we can safely assume ${spooletcdir}
     29 	# exists and postfix isn't running at this point (unless forcestart
     30 	# is used).
     31 	#
     32 
     33 	for f in localtime resolv.conf services; do
     34 		if [ -f /etc/$f ]; then
     35 			cmp -s /etc/$f ${spooletcdir}/$f || \
     36 			    cp -p /etc/$f ${spooletcdir}/$f
     37 		fi
     38 	done
     39 
     40 	# check modifications on /etc/mail/aliases
     41 	if [ -f "/etc/mail/aliases.db" ]; then
     42 		if [ ! "/etc/mail/aliases" -ot "/etc/mail/aliases.db" ]; then
     43 			echo \
     44 	    "${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating"
     45 			/usr/bin/newaliases
     46 		fi
     47 	else
     48 		echo \
     49 	    "${name}: /etc/mail/aliases.db not present, generating"
     50 			/usr/bin/newaliases
     51 	fi
     52 }
     53 
     54 postfix_op()
     55 {
     56 	${postfix_command} ${rc_arg}
     57 }
     58 
     59 load_rc_config $name
     60 run_rc_command "$1"
     61