1 #!/bin/sh 2 # 3 # $NetBSD: ipsec,v 1.4 2000/07/17 13:10:54 lukem Exp $ 4 # 5 6 # PROVIDE: ipsec 7 # REQUIRE: root beforenetlkm mountcritlocal tty 8 9 # it does not really require beforenetlkm. 10 11 . /etc/rc.subr 12 13 name="ipsec" 14 start_precmd="ipsec_prestart" 15 start_cmd="ipsec_start" 16 stop_precmd="checkyesno ipsec && [ -f /etc/ipsec.conf ]" 17 stop_cmd="ipsec_stop" 18 reload_precmd="$stop_precmd" 19 reload_cmd="ipsec_reload" 20 extra_commands="reload" 21 22 ipsec_start() 23 { 24 if ! checkyesno ipsec; then 25 return 1 26 fi 27 if [ ! -f /etc/ipsec.conf ]; then 28 warn "/etc/ipsec.conf not readable; ipsec start aborted." 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