#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
# Copyright (C) 2010 Vertical Communications

pi_replace_wifidatfile_for_LU() {
	DAT_FILE_2G_PATH="/etc/wireless/mediatek/mt7981.dbdc.b0.dat"
	DAT_FILE_5G_PATH="/etc/wireless/mediatek/mt7981.dbdc.b1.dat"

	if [ x"$(bdinfo country)" = x"LU" ]; then
		if [ -f "${DAT_FILE_5G_PATH}" ]; then
			if grep -q "SKUenable=0" "${DAT_FILE_5G_PATH}"; then
				sed -i "s/SKUenable=0/SKUenable=1/g" ${DAT_FILE_5G_PATH}
			fi

			if grep -q "BFBACKOFFenable=0" "${DAT_FILE_5G_PATH}"; then
				sed -i "s/BFBACKOFFenable=0/BFBACKOFFenable=1/g" ${DAT_FILE_5G_PATH}
			fi
		fi

		if [ -f "${DAT_FILE_2G_PATH}" ]; then
			if grep -q "SKUenable=0" "${DAT_FILE_2G_PATH}"; then
				sed -i "s/SKUenable=0/SKUenable=1/g" ${DAT_FILE_2G_PATH}
			fi

			if grep -q "BFBACKOFFenable=0" "${DAT_FILE_2G_PATH}"; then
				sed -i "s/BFBACKOFFenable=0/BFBACKOFFenable=1/g" ${DAT_FILE_2G_PATH}
			fi
		fi
	fi
}

boot_hook_add preinit_main pi_replace_wifidatfile_for_LU

