Home | History | Annotate | Line # | Download | only in rc.d
ipsec revision 1.8
      1  1.1   itojun #!/bin/sh
      2  1.1   itojun #
      3  1.8  mycroft # $NetBSD: ipsec,v 1.8 2004/08/13 18:08:03 mycroft Exp $
      4  1.1   itojun #
      5  1.1   itojun 
      6  1.1   itojun # PROVIDE: ipsec
      7  1.1   itojun # REQUIRE: root beforenetlkm mountcritlocal tty
      8  1.7  thorpej # BEFORE:  DAEMON
      9  1.1   itojun 
     10  1.1   itojun #	it does not really require beforenetlkm.
     11  1.1   itojun 
     12  1.8  mycroft $_rc_subr_loaded . /etc/rc.subr
     13  1.1   itojun 
     14  1.1   itojun name="ipsec"
     15  1.6    lukem rcvar=$name
     16  1.4    lukem start_precmd="ipsec_prestart"
     17  1.1   itojun start_cmd="ipsec_start"
     18  1.6    lukem stop_precmd="test -f /etc/ipsec.conf"
     19  1.1   itojun stop_cmd="ipsec_stop"
     20  1.1   itojun reload_cmd="ipsec_reload"
     21  1.1   itojun extra_commands="reload"
     22  1.1   itojun 
     23  1.5    lukem ipsec_prestart()
     24  1.1   itojun {
     25  1.1   itojun 	if [ ! -f /etc/ipsec.conf ]; then
     26  1.4    lukem 		warn "/etc/ipsec.conf not readable; ipsec start aborted."
     27  1.5    lukem 			#
     28  1.5    lukem 			# If booting directly to multiuser, send SIGTERM to
     29  1.5    lukem 			# the parent (/etc/rc) to abort the boot
     30  1.5    lukem 			#
     31  1.5    lukem 		if [ "$autoboot" = yes ]; then
     32  1.5    lukem 			echo "ERROR: ABORTING BOOT (sending SIGTERM to parent)!"
     33  1.5    lukem 			kill -TERM $$
     34  1.5    lukem 			exit 1
     35  1.5    lukem 		fi
     36  1.4    lukem 		return 1
     37  1.1   itojun 	fi
     38  1.4    lukem 	return 0
     39  1.4    lukem }
     40  1.4    lukem 
     41  1.4    lukem ipsec_start()
     42  1.4    lukem {
     43  1.1   itojun 	echo "Installing ipsec manual keys/policies."
     44  1.1   itojun 	/sbin/setkey -f /etc/ipsec.conf
     45  1.1   itojun }
     46  1.1   itojun 
     47  1.1   itojun ipsec_stop()
     48  1.1   itojun {
     49  1.3   itojun 	echo "Clearing ipsec manual keys/policies."
     50  1.1   itojun 
     51  1.1   itojun 	# still not 100% sure if we would like to do this.
     52  1.1   itojun 	# it is very questionable to do this during shutdown session, since
     53  1.1   itojun 	# it can hang any of remaining IPv4/v6 session.
     54  1.1   itojun 	#
     55  1.1   itojun 	/sbin/setkey -F
     56  1.1   itojun 	/sbin/setkey -FP
     57  1.1   itojun }
     58  1.1   itojun 
     59  1.1   itojun ipsec_reload()
     60  1.1   itojun {
     61  1.1   itojun 	echo "Reloading ipsec manual keys/policies."
     62  1.1   itojun 	/sbin/setkey -F
     63  1.1   itojun 	/sbin/setkey -FP
     64  1.1   itojun 	/sbin/setkey -f /etc/ipsec.conf
     65  1.1   itojun }
     66  1.1   itojun 
     67  1.1   itojun load_rc_config $name
     68  1.1   itojun run_rc_command "$1"
     69