1#!/bin/sh 2# 3# $NetBSD: ipsec,v 1.11 2008/11/22 20:23:33 tsutsui Exp $ 4# 5 6# PROVIDE: ipsec 7# REQUIRE: root bootconf mountcritlocal tty 8# BEFORE: DAEMON 9 10$_rc_subr_loaded . /etc/rc.subr 11 12name="ipsec" 13rcvar=$name 14start_precmd="ipsec_prestart" 15start_cmd="ipsec_start" 16stop_precmd="test -f /etc/ipsec.conf" 17stop_cmd="ipsec_stop" 18reload_cmd="ipsec_reload" 19extra_commands="reload" 20 21ipsec_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 32ipsec_start() 33{ 34 echo "Installing ipsec manual keys/policies." 35 /sbin/setkey -f /etc/ipsec.conf 36} 37 38ipsec_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 50ipsec_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 58load_rc_config $name 59run_rc_command "$1" 60