Developing lightweight computation at the DSG edge

Commit f4ef3181 authored by p4u's avatar p4u
Browse files

Prepare network functions only removes network devices, not the entire file

Adapt interface names to be compatible with switch vlans
Add hooks system to execute script depending on the hardware
Add hook for configurate WDR4300 and WDR3600 switch
parent e4112de2
......@@ -31,6 +31,19 @@ log() {
echo "$@" > /tmp/qmp_autoconf.log
}
boothooks() {
local device="$(cat /tmp/sysinfo/board_name)"
local hooksdir="/etc/qmp/hooks/$device"
[ -d "$hooksdir" ] && {
for h in $hooksdir/*; do
echo "Executing hook: $h"
sh $h boot
done
}
}
configure() {
log Starting qmp configuration...
......@@ -39,6 +52,9 @@ configure() {
log [Configuring wireless]
#Execute hooks
boothooks
#Generating default wifi configuration
country="$(uci get qmp.wireless.country 2>/dev/null)"
country="${country:-00}"
......
#!/bin/sh
# Stage = [boot|pre|post]
STAGE="$1"
[ "$STAGE" == "boot" ] && {
echo "Configuring TPlink WDR switch [INET|LAN|LAN|LAN|MESH]"
uci delete network.@switch[0]
uci add network switch
uci delete network.@switch_vlan[2]
uci delete network.@switch_vlan[1]
uci delete network.@switch_vlan[0]
uci add network switch_vlan > /dev/null
uci add network switch_vlan > /dev/null
uci add network switch_vlan > /dev/null
uci set network.@switch[0]=switch
uci set network.@switch[0].name=eth0
uci set network.@switch[0].reset=1
uci set network.@switch[0].enable_vlan=1
uci set network.@switch_vlan[0]=switch_vlan
uci set network.@switch_vlan[0].device=eth0
uci set network.@switch_vlan[0].vlan=1
uci set network.@switch_vlan[0].vid=1
uci set network.@switch_vlan[0].ports="0t 2 3 4"
uci set network.@switch_vlan[1]=switch_vlan
uci set network.@switch_vlan[1].device=eth0
uci set network.@switch_vlan[1].vlan=2
uci set network.@switch_vlan[1].ports="0t 1"
uci set network.@switch_vlan[1].vid=2
uci set network.@switch_vlan[2]=switch_vlan
uci set network.@switch_vlan[2].device=eth0
uci set network.@switch_vlan[2].vlan=3
uci set network.@switch_vlan[2].ports="0t 5t"
uci set network.@switch_vlan[2].vid=12
uci commit network
}
../scripts/switch_wdr.sh
\ No newline at end of file
......@@ -111,7 +111,7 @@ qmp_get_virtual_iface() {
[ -n "$viface" ] && { echo $viface; return; }
# id is the first and char and the numbers of the device [e]th[0] [w]lan[1]
local id_num=$(echo $device | tr -d "[A-z]" | tr - _)
local id_num=$(echo $device | tr -d "[A-z]" | tr - _ | tr . _)
local id_char=$(echo $device | cut -c 1)
# is wan
......@@ -686,6 +686,15 @@ qmp_configure_prepare() {
echo "" > /etc/config/$conf
}
qmp_configure_prepare_network() {
local toRemove="$(uci show network | egrep "network.(lan|wan_|mesh_).*=interface" | cut -d. -f2 | cut -d= -f1)"
echo "Removing network configuration for: $toRemove"
for i in $toRemove; do
uci del network.$i
done
uci commit network
}
qmp_configure_network() {
local conf="network"
......@@ -694,7 +703,7 @@ qmp_configure_network() {
echo "Configuring networking"
echo "-----------------------"
qmp_configure_prepare $conf
qmp_configure_prepare_network $conf
if qmp_uci_test qmp.interfaces.mesh_devices && qmp_uci_test qmp.networks.mesh_protocol_vids && qmp_uci_test qmp.networks.mesh_vid_offset; then
local vids="$(qmp_uci_get networks.mesh_protocol_vids | awk -F':' -v RS=" " '{print $2 + '$(uci -q get qmp.networks.mesh_vid_offset)'}')"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment