ipsec revision 101085
1#!/bin/sh 2# 3# $NetBSD: ipsec,v 1.7 2002/03/22 04:33:58 thorpej Exp $ 4# $FreeBSD: head/etc/rc.d/ipsec 101085 2002-07-31 16:39:19Z ume $ 5# 6 7# PROVIDE: ipsec 8# REQUIRE: root beforenetlkm mountcritlocal tty 9# BEFORE: DAEMON 10# KEYWORD: FreeBSD NetBSD 11 12# it does not really require beforenetlkm. 13 14. /etc/rc.subr 15 16name="ipsec" 17rcvar=`set_rcvar` 18# This will be overiden from rc.conf on FreeBSD. 19ipsec_file="/etc/ipsec.conf" 20start_precmd="ipsec_prestart" 21start_cmd="ipsec_start" 22stop_precmd="test -f /etc/ipsec.conf" 23stop_cmd="ipsec_stop" 24reload_cmd="ipsec_reload" 25extra_commands="reload" 26 27case `${CMD_OSTYPE}` in 28FreeBSD) 29 ipsec_program="/usr/sbin/setkey" 30 ;; 31NetBSD) 32 ipsec_program="/sbin/setkey" 33 ;; 34esac 35 36ipsec_prestart() 37{ 38 if [ ! -f "$ipsec_file" ]; then 39 warn "$ipsec_file not readable; ipsec start aborted." 40 # 41 # If booting directly to multiuser, send SIGTERM to 42 # the parent (/etc/rc) to abort the boot 43 # 44 if [ "$autoboot" = yes ]; then 45 echo "ERROR: ABORTING BOOT (sending SIGTERM to parent)!" 46 kill -TERM $$ 47 exit 1 48 fi 49 return 1 50 fi 51 return 0 52} 53 54ipsec_start() 55{ 56 echo "Installing ipsec manual keys/policies." 57 ${ipsec_program} -f $ipsec_file 58} 59 60ipsec_stop() 61{ 62 echo "Clearing ipsec manual keys/policies." 63 64 # still not 100% sure if we would like to do this. 65 # it is very questionable to do this during shutdown session, since 66 # it can hang any of remaining IPv4/v6 session. 67 # 68 ${ipsec_program} -F 69 ${ipsec_program} -FP 70} 71 72ipsec_reload() 73{ 74 echo "Reloading ipsec manual keys/policies." 75 ${ipsec_program} -F 76 ${ipsec_program} -FP 77 ${ipsec_program} -f "$ipsec_file" 78} 79 80load_rc_config $name 81run_rc_command "$1" 82