wait until our local address is available before configuring.

This commit is contained in:
christos 2013-09-12 19:52:50 +00:00
parent 8fc5f922fd
commit 8f0c389494

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# $NetBSD: ipsec,v 1.12 2013/06/14 16:37:55 christos Exp $
# $NetBSD: ipsec,v 1.13 2013/09/12 19:52:50 christos Exp $
#
# PROVIDE: ipsec
@ -37,14 +37,33 @@ ipsec_getip() {
done
}
ipsec_load() {
if [ -z "$1" ]; then
/sbin/setkey -f /etc/ipsec.conf
else
sed -e "s/@LOCAL_ADDR@/$1/" < /etc/ipsec.conf | \
/sbin/setkey -f -
fi
}
ipsec_configure() {
while true; do
local addr="$(ipsec_getip "$ipsec_flags")"
case "$addr" in
'') sleep 1;;
"0.0.0.0") sleep 1;;
*) ipsec_load "$addr"; return;;
esac
done &
}
ipsec_start()
{
echo "Installing ipsec manual keys/policies."
if [ -n "$ipsec_flags" ]; then
sed -e "s/@LOCAL_ADDR@/$(ipsec_getip "$ipsec_flags")/" \
< /etc/ipsec.conf | /sbin/setkey -f -
ipsec_configure
else
/sbin/setkey -f /etc/ipsec.conf
ipsec_load
fi
}