2001-06-16 07:16:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2002-06-13 22:14:37 +00:00
|
|
|
# $NetBSD: ipsec,v 1.7 2002/03/22 04:33:58 thorpej Exp $
|
|
|
|
# $FreeBSD$
|
2001-06-16 07:16:14 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: ipsec
|
2004-03-05 07:43:38 +00:00
|
|
|
# REQUIRE: root mountcritlocal
|
2002-06-13 22:14:37 +00:00
|
|
|
# BEFORE: DAEMON
|
2004-03-08 12:25:05 +00:00
|
|
|
# KEYWORD: FreeBSD nojail
|
2001-06-16 07:16:14 +00:00
|
|
|
|
|
|
|
# it does not really require beforenetlkm.
|
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="ipsec"
|
2002-06-13 22:14:37 +00:00
|
|
|
rcvar=`set_rcvar`
|
2001-06-16 07:16:14 +00:00
|
|
|
start_precmd="ipsec_prestart"
|
|
|
|
start_cmd="ipsec_start"
|
|
|
|
stop_precmd="test -f /etc/ipsec.conf"
|
|
|
|
stop_cmd="ipsec_stop"
|
|
|
|
reload_cmd="ipsec_reload"
|
|
|
|
extra_commands="reload"
|
2004-01-17 10:40:45 +00:00
|
|
|
ipsec_program="/usr/sbin/setkey"
|
|
|
|
# ipsec_file is set by rc.conf
|
2002-07-31 16:39:19 +00:00
|
|
|
|
2001-06-16 07:16:14 +00:00
|
|
|
ipsec_prestart()
|
|
|
|
{
|
2002-06-13 22:14:37 +00:00
|
|
|
if [ ! -f "$ipsec_file" ]; then
|
|
|
|
warn "$ipsec_file not readable; ipsec start aborted."
|
2001-06-16 07:16:14 +00:00
|
|
|
#
|
|
|
|
# If booting directly to multiuser, send SIGTERM to
|
|
|
|
# the parent (/etc/rc) to abort the boot
|
|
|
|
#
|
|
|
|
if [ "$autoboot" = yes ]; then
|
|
|
|
echo "ERROR: ABORTING BOOT (sending SIGTERM to parent)!"
|
|
|
|
kill -TERM $$
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
ipsec_start()
|
|
|
|
{
|
|
|
|
echo "Installing ipsec manual keys/policies."
|
2002-07-31 16:39:19 +00:00
|
|
|
${ipsec_program} -f $ipsec_file
|
2001-06-16 07:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ipsec_stop()
|
|
|
|
{
|
|
|
|
echo "Clearing ipsec manual keys/policies."
|
|
|
|
|
|
|
|
# still not 100% sure if we would like to do this.
|
|
|
|
# it is very questionable to do this during shutdown session, since
|
|
|
|
# it can hang any of remaining IPv4/v6 session.
|
|
|
|
#
|
2002-07-31 16:39:19 +00:00
|
|
|
${ipsec_program} -F
|
|
|
|
${ipsec_program} -FP
|
2001-06-16 07:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ipsec_reload()
|
|
|
|
{
|
|
|
|
echo "Reloading ipsec manual keys/policies."
|
2002-07-31 16:39:19 +00:00
|
|
|
${ipsec_program} -F
|
|
|
|
${ipsec_program} -FP
|
|
|
|
${ipsec_program} -f "$ipsec_file"
|
2001-06-16 07:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|