#!/bin/sh
#
# Copyright (C) 2015-2017 devolo AG
#

[ -e /etc/config/plc ] && exit 0


if [ -f /lib/ar71xx.sh ]; then
        PLATFORM=ar71xx
        . /lib/ar71xx.sh
elif [ -f /lib/ipq806x.sh ]; then
        PLATFORM=ipq806x
        . /lib/ipq806x.sh
fi

. /lib/functions/uci-defaults.sh

touch /etc/config/plc
uci set plc.plc=plc

# allow standby as default
uci set plc.plc.standby=1

board=$(${PLATFORM}_board_name)

case "$board" in
    dlan-hotspot)
        uci set plc.plc.disabled=0
        uci set plc.plc.interface=eth1
        ;;
    dlan-pro-500-wp|\
    dlan-550-wifi)
        uci set plc.plc.disabled=0
        uci set plc.plc.interface=eth0
        uci set plc.plc.individual_nmk=1
        ;;
    dlan-pro-1200-ac|\
    dlan-pro-1200-n)
        uci set plc.plc.disabled=0
        uci set plc.plc.interface=eth0
        uci set plc.plc.individual_nmk=1
        uci set plc.config=config
        uci set plc.config.PlcIfname=eth0
        uci set plc.config.AggrLinkRate=0
        uci set plc.config.Enabled=1
        ;;
    dlan-1000-ac)
	uci set plc.plc.disabled=0
	uci set plc.plc.interface=eth0
	uci set plc.plc.individual_nmk=1
        uci set plc.config=config
        uci set plc.config.PlcIfname=eth0
        uci set plc.config.AggrLinkRate=0
        uci set plc.config.Enabled=1
	;;
    devolo-home-control-cu)
        uci set plc.plc.disabled=0
        uci set plc.plc.interface=eth0
        uci set plc.plc.individual_nmk=1
        ;;
    *)
        uci set plc.plc.disabled=1
        ;;
esac

uci commit plc

exit 0