#!/bin/sh

_LOGOUT_TIME="$(date "+%Y-%m-%d %H:%M:%S")"
CONFIG="luci-app-ipsec-server"
L2TP_PATH=/var/etc/xl2tpd
L2TP_SESSION_PATH=${L2TP_PATH}/session

_USERNAME=${PEERNAME}
_IFACE=${1}
_TTY=${2}
_SPEED=${3}
_LOCALIP=${4}
_PEERIP=${5}
_REMOTEIP=${6}
_BYTES_SENT=${BYTES_SENT}
_BYTES_RCVD=${BYTES_RCVD}
_CONNECT_TIME=${CONNECT_TIME}

rm -f ${L2TP_SESSION_PATH}/${_USERNAME}.${_IFACE}
rm -f /var/run/${_IFACE}.pid

#可根据退出的账号自定义脚本，如静态路由表，组网等。
SCRIPT="/usr/share/xl2tpd/ip-down.d/${_USERNAME}"
[ -s "$SCRIPT" ] && {
	[ ! -x "$SCRIPT" ] && chmod 0755 "$SCRIPT"
	"$SCRIPT" "$@"
}
