#!/bin/sh

# Check if the configuration was be applied
applied=$(uci get system.@system[0].linkup_optimization 2>/dev/null)
if [ "$applied" = "1" ]; then
    exit 0
fi

# Enable packet steering
uci set network.globals.packet_steering='2'

# Configuring Firewall
uci del firewall.@zone[0].network
uci add_list firewall.@zone[0].network='lan'
uci del firewall.@zone[1].network
uci add_list firewall.@zone[1].network='wan'

# Enable HW Offload
uci set firewall.@defaults[0].synflood_protect='1'
uci set firewall.@defaults[0].flow_offloading='1'
uci set firewall.@defaults[0].flow_offloading_hw='1'

# Delete IPv6 Interface
uci del network.wan6
uci del network.wan.device

# Configure AT Command 
uci set network.wan.proto='atc'
uci set network.wan.auth='0'
uci set network.wan.pdp='IP'
uci set network.wan.atc_debug='0'
uci set network.wan.device='/dev/ttyUSB3'

# Save all configuration
uci commit

exit 0