#!/bin/sh 

upgrade_hwnat_config()
{
	hwnat=`ls /etc/config/ | grep hwnat`
	if [ -z "$hwnat" ]; then
		return
	fi

	hnat_sens_table=`uci -c /etc/profile.d show profile.@hwnat[0] | sed '1d' | cut -d "." -f 3 | cut -d "=" -f 1 `
	if [ -n "$hnat_sens_table" ]; then
		hwnat_module=`cat /etc/config/hwnat | grep "config hwnat 'module'"`
		if [ -z "$hwnat_module" ]; then
			uci set hwnat.module=hwnat
		fi

		for sens_module in ${hnat_sens_table}
		do
			tmp_module=`uci get hwnat.module.${sens_module}`
			if [ ! -n "$tmp_module" ] ;then
				uci set hwnat.module.${sens_module}=0
			fi
		done
		uci commit hwnat
	fi
}

upgrade_config()
{
	upgrade_hwnat_config
}

upgrade_config
