Home | History | Annotate | Line # | Download | only in rc.d
postfix revision 1.13
      1   1.1   thorpej #!/bin/sh
      2   1.1   thorpej #
      3  1.13  christos # $NetBSD: postfix,v 1.13 2006/09/07 15:26:08 christos Exp $
      4   1.1   thorpej #
      5   1.1   thorpej 
      6   1.1   thorpej # PROVIDE: mail
      7   1.1   thorpej # REQUIRE: LOGIN
      8   1.6     lukem #	we make mail start late, so that things like .forward's are not
      9   1.6     lukem #	processed until the system is fully operational
     10   1.1   thorpej 
     11   1.9   mycroft $_rc_subr_loaded . /etc/rc.subr
     12   1.1   thorpej 
     13   1.3     lukem name="postfix"
     14   1.5     lukem rcvar=$name
     15   1.8     lukem postfix_command="/usr/sbin/${name}"
     16   1.3     lukem required_files="/etc/${name}/main.cf"
     17   1.6     lukem start_precmd="postfix_precmd"
     18   1.8     lukem start_cmd="postfix_op"
     19   1.8     lukem stop_cmd="postfix_op"
     20   1.8     lukem reload_cmd="postfix_op"
     21   1.5     lukem extra_commands="reload"
     22   1.6     lukem spooletcdir="/var/spool/${name}/etc"
     23  1.13  christos postconf="/usr/sbin/postconf"
     24   1.6     lukem required_dirs=$spooletcdir
     25  1.12  christos 
     26  1.12  christos _rebuild() {
     27  1.12  christos 	echo "${name}: rebuilding ${1} ($2 ${1}.db)"
     28  1.13  christos 	$($postconf -h newaliases_path)
     29  1.12  christos }
     30   1.6     lukem 
     31   1.6     lukem postfix_precmd()
     32   1.6     lukem {
     33   1.6     lukem 	# As this is called after the is_running and required_dir checks
     34   1.6     lukem 	# are made in run_rc_command(), we can safely assume ${spooletcdir}
     35   1.6     lukem 	# exists and postfix isn't running at this point (unless forcestart
     36   1.6     lukem 	# is used).
     37   1.6     lukem 	#
     38   1.6     lukem 
     39   1.6     lukem 	for f in localtime resolv.conf services; do
     40   1.6     lukem 		if [ -f /etc/$f ]; then
     41   1.6     lukem 			cmp -s /etc/$f ${spooletcdir}/$f || \
     42   1.6     lukem 			    cp -p /etc/$f ${spooletcdir}/$f
     43   1.6     lukem 		fi
     44   1.6     lukem 	done
     45  1.10  christos 
     46  1.13  christos 	for f in $($postconf -h alias_database); do
     47  1.12  christos 		OIFS="${IFS}"
     48  1.12  christos 		IFS="${IFS}:"
     49  1.12  christos 		set -- $f
     50  1.12  christos 		IFS="${OIFS}"
     51  1.12  christos 		case "$1" in
     52  1.12  christos 		hash)
     53  1.12  christos 			if [ -f "$2.db" ]; then
     54  1.12  christos 				if [ ! "$2" -ot "$2.db" ]; then
     55  1.12  christos 					_rebuild "$2" "out of date"
     56  1.12  christos 				fi
     57  1.12  christos 			else
     58  1.12  christos 				_rebuild "$2" "missing"
     59  1.11  christos 			fi
     60  1.12  christos 			;;
     61  1.12  christos 		*)
     62  1.12  christos 			;;
     63  1.12  christos 		esac
     64  1.11  christos 	done
     65   1.6     lukem }
     66   1.1   thorpej 
     67   1.8     lukem postfix_op()
     68   1.8     lukem {
     69   1.8     lukem 	${postfix_command} ${rc_arg}
     70   1.8     lukem }
     71   1.8     lukem 
     72   1.4     lukem load_rc_config $name
     73   1.3     lukem run_rc_command "$1"
     74