ipsec revision 1.4
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
13name="ipsec"
14start_precmd="ipsec_prestart"
15start_cmd="ipsec_start"
16stop_precmd="checkyesno ipsec && [ -f /etc/ipsec.conf ]"
17stop_cmd="ipsec_stop"
18reload_precmd="$stop_precmd"
19reload_cmd="ipsec_reload"
20extra_commands="reload"
21
22ipsec_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
34ipsec_start()
35{
36	echo "Installing ipsec manual keys/policies."
37	/sbin/setkey -f /etc/ipsec.conf
38}
39
40ipsec_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
52ipsec_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
60load_rc_config $name
61run_rc_command "$1"
62