Home | History | Annotate | Line # | Download | only in rc.d
ipsec revision 1.9
      1 #!/bin/sh
      2 #
      3 # $NetBSD: ipsec,v 1.9 2007/04/06 14:20:17 apb Exp $
      4 #
      5 
      6 # PROVIDE: ipsec
      7 # REQUIRE: root beforenetlkm mountcritlocal tty
      8 # BEFORE:  DAEMON
      9 
     10 #	it does not really require beforenetlkm.
     11 
     12 $_rc_subr_loaded . /etc/rc.subr
     13 
     14 name="ipsec"
     15 rcvar=$name
     16 start_precmd="ipsec_prestart"
     17 start_cmd="ipsec_start"
     18 stop_precmd="test -f /etc/ipsec.conf"
     19 stop_cmd="ipsec_stop"
     20 reload_cmd="ipsec_reload"
     21 extra_commands="reload"
     22 
     23 ipsec_prestart()
     24 {
     25 	if [ ! -f /etc/ipsec.conf ]; then
     26 		warn "/etc/ipsec.conf not readable; ipsec start aborted."
     27 
     28 		stop_boot
     29 		return 1
     30 	fi
     31 	return 0
     32 }
     33 
     34 ipsec_start()
     35 {
     36 	echo "Installing ipsec manual keys/policies."
     37 	/sbin/setkey -f /etc/ipsec.conf
     38 }
     39 
     40 ipsec_stop()
     41 {
     42 	echo "Clearing ipsec manual keys/policies."
     43 
     44 	# still not 100% sure if we would like to do this.
     45 	# it is very questionable to do this during shutdown session, since
     46 	# it can hang any of remaining IPv4/v6 session.
     47 	#
     48 	/sbin/setkey -F
     49 	/sbin/setkey -FP
     50 }
     51 
     52 ipsec_reload()
     53 {
     54 	echo "Reloading ipsec manual keys/policies."
     55 	/sbin/setkey -F
     56 	/sbin/setkey -FP
     57 	/sbin/setkey -f /etc/ipsec.conf
     58 }
     59 
     60 load_rc_config $name
     61 run_rc_command "$1"
     62