mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
netmode: Added mode specific scripts
This commit is contained in:
parent
26ffa55453
commit
db626422dc
12 changed files with 384 additions and 2 deletions
|
|
@ -8,7 +8,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=netmode
|
PKG_NAME:=netmode
|
||||||
PKG_VERSION:=1.1.2
|
PKG_VERSION:=1.1.3
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||||
PKG_LICENSE:=GPL-2.0-only
|
PKG_LICENSE:=GPL-2.0-only
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,23 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"Type": {
|
||||||
|
"type": "string",
|
||||||
|
"read": true,
|
||||||
|
"write": true,
|
||||||
|
"description": "Datatype for this argument",
|
||||||
|
"protocols": [
|
||||||
|
"cwmp",
|
||||||
|
"usp"
|
||||||
|
],
|
||||||
|
"mapping": [
|
||||||
|
{
|
||||||
|
"type": "uci_sec",
|
||||||
|
"data": "@Parent",
|
||||||
|
"key": "type"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"Description": {
|
"Description": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"read": true,
|
"read": true,
|
||||||
|
|
|
||||||
127
netmode/files/etc/netmodes/bridged/scripts/10-bridged
Normal file
127
netmode/files/etc/netmodes/bridged/scripts/10-bridged
Normal file
|
|
@ -0,0 +1,127 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. /lib/functions.sh
|
||||||
|
. /usr/share/libubox/jshn.sh
|
||||||
|
|
||||||
|
source "/etc/device_info"
|
||||||
|
|
||||||
|
l2_mcast_config() {
|
||||||
|
# configure L2 mcast config for snooping
|
||||||
|
logger -s -p user.info -t "netmode" "Generating L2 mcast configuration"
|
||||||
|
|
||||||
|
# remove proxy sections
|
||||||
|
uci -q delete mcast.igmp_proxy_1
|
||||||
|
uci -q delete mcast.mc_proxy_MLD
|
||||||
|
|
||||||
|
# add igmp_snooping section
|
||||||
|
uci -q set mcast.igmp_snooping_1=snooping
|
||||||
|
uci -q set mcast.igmp_snooping_1.enable='1'
|
||||||
|
uci -q set mcast.igmp_snooping_1.proto='igmp'
|
||||||
|
uci -q set mcast.igmp_snooping_1.version='2'
|
||||||
|
uci -q set mcast.igmp_snooping_1.robustness='2'
|
||||||
|
uci -q set mcast.igmp_snooping_1.query_interval='125'
|
||||||
|
uci -q set mcast.igmp_snooping_1.query_response_interval='100'
|
||||||
|
uci -q set mcast.igmp_snooping_1.last_member_query_interval='10'
|
||||||
|
uci -q set mcast.igmp_snooping_1.fast_leave='1'
|
||||||
|
uci -q set mcast.igmp_snooping_1.snooping_mode='2'
|
||||||
|
uci -q set mcast.igmp_snooping_1.interface='br-lan'
|
||||||
|
uci -q add_list mcast.igmp_snooping_1.filter='239.0.0.0/8'
|
||||||
|
|
||||||
|
# add mld_snooping section
|
||||||
|
uci -q set mcast.mld_snooping_1=snooping
|
||||||
|
uci -q set mcast.mld_snooping_1.enable='1'
|
||||||
|
uci -q set mcast.mld_snooping_1.proto='mld'
|
||||||
|
uci -q set mcast.mld_snooping_1.version='2'
|
||||||
|
uci -q set mcast.mld_snooping_1.robustness='2'
|
||||||
|
uci -q set mcast.mld_snooping_1.query_interval='125'
|
||||||
|
uci -q set mcast.mld_snooping_1.query_response_interval='100'
|
||||||
|
uci -q set mcast.mld_snooping_1.last_member_query_interval='10'
|
||||||
|
uci -q set mcast.mld_snooping_1.fast_leave='1'
|
||||||
|
uci -q set mcast.mld_snooping_1.snooping_mode='2'
|
||||||
|
uci -q set mcast.mld_snooping_1.interface='br-lan'
|
||||||
|
|
||||||
|
uci -q commit mcast
|
||||||
|
}
|
||||||
|
|
||||||
|
l2_network_config() {
|
||||||
|
logger -s -p user.info -t "netmode" "Generating L2 network configuration"
|
||||||
|
|
||||||
|
# Configure L2 Network Mode
|
||||||
|
uci -q set network.lan=interface
|
||||||
|
uci -q set network.lan.proto='dhcp'
|
||||||
|
uci -q set network.lan.vendorid="$(uci -q get network.wan.vendorid)"
|
||||||
|
uci -q set network.lan.clientid="$(uci -q get network.wan.clientid)"
|
||||||
|
uci -q set network.lan.reqopts="$(uci -q get network.wan.reqopts)"
|
||||||
|
uci -q set network.lan.sendopts="$(uci -q get network.wan.sendopts)"
|
||||||
|
uci -q set network.lan.device='br-lan'
|
||||||
|
uci -q set network.lan.force_link='1'
|
||||||
|
|
||||||
|
uci -q set network.lan6=interface
|
||||||
|
uci -q set network.lan6.proto='dhcpv6'
|
||||||
|
uci -q set network.lan6.device='@lan'
|
||||||
|
uci -q set network.lan6.reqprefix='no'
|
||||||
|
|
||||||
|
uci -q set network.wan.disabled='1'
|
||||||
|
uci -q set network.wan6.disabled='1'
|
||||||
|
|
||||||
|
uci -q delete network.br_lan.ports
|
||||||
|
uci -q set network.br_lan.bridge_empty='1'
|
||||||
|
|
||||||
|
add_port_to_br_lan() {
|
||||||
|
port="$1"
|
||||||
|
[ -n "$port" -a -d /sys/class/net/$port ] || continue
|
||||||
|
uci add_list network.br_lan.ports="$port"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -f /etc/board.json ]; then
|
||||||
|
json_load_file /etc/board.json
|
||||||
|
json_select network
|
||||||
|
json_select lan
|
||||||
|
if json_is_a ports array; then
|
||||||
|
json_for_each_item add_port_to_br_lan ports
|
||||||
|
else
|
||||||
|
json_get_var device device
|
||||||
|
[ -n "$device" ] && uci add_list network.br_lan.ports="$device"
|
||||||
|
fi
|
||||||
|
json_select ..
|
||||||
|
json_select wan 2>/dev/null
|
||||||
|
json_get_var device device
|
||||||
|
[ -n "$device" ] && uci add_list network.br_lan.ports="$device"
|
||||||
|
json_cleanup
|
||||||
|
fi
|
||||||
|
|
||||||
|
uci -q commit network
|
||||||
|
|
||||||
|
# Disable DHCP Server
|
||||||
|
uci -q set dhcp.lan.ignore=1
|
||||||
|
uci -q commit dhcp
|
||||||
|
/etc/init.d/odhcpd disable
|
||||||
|
|
||||||
|
# Disable SSDPD
|
||||||
|
uci -q set ssdpd.ssdp.enabled="0"
|
||||||
|
uci -q commit ssdpd
|
||||||
|
|
||||||
|
# Update CWMP Agent WAN Interface
|
||||||
|
uci -q set cwmp.cpe.default_wan_interface="lan"
|
||||||
|
uci -q commit cwmp
|
||||||
|
|
||||||
|
# Update gateway WAN Interface
|
||||||
|
uci -q set gateway.global.wan_interface="lan"
|
||||||
|
uci -q commit gateway
|
||||||
|
|
||||||
|
# disable firewall
|
||||||
|
uci -q set firewall.globals.enabled="0"
|
||||||
|
uci -q commit firewall
|
||||||
|
}
|
||||||
|
|
||||||
|
l2_network_config
|
||||||
|
l2_mcast_config
|
||||||
|
|
||||||
|
# If device is already boot-up, assume netmode changed during runtime
|
||||||
|
if [ -f /var/run/boot_complete ]; then
|
||||||
|
/etc/init.d/odhcpd stop 2>/dev/null
|
||||||
|
for config in network dhcp ssdpd cwmp gateway firewall mcast; do
|
||||||
|
ubus call uci commit "{\"config\":\"$config\"}"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
fi
|
||||||
108
netmode/files/etc/netmodes/routed-dhcp/scripts/10-routed-dhcp
Normal file
108
netmode/files/etc/netmodes/routed-dhcp/scripts/10-routed-dhcp
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. /lib/functions.sh
|
||||||
|
. /usr/share/libubox/jshn.sh
|
||||||
|
|
||||||
|
source "/etc/device_info"
|
||||||
|
|
||||||
|
l3_mcast_config() {
|
||||||
|
# configure L3 mcast config
|
||||||
|
logger -s -p user.info -t "netmode" "Generating L3 mcast configuration"
|
||||||
|
|
||||||
|
rm -f /etc/config/mcast
|
||||||
|
sh /rom/etc/uci-defaults/61-mcast_config_generate
|
||||||
|
uci -q commit mcast
|
||||||
|
}
|
||||||
|
|
||||||
|
l3_network_config() {
|
||||||
|
logger -s -p user.info -t "netmode" "Generating L3 network configuration"
|
||||||
|
|
||||||
|
# Configure L3 Network Mode
|
||||||
|
uci -q set network.lan=interface
|
||||||
|
uci -q set network.lan.device='br-lan'
|
||||||
|
uci -q set network.lan.proto='static'
|
||||||
|
uci -q set network.lan.ipaddr='192.168.1.1'
|
||||||
|
uci -q set network.lan.netmask='255.255.255.0'
|
||||||
|
uci -q set network.lan.ip6assign='60'
|
||||||
|
uci -q delete network.lan.vendorid
|
||||||
|
uci -q delete network.lan.clientid
|
||||||
|
uci -q delete network.lan.reqopts
|
||||||
|
uci -q delete network.lan.sendopts
|
||||||
|
|
||||||
|
uci -q delete network.lan6
|
||||||
|
|
||||||
|
uci -q set network.wan=interface
|
||||||
|
uci -q set network.wan.proto='dhcp'
|
||||||
|
uci -q delete network.wan.disabled
|
||||||
|
uci -q delete network.wan.username
|
||||||
|
uci -q delete network.wan.password
|
||||||
|
|
||||||
|
uci -q set network.wan6=interface
|
||||||
|
uci -q set network.wan6.proto='dhcpv6'
|
||||||
|
uci -q delete network.wan6.disabled
|
||||||
|
|
||||||
|
uci -q delete network.br_lan.ports
|
||||||
|
uci -q set network.br_lan.bridge_empty='1'
|
||||||
|
|
||||||
|
add_port_to_br_lan() {
|
||||||
|
port="$1"
|
||||||
|
[ -n "$port" -a -d /sys/class/net/$port ] || continue
|
||||||
|
uci add_list network.br_lan.ports="$port"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -f /etc/board.json ]; then
|
||||||
|
json_load_file /etc/board.json
|
||||||
|
json_select network
|
||||||
|
json_select lan
|
||||||
|
if json_is_a ports array; then
|
||||||
|
json_for_each_item add_port_to_br_lan ports
|
||||||
|
else
|
||||||
|
json_get_var device device
|
||||||
|
[ -n "$device" ] && uci add_list network.br_lan.ports="$device"
|
||||||
|
fi
|
||||||
|
json_select ..
|
||||||
|
json_select wan 2>/dev/null
|
||||||
|
json_get_var device device
|
||||||
|
if [ -n "$device" ]; then
|
||||||
|
uci -q set network.wan.device="$device"
|
||||||
|
uci -q set network.wan6.device="$device"
|
||||||
|
fi
|
||||||
|
json_cleanup
|
||||||
|
fi
|
||||||
|
|
||||||
|
uci -q commit network
|
||||||
|
|
||||||
|
# Enable DHCP Server
|
||||||
|
uci -q set dhcp.lan.ignore=0
|
||||||
|
uci -q set dhcp.wan.ignore=1
|
||||||
|
uci -q commit dhcp
|
||||||
|
/etc/init.d/odhcpd enable
|
||||||
|
|
||||||
|
# Enable SSDPD
|
||||||
|
uci -q set ssdpd.ssdp.enabled="1"
|
||||||
|
uci -q commit ssdpd
|
||||||
|
|
||||||
|
# Update CWMP Agent WAN Interface
|
||||||
|
uci -q set cwmp.cpe.default_wan_interface="wan"
|
||||||
|
uci -q commit cwmp
|
||||||
|
|
||||||
|
# Update gateway WAN Interface
|
||||||
|
uci -q set gateway.global.wan_interface="wan"
|
||||||
|
uci -q commit gateway
|
||||||
|
|
||||||
|
# Enable firewall
|
||||||
|
uci -q set firewall.globals.enabled="1"
|
||||||
|
uci -q commit firewall
|
||||||
|
}
|
||||||
|
|
||||||
|
l3_network_config
|
||||||
|
l3_mcast_config
|
||||||
|
|
||||||
|
# If device is already boot-up, assume netmode changed during runtime
|
||||||
|
if [ -f /var/run/boot_complete ]; then
|
||||||
|
/etc/init.d/odhcpd restart 2>/dev/null
|
||||||
|
for config in network dhcp ssdpd cwmp gateway firewall mcast; do
|
||||||
|
ubus call uci commit "{\"config\":\"$config\"}"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
fi
|
||||||
106
netmode/files/etc/netmodes/routed-pppoe/scripts/10-routed-pppoe
Normal file
106
netmode/files/etc/netmodes/routed-pppoe/scripts/10-routed-pppoe
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. /lib/functions.sh
|
||||||
|
. /usr/share/libubox/jshn.sh
|
||||||
|
|
||||||
|
source "/etc/device_info"
|
||||||
|
|
||||||
|
l3_mcast_config() {
|
||||||
|
# configure L3 mcast config
|
||||||
|
logger -s -p user.info -t "netmode" "Generating L3 mcast configuration"
|
||||||
|
|
||||||
|
rm -f /etc/config/mcast
|
||||||
|
sh /rom/etc/uci-defaults/61-mcast_config_generate
|
||||||
|
uci -q commit mcast
|
||||||
|
}
|
||||||
|
|
||||||
|
l3_network_pppoe_config() {
|
||||||
|
logger -s -p user.info -t "netmode" "Generating L3 network configuration"
|
||||||
|
|
||||||
|
# Configure L3 Network Mode
|
||||||
|
uci -q set network.lan=interface
|
||||||
|
uci -q set network.lan.device='br-lan'
|
||||||
|
uci -q set network.lan.proto='static'
|
||||||
|
uci -q set network.lan.ipaddr='192.168.1.1'
|
||||||
|
uci -q set network.lan.netmask='255.255.255.0'
|
||||||
|
uci -q set network.lan.ip6assign='60'
|
||||||
|
uci -q delete network.lan.vendorid
|
||||||
|
uci -q delete network.lan.clientid
|
||||||
|
uci -q delete network.lan.reqopts
|
||||||
|
uci -q delete network.lan.sendopts
|
||||||
|
|
||||||
|
uci -q delete network.lan6
|
||||||
|
|
||||||
|
uci -q set network.wan=interface
|
||||||
|
uci -q set network.wan.proto='pppoe'
|
||||||
|
uci -q set network.wan.username="$NETMODE_username"
|
||||||
|
uci -q set network.wan.password="$NETMODE_password"
|
||||||
|
uci -q delete network.wan.disabled
|
||||||
|
|
||||||
|
uci -q set network.wan6.disabled='1'
|
||||||
|
|
||||||
|
uci -q delete network.br_lan.ports
|
||||||
|
uci -q set network.br_lan.bridge_empty='1'
|
||||||
|
|
||||||
|
add_port_to_br_lan() {
|
||||||
|
port="$1"
|
||||||
|
[ -n "$port" -a -d /sys/class/net/$port ] || continue
|
||||||
|
uci add_list network.br_lan.ports="$port"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -f /etc/board.json ]; then
|
||||||
|
json_load_file /etc/board.json
|
||||||
|
json_select network
|
||||||
|
json_select lan
|
||||||
|
if json_is_a ports array; then
|
||||||
|
json_for_each_item add_port_to_br_lan ports
|
||||||
|
else
|
||||||
|
json_get_var device device
|
||||||
|
[ -n "$device" ] && uci add_list network.br_lan.ports="$device"
|
||||||
|
fi
|
||||||
|
json_select ..
|
||||||
|
json_select wan 2>/dev/null
|
||||||
|
json_get_var device device
|
||||||
|
if [ -n "$device" ]; then
|
||||||
|
uci -q set network.wan.device="$device"
|
||||||
|
uci -q set network.wan6.device="$device"
|
||||||
|
fi
|
||||||
|
json_cleanup
|
||||||
|
fi
|
||||||
|
|
||||||
|
uci -q commit network
|
||||||
|
|
||||||
|
# Enable DHCP Server
|
||||||
|
uci -q set dhcp.lan.ignore=0
|
||||||
|
uci -q set dhcp.wan.ignore=1
|
||||||
|
uci -q commit dhcp
|
||||||
|
/etc/init.d/odhcpd enable
|
||||||
|
|
||||||
|
# Enable SSDPD
|
||||||
|
uci -q set ssdpd.ssdp.enabled="1"
|
||||||
|
uci -q commit ssdpd
|
||||||
|
|
||||||
|
# Update CWMP Agent WAN Interface
|
||||||
|
uci -q set cwmp.cpe.default_wan_interface="wan"
|
||||||
|
uci -q commit cwmp
|
||||||
|
|
||||||
|
# Update gateway WAN Interface
|
||||||
|
uci -q set gateway.global.wan_interface="wan"
|
||||||
|
uci -q commit gateway
|
||||||
|
|
||||||
|
# Enable firewall
|
||||||
|
uci -q set firewall.globals.enabled="1"
|
||||||
|
uci -q commit firewall
|
||||||
|
}
|
||||||
|
|
||||||
|
l3_network_pppoe_config
|
||||||
|
l3_mcast_config
|
||||||
|
|
||||||
|
# If device is already boot-up, assume netmode changed during runtime
|
||||||
|
if [ -f /var/run/boot_complete ]; then
|
||||||
|
/etc/init.d/odhcpd restart 2>/dev/null
|
||||||
|
for config in network dhcp ssdpd cwmp gateway firewall mcast; do
|
||||||
|
ubus call uci commit "{\"config\":\"$config\"}"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
@ -13,12 +13,14 @@
|
||||||
"name": "username",
|
"name": "username",
|
||||||
"description": "PPoE username",
|
"description": "PPoE username",
|
||||||
"required": true,
|
"required": true,
|
||||||
|
"type": "string",
|
||||||
"#value": "TestUser"
|
"#value": "TestUser"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "password",
|
"name": "password",
|
||||||
"description": "PPoE password",
|
"description": "PPoE password",
|
||||||
"required": true,
|
"required": true,
|
||||||
|
"type": "string",
|
||||||
"#value": "TestPassword"
|
"#value": "TestPassword"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ fi
|
||||||
|
|
||||||
configure_supp_modes_args()
|
configure_supp_modes_args()
|
||||||
{
|
{
|
||||||
local obj inst name description required value parent
|
local obj inst name description required value parent type
|
||||||
|
|
||||||
obj="${1}"
|
obj="${1}"
|
||||||
inst="${2}"
|
inst="${2}"
|
||||||
|
|
@ -32,12 +32,14 @@ configure_supp_modes_args()
|
||||||
json_get_var description description
|
json_get_var description description
|
||||||
json_get_var value value
|
json_get_var value value
|
||||||
json_get_var required required
|
json_get_var required required
|
||||||
|
json_get_var type type
|
||||||
|
|
||||||
uci -q set netmode.${parent}_supprted_args_${SUPP_ARGS}=supported_args
|
uci -q set netmode.${parent}_supprted_args_${SUPP_ARGS}=supported_args
|
||||||
uci -q set netmode.${parent}_supprted_args_${SUPP_ARGS}.name="${name}"
|
uci -q set netmode.${parent}_supprted_args_${SUPP_ARGS}.name="${name}"
|
||||||
uci -q set netmode.${parent}_supprted_args_${SUPP_ARGS}.description="${description}"
|
uci -q set netmode.${parent}_supprted_args_${SUPP_ARGS}.description="${description}"
|
||||||
uci -q set netmode.${parent}_supprted_args_${SUPP_ARGS}.required="${required}"
|
uci -q set netmode.${parent}_supprted_args_${SUPP_ARGS}.required="${required}"
|
||||||
uci -q set netmode.${parent}_supprted_args_${SUPP_ARGS}.value="${value}"
|
uci -q set netmode.${parent}_supprted_args_${SUPP_ARGS}.value="${value}"
|
||||||
|
uci -q set netmode.${parent}_supprted_args_${SUPP_ARGS}.type="${type}"
|
||||||
uci -q set netmode.${parent}_supprted_args_${SUPP_ARGS}.dm_parent="${parent}"
|
uci -q set netmode.${parent}_supprted_args_${SUPP_ARGS}.dm_parent="${parent}"
|
||||||
|
|
||||||
json_select ..
|
json_select ..
|
||||||
|
|
|
||||||
20
netmode/files/lib/netmode/post/datamodel_init.sh
Normal file
20
netmode/files/lib/netmode/post/datamodel_init.sh
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This script is to cleanup dmmap and restart datamodel related services
|
||||||
|
# when wan mode changes
|
||||||
|
|
||||||
|
if [ -d "/etc/bbfdm/dmmap/" ]; then
|
||||||
|
rm -rf /etc/bbfdm/dmmap/*
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -x "/etc/init.d/bbfdm.services" ]; then
|
||||||
|
/etc/init.d/bbfdm.services restart
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -x "/etc/init.d/bbfdmd" ]; then
|
||||||
|
/etc/init.d/bbfdmd restart
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -x "/etc/init.d/obuspa" ]; then
|
||||||
|
/etc/init.d/obuspa restart
|
||||||
|
fi
|
||||||
Loading…
Add table
Reference in a new issue