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