Home | History | Annotate | Line # | Download | only in rc.d
postfix revision 1.12
      1 #!/bin/sh
      2 #
      3 # $NetBSD: postfix,v 1.12 2006/09/07 14:16:55 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 _rebuild() {
     26 	echo "${name}: rebuilding ${1} ($2 ${1}.db)"
     27 	$(postconf -h newaliases_path)
     28 }
     29 
     30 postfix_precmd()
     31 {
     32 	# As this is called after the is_running and required_dir checks
     33 	# are made in run_rc_command(), we can safely assume ${spooletcdir}
     34 	# exists and postfix isn't running at this point (unless forcestart
     35 	# is used).
     36 	#
     37 
     38 	for f in localtime resolv.conf services; do
     39 		if [ -f /etc/$f ]; then
     40 			cmp -s /etc/$f ${spooletcdir}/$f || \
     41 			    cp -p /etc/$f ${spooletcdir}/$f
     42 		fi
     43 	done
     44 
     45 	for f in $(postconf -h alias_database); do
     46 		OIFS="${IFS}"
     47 		IFS="${IFS}:"
     48 		set -- $f
     49 		IFS="${OIFS}"
     50 		case "$1" in
     51 		hash)
     52 			if [ -f "$2.db" ]; then
     53 				if [ ! "$2" -ot "$2.db" ]; then
     54 					_rebuild "$2" "out of date"
     55 				fi
     56 			else
     57 				_rebuild "$2" "missing"
     58 			fi
     59 			;;
     60 		*)
     61 			;;
     62 		esac
     63 	done
     64 }
     65 
     66 postfix_op()
     67 {
     68 	${postfix_command} ${rc_arg}
     69 }
     70 
     71 load_rc_config $name
     72 run_rc_command "$1"
     73