add default alias to display a user friendly interface name
This commit is contained in:
parent
640196c5b3
commit
47a61c03d2
@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
||||
PKG_NAME:=luci-app-qmodem-mwan
|
||||
LUCI_TITLE:=Luci qwrt modem mwan support
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=2.4.1
|
||||
PKG_VERSION:=2.4.4
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_LINCESE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=Tom <fjrcn@outlook.com>
|
||||
|
@ -16,11 +16,12 @@ modem_settings()
|
||||
uci commit qmodem_mwan
|
||||
;;
|
||||
huasifei,ws3006)
|
||||
add_ipv4_config "2_1_2"
|
||||
add_ipv4_config "2_1_4"
|
||||
add_ipv4_config "1_1_1"
|
||||
add_ipv4_config "1_1_2"
|
||||
add_ipv4_config "1_1_3"
|
||||
add_ipv4_config "5g0"
|
||||
add_ipv4_config "5g1"
|
||||
add_ipv4_config "4g0"
|
||||
add_ipv4_config "4g1"
|
||||
add_ipv4_config "4g2"
|
||||
add_ipv4_config "4g3"
|
||||
uci commit qmodem_mwan
|
||||
;;
|
||||
|
||||
|
@ -130,8 +130,8 @@ handle_config()
|
||||
config_get track_ip $1 member_track_ip
|
||||
echo $1
|
||||
append_if $interface "$track_ip"
|
||||
add_mwan3_member $interface $priority $weight $1
|
||||
append_mwan3_policy_member $family $1
|
||||
add_mwan3_member $interface $priority $weight m$interface
|
||||
append_mwan3_policy_member $family m$interface
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
||||
PKG_NAME:=luci-app-qmodem
|
||||
LUCI_TITLE:=LuCI support for QWRT Modem
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=2.4.3
|
||||
PKG_VERSION:=2.4.4
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_LINCESE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=Tom <fjrcn@outlook.com>
|
||||
|
@ -39,6 +39,11 @@ for line in net:lines() do
|
||||
end
|
||||
net:close()
|
||||
|
||||
default_alias = s:option(Value, "default_alias", translate("Default Alias"))
|
||||
default_alias.description = translate("After setting this option, the first module loaded into this slot will automatically be assigned this default alias.")
|
||||
|
||||
|
||||
|
||||
associated_usb = s:option(Value, "associated_usb", translate("Associated USB"))
|
||||
associated_usb.rmempty = true
|
||||
associated_usb.description = translate("For M.2 slots with both PCIe and USB support, specify the associated USB port (for ttyUSB access)")
|
||||
|
@ -471,3 +471,9 @@ msgstr "已启用"
|
||||
|
||||
msgid "DISABLED"
|
||||
msgstr "已禁用"
|
||||
|
||||
msgid "Default Alias"
|
||||
msgstr "默认别名"
|
||||
|
||||
msgid "After setting this option, the first module loaded into this slot will automatically be assigned this default alias."
|
||||
msgid "设置后,首次加载来此该插槽的模组会自动分配该默认别名"
|
||||
|
@ -35,25 +35,29 @@ modem_settings()
|
||||
#(slot 2)
|
||||
uci set qmodem.u2_1_2="modem-slot"
|
||||
uci set qmodem.u2_1_2.slot="2-1.2"
|
||||
uci set qmodem.u2_1_2.alias="5g1"
|
||||
uci set qmodem.u2_1_2.type="usb"
|
||||
uci set qmodem.u2_1_2.net_led="wwan2"
|
||||
uci set qmodem.u2_1_2.sim_led="green:sim2"
|
||||
#(slot 1)
|
||||
uci set qmodem.u2_1_4="modem-slot"
|
||||
uci set qmodem.u2_1_4.slot="2-1.4"
|
||||
uci set qmodem.u2_1_4.alias="5g0"
|
||||
uci set qmodem.u2_1_4.type="usb"
|
||||
uci set qmodem.u2_1_4.net_led="wwan1"
|
||||
uci set qmodem.u2_1_4.sim_led="green:sim1"
|
||||
#m2 usb2.0
|
||||
#(slot 2)
|
||||
uci set qmodem.u1_1_2="modem-slot"
|
||||
uci set qmodem.u1_1_2.slot="1-1.1"
|
||||
uci set qmodem.u1_1_2.type="usb"
|
||||
uci set qmodem.u1_1_2.net_led="wwan2"
|
||||
uci set qmodem.u1_1_2.sim_led="green:sim2"
|
||||
uci set qmodem.u1_1_1="modem-slot"
|
||||
uci set qmodem.u1_1_1.slot="1-1.1"
|
||||
uci set qmodem.u1_1_1.type="usb"
|
||||
uci set qmodem.u1_1_1.alias="4g3"
|
||||
uci set qmodem.u1_1_1.net_led="wwan2"
|
||||
uci set qmodem.u1_1_1.sim_led="green:sim2"
|
||||
#(slot 1)
|
||||
uci set qmodem.u1_1_4="modem-slot"
|
||||
uci set qmodem.u1_1_4.slot="1-1.4"
|
||||
uci set qmodem.u1_1_4.alias="4g2"
|
||||
uci set qmodem.u1_1_4.type="usb"
|
||||
uci set qmodem.u1_1_4.net_led="wwan1"
|
||||
uci set qmodem.u1_1_4.sim_led="green:sim1"
|
||||
@ -62,12 +66,14 @@ modem_settings()
|
||||
uci set qmodem.u1_1_2="modem-slot"
|
||||
uci set qmodem.u1_1_2.slot="1-1.2"
|
||||
uci set qmodem.u1_1_2.type="usb"
|
||||
uci set qmodem.u1_1_2.alias="4g1"
|
||||
uci set qmodem.u1_1_2.net_led="wwan2"
|
||||
uci set qmodem.u1_1_2.sim_led="green:sim2"
|
||||
#(slot 1)
|
||||
uci set qmodem.u1_1_3="modem-slot"
|
||||
uci set qmodem.u1_1_3.slot="1-1.3"
|
||||
uci set qmodem.u1_1_3.type="usb"
|
||||
uci set qmodem.u1_1_3.alias="4g0"
|
||||
uci set qmodem.u1_1_3.net_led="wwan1"
|
||||
uci set qmodem.u1_1_3.sim_led="green:sim1"
|
||||
|
||||
|
@ -323,60 +323,139 @@ append_to_fw_zone()
|
||||
|
||||
set_if()
|
||||
{
|
||||
fw_reload_flag=0
|
||||
dhcp_reload_flag=0
|
||||
network_reload_flag=0
|
||||
#check if exist
|
||||
case $manufacturer in
|
||||
"quectel")
|
||||
case $platform in
|
||||
"unisoc")
|
||||
case $driver in
|
||||
"mbim")
|
||||
proto="none"
|
||||
protov6="none"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
if [ -z "$proto" ];then
|
||||
proto="dhcp"
|
||||
protov6="dhcpv6"
|
||||
fi
|
||||
case $pdp_type in
|
||||
"ip")
|
||||
env4="1"
|
||||
env6="0"
|
||||
;;
|
||||
"ipv6")
|
||||
env4="0"
|
||||
env6="1"
|
||||
;;
|
||||
"ipv4v6")
|
||||
env4="1"
|
||||
env6="1"
|
||||
;;
|
||||
esac
|
||||
interface=$(uci -q get network.$interface_name)
|
||||
if [ -z "$interface" ];then
|
||||
uci set network.${interface_name}=interface
|
||||
uci set network.${interface_name}.modem_config="${modem_config}"
|
||||
uci set network.${interface_name}.proto='dhcp'
|
||||
uci set network.${interface_name}.defaultroute='1'
|
||||
uci set network.${interface_name}.peerdns='0'
|
||||
uci set network.${interface_name}.metric="${metric}"
|
||||
uci add_list network.${interface_name}.dns='114.114.114.114'
|
||||
uci add_list network.${interface_name}.dns='119.29.29.29'
|
||||
local num=$(uci show firewall | grep "name='wan'" | wc -l)
|
||||
local wwan_num=$(uci -q get firewall.@zone[$num].network | grep -w "${interface_name}" | wc -l)
|
||||
if [ "$wwan_num" = "0" ]; then
|
||||
append_to_fw_zone $num ${interface_name}
|
||||
interfacev6=$(uci -q get network.$interface6_name)
|
||||
if [ "$env4" -eq 1 ];then
|
||||
if [ -z "$inetrface" ];then
|
||||
uci set network.${interface_name}=interface
|
||||
uci set network.${interface_name}.modem_config="${modem_config}"
|
||||
uci set network.${interface_name}.proto="${proto}"
|
||||
uci set network.${interface_name}.defaultroute='1'
|
||||
uci set network.${interface_name}.peerdns='0'
|
||||
uci set network.${interface_name}.metric="${metric}"
|
||||
uci add_list network.${interface_name}.dns='114.114.114.114'
|
||||
uci add_list network.${interface_name}.dns='119.29.29.29'
|
||||
local num=$(uci show firewall | grep "name='wan'" | wc -l)
|
||||
local wwan_num=$(uci -q get firewall.@zone[$num].network | grep -w "${interface_name}" | wc -l)
|
||||
if [ "$wwan_num" = "0" ]; then
|
||||
append_to_fw_zone $num ${interface_name}
|
||||
fi
|
||||
network_reload_flag=1
|
||||
firewall_reload_flag=1
|
||||
fi
|
||||
#set ipv6
|
||||
#if pdptype contain 6
|
||||
if [ -n "$(echo $pdp_type | grep "6")" ];then
|
||||
else
|
||||
if [ -n "$interface" ];then
|
||||
uci delete network.${interface_name}
|
||||
network_reload_flag=1
|
||||
m_debug "delete interface $interface_name"
|
||||
fi
|
||||
fi
|
||||
if [ "$env6" -eq 1 ];then
|
||||
if [ -z "$interfacev6" ];then
|
||||
uci set network.lan.ipv6='1'
|
||||
uci set network.lan.ip6assign='64'
|
||||
uci set network.lan.ip6class="${interface6_name}"
|
||||
uci set network.${interface6_name}.modem_config="${modem_config}"
|
||||
uci set network.${interface6_name}='interface'
|
||||
uci set network.${interface6_name}.proto='dhcpv6'
|
||||
uci set network.${interface6_name}.proto="${protov6}"
|
||||
uci set network.${interface6_name}.ifname="@${interface_name}"
|
||||
uci set network.${interface6_name}.device="@${interface_name}"
|
||||
uci set network.${interface6_name}.metric="${metric}"
|
||||
if [ "$ra_master" = "1" ];then
|
||||
uci set dhcp.${interface6_name}='dhcp'
|
||||
uci set dhcp.${interface6_name}.interface="${interface6_name}"
|
||||
uci set dhcp.${interface6_name}.ra='relay'
|
||||
uci set dhcp.${interface6_name}.ndp='relay'
|
||||
uci set dhcp.${interface6_name}.master='1'
|
||||
uci set dhcp.${interface6_name}.ignore='1'
|
||||
uci set dhcp.lan.ra='relay'
|
||||
uci set dhcp.lan.ndp='relay'
|
||||
uci set dhcp.lan.dhcpv6='relay'
|
||||
uci commit dhcp
|
||||
elif [ "$extend_prefix" = "1" ];then
|
||||
uci set network.${interface6_name}.extendprefix=1
|
||||
fi
|
||||
|
||||
local wwan6_num=$(uci -q get firewall.@zone[$num].network | grep -w "${interface6_name}" | wc -l)
|
||||
if [ "$wwan6_num" = "0" ]; then
|
||||
append_to_fw_zone $num ${interface6_name}
|
||||
fi
|
||||
network_reload_flag=1
|
||||
firewall_reload_flag=1
|
||||
fi
|
||||
if [ "$ra_master" = "1" ];then
|
||||
uci set dhcp.${interface6_name}='dhcp'
|
||||
uci set dhcp.${interface6_name}.interface="${interface6_name}"
|
||||
uci set dhcp.${interface6_name}.ra='relay'
|
||||
uci set dhcp.${interface6_name}.ndp='relay'
|
||||
uci set dhcp.${interface6_name}.master='1'
|
||||
uci set dhcp.${interface6_name}.ignore='1'
|
||||
uci set dhcp.lan.ra='relay'
|
||||
uci set dhcp.lan.ndp='relay'
|
||||
uci set dhcp.lan.dhcpv6='relay'
|
||||
dhcp_reload_flag=1
|
||||
elif [ "$extend_prefix" = "1" ];then
|
||||
uci set network.${interface6_name}.extendprefix=1
|
||||
dhcpv6=$(uci -q get dhcp.${interface6_name})
|
||||
if [ -n "$dhcpv6" ];then
|
||||
uci delete dhcp.${interface6_name}
|
||||
dhcp_reload_flag=1
|
||||
fi
|
||||
else
|
||||
dhcpv6=$(uci -q get dhcp.${interface6_name})
|
||||
if [ -n "$dhcpv6" ];then
|
||||
uci delete dhcp.${interface6_name}
|
||||
dhcp_reload_flag=1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [ -n "$interfacev6" ];then
|
||||
uci delete network.${interface6_name}
|
||||
network_reload_flag=1
|
||||
dhcpv6=$(uci -q get dhcp.${interface6_name})
|
||||
if [ -n "$dhcpv6" ];then
|
||||
dhcp_reload_flag=1
|
||||
fi
|
||||
m_debug "delete interface $interface6_name"
|
||||
fi
|
||||
uci commit network
|
||||
uci commit firewall
|
||||
ifup ${interface_name}
|
||||
m_debug "create interface $interface_name"
|
||||
|
||||
fi
|
||||
|
||||
if [ "$network_reload_flag" -eq 1 ];then
|
||||
uci commit network
|
||||
/etc/init.d/network restart
|
||||
fi
|
||||
if [ "$firewall_reload_flag" -eq 1 ];then
|
||||
uci commit firewall
|
||||
/etc/init.d/firewall restart
|
||||
fi
|
||||
if [ "$dhcp_reload_flag" -eq 1 ];then
|
||||
uci commit dhcp
|
||||
/etc/init.d/dhcp restart
|
||||
fi
|
||||
|
||||
|
||||
set_modem_netcard=$modem_netcard
|
||||
if [ -z "$set_modem_netcard" ];then
|
||||
m_debug "no netcard found"
|
||||
|
@ -14,6 +14,13 @@ get_associate_usb()
|
||||
config_foreach _get_associated_usb_by_path modem-slot
|
||||
}
|
||||
|
||||
get_default_alias()
|
||||
{
|
||||
target_slot=$1
|
||||
config_load qmodem
|
||||
config_foreach _get_default_alias_by_slot
|
||||
}
|
||||
|
||||
_get_associated_usb_by_path()
|
||||
{
|
||||
local cfg="$1"
|
||||
@ -26,6 +33,16 @@ _get_associated_usb_by_path()
|
||||
|
||||
}
|
||||
|
||||
_get_default_alias_by_slot()
|
||||
{
|
||||
local cfg="$1"
|
||||
config_get _get_slot $cfg slot
|
||||
if [ "$target_slot" == "$_get_slot" ];then
|
||||
config_get default_alias $cfg alias
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
scan()
|
||||
{
|
||||
local slot_type=$1
|
||||
@ -298,11 +315,14 @@ add()
|
||||
else
|
||||
#aqcuire lock
|
||||
lock /tmp/lock/modem_add
|
||||
get_default_alias $slot
|
||||
|
||||
modem_count=$(uci get qmodem.main.modem_count)
|
||||
[ -z "$modem_count" ] && modem_count=0
|
||||
modem_count=$(($modem_count+1))
|
||||
uci set qmodem.main.modem_count=$modem_count
|
||||
uci set qmodem.$section_name=modem-device
|
||||
[ -n "$default_alias" ] && uci set qmodem.${section_name}.alias="$default_alias"
|
||||
uci commit qmodem
|
||||
lock -u /tmp/lock/modem_add
|
||||
#release lock
|
||||
|
Loading…
x
Reference in New Issue
Block a user