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