#!/bin/sh

. /etc/init.d/utils

if [ "$trusted_ip" != "" ]; then
    peer="$trusted_ip"
else
    peer="$remote_1"
fi

if [ "tap0" != "$1" ]; then
    error "Interface mismatch in openvpn-up ($1 != tap0)"
    exit 1
fi

if [ ! -e /etc/default/softbridge/lan1 ]; then
    error "lan1 is not a bridge interface"
    exit 1
fi

/usr/sbin/brctl addif lan1 tap0
/sbin/ifconfig tap0 0.0.0.0 promisc up

# call main up
/usr/local/sbin/www-scripts/openvpn/tunnel-up "0" "tap0" "client" "$peer"
exit 0
