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
|
|
|
|
# REQUIRE: root beforenetlkm mountcritlocal tty
|
2002-06-13 22:14:37 +00:00
|
|
|
# BEFORE: DAEMON
|
|
|
|
# KEYWORD: FreeBSD NetBSD
|
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`
|
|
|
|
# This will be overiden from rc.conf on FreeBSD.
|
|
|
|
ipsec_file="/etc/ipsec.conf"
|
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"
|
|
|
|
|
2002-09-06 16:18:05 +00:00
|
|
|
case ${OSTYPE} in
|
2002-07-31 16:39:19 +00:00
|
|
|
FreeBSD)
|
|
|
|
ipsec_program="/usr/sbin/setkey"
|
|
|
|
;;
|
|
|
|
NetBSD)
|
|
|
|
ipsec_program="/sbin/setkey"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
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"
|