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
|
2007-04-02 22:53:07 +00:00
|
|
|
# REQUIRE: root FILESYSTEMS
|
2005-10-12 22:14:44 +00:00
|
|
|
# BEFORE: DAEMON mountcritremote
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail
|
2001-06-16 07:16:14 +00:00
|
|
|
|
|
|
|
. /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"
|
2006-01-24 15:11:11 +00:00
|
|
|
stop_precmd="test -f $ipsec_file"
|
2001-06-16 07:16:14 +00:00
|
|
|
stop_cmd="ipsec_stop"
|
|
|
|
reload_cmd="ipsec_reload"
|
|
|
|
extra_commands="reload"
|
2005-10-12 21:40:41 +00:00
|
|
|
ipsec_program="/sbin/setkey"
|
2004-01-17 10:40:45 +00:00
|
|
|
# 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_file"
|
2001-06-16 07:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|