ipsec revision 1.8
11.1Sitojun#!/bin/sh
21.1Sitojun#
31.8Smycroft# $NetBSD: ipsec,v 1.8 2004/08/13 18:08:03 mycroft Exp $
41.1Sitojun#
51.1Sitojun
61.1Sitojun# PROVIDE: ipsec
71.1Sitojun# REQUIRE: root beforenetlkm mountcritlocal tty
81.7Sthorpej# BEFORE:  DAEMON
91.1Sitojun
101.1Sitojun#	it does not really require beforenetlkm.
111.1Sitojun
121.8Smycroft$_rc_subr_loaded . /etc/rc.subr
131.1Sitojun
141.1Sitojunname="ipsec"
151.6Slukemrcvar=$name
161.4Slukemstart_precmd="ipsec_prestart"
171.1Sitojunstart_cmd="ipsec_start"
181.6Slukemstop_precmd="test -f /etc/ipsec.conf"
191.1Sitojunstop_cmd="ipsec_stop"
201.1Sitojunreload_cmd="ipsec_reload"
211.1Sitojunextra_commands="reload"
221.1Sitojun
231.5Slukemipsec_prestart()
241.1Sitojun{
251.1Sitojun	if [ ! -f /etc/ipsec.conf ]; then
261.4Slukem		warn "/etc/ipsec.conf not readable; ipsec start aborted."
271.5Slukem			#
281.5Slukem			# If booting directly to multiuser, send SIGTERM to
291.5Slukem			# the parent (/etc/rc) to abort the boot
301.5Slukem			#
311.5Slukem		if [ "$autoboot" = yes ]; then
321.5Slukem			echo "ERROR: ABORTING BOOT (sending SIGTERM to parent)!"
331.5Slukem			kill -TERM $$
341.5Slukem			exit 1
351.5Slukem		fi
361.4Slukem		return 1
371.1Sitojun	fi
381.4Slukem	return 0
391.4Slukem}
401.4Slukem
411.4Slukemipsec_start()
421.4Slukem{
431.1Sitojun	echo "Installing ipsec manual keys/policies."
441.1Sitojun	/sbin/setkey -f /etc/ipsec.conf
451.1Sitojun}
461.1Sitojun
471.1Sitojunipsec_stop()
481.1Sitojun{
491.3Sitojun	echo "Clearing ipsec manual keys/policies."
501.1Sitojun
511.1Sitojun	# still not 100% sure if we would like to do this.
521.1Sitojun	# it is very questionable to do this during shutdown session, since
531.1Sitojun	# it can hang any of remaining IPv4/v6 session.
541.1Sitojun	#
551.1Sitojun	/sbin/setkey -F
561.1Sitojun	/sbin/setkey -FP
571.1Sitojun}
581.1Sitojun
591.1Sitojunipsec_reload()
601.1Sitojun{
611.1Sitojun	echo "Reloading ipsec manual keys/policies."
621.1Sitojun	/sbin/setkey -F
631.1Sitojun	/sbin/setkey -FP
641.1Sitojun	/sbin/setkey -f /etc/ipsec.conf
651.1Sitojun}
661.1Sitojun
671.1Sitojunload_rc_config $name
681.1Sitojunrun_rc_command "$1"
69