#!/bin/sh

. /usr/share/libubox/jshn.sh

ETH_INFO_FILE="/tmp/cache/systeminfo/ethinfo.info"
BOARD_DATA_FILE="/tmp/cache/systeminfo/boarddata.info"
DETWAN_CONF="/etc/detwan.conf"

print_detwan_conf()
{
cat <<EOF
detwan_pptp_hostname $1
detwan_lan_ifname $2
detwan_ppp_ifname $3
wan_hostname $1
wan_factory_mac $4
EOF
}

[ -d "/tmp/cache/cdless" ] || mkdir /tmp/cache/cdless

json_load "`cat $ETH_INFO_FILE`"
json_get_vars lan_net_if ppp_net_if
json_load "`cat $BOARD_DATA_FILE`"
json_get_var wan_mac "wan_mac"
json_get_var host "model_id"

print_detwan_conf $host $lan_net_if $ppp_net_if $wan_mac > $DETWAN_CONF
