Developing lightweight computation at the DSG edge

Commit bd3bcb7e authored by p4u's avatar p4u
Browse files

Add new option qmp.interfaces.ignore_devices to force initial autoconfiguration not use them

Add hooks call from the configure_initial function in qmp_functions
Enables the Tplink WDR swhich hook, now it works.
parent a7fd93cd
config 'qmp' 'interfaces'
# option 'configure_switch' 'eth0' # (uncomment line if available, e.g. WGT634U)
option 'lan_devices' '' # will be used for LAN
option 'wan_devices' '' # will be used for WAN
option 'mesh_devices' '' # will be extended by vlan tag for by uses as Mesh
# option 'no_vlan_devices' '' # interfaces which won't be vlan tagged
# option 'configure_switch' '' # (deprecated) (uncomment line if available, e.g. WGT634U)
option 'lan_devices' '' # will be used for LAN
option 'wan_devices' '' # will be used for WAN
option 'mesh_devices' '' # will be extended by vlan tag for by uses as Mesh
# option 'no_vlan_devices' '' # interfaces which won't be vlan tagged
# option 'ignore_devices' '' # interfaces to ignore
config 'qmp' 'node'
option 'primary_device' 'eth0'
......@@ -16,7 +17,7 @@ config 'qmp' 'update'
option 'images' 'IMAGES'
option 'devices' 'DEVICES'
option 'filter' 'sysupgrade'
option 'preserve' '/etc/config/qmp /etc/shadow /etc/passwd /etc/rc.local /etc/firewall.user /etc/dropbear/* /etc/config/b6m-spread'
option 'preserve' '/etc/config/qmp /etc/shadow /etc/passwd /etc/rc.local /etc/firewall.user /etc/dropbear /etc/config/b6m-spread /etc/qmp/.birth'
config 'qmp' 'non_overlapping'
# Each node assings a non-overlapping DHCP IPv4 ranges over a /16 network on lan device
......
......@@ -47,37 +47,23 @@ exechooks() {
}
}
configure() {
log Redirecting stderr to $QMP_LOG
exec 2>>$QMP_LOG
log Starting qmp configuration...
log Waiting 10 seconds to be sure all is configured
sleep 10
# Execute birth hooks if it is the first boot of the device
[ ! -e "$BIRTH_FILE" ] && exechooks birth
# Execute firstboot hooks
log "[Executing hooks]"
exechooks firstboot
#Generating default wifi configuration
log "[Configuring wifi]"
country="$(uci get qmp.wireless.country 2>/dev/null)"
country="${country:-00}"
log Using countrycode $country
prepare_wifi() {
# Wifi is complicated...
mv /etc/config/wireless /tmp/wireless.old
# Wifi is complicated...
# It is a quick hack, because each time ath9k is loaded the phyX counter increases
# and openwrt wifi scripts take the device namw (i.e wlan0) from this counter
# It only works for ath9k
rmmod ath9k
insmod ath9k
sleep 1
# It is a quick hack, because each time ath9k is loaded the phyX counter increases
# and openwrt wifi scripts take it for selectin the wlan name (i.e wlan3)
local index=0
iw phy | grep Wiphy | awk '{print $2}' | while read d
do
iw phy $d set name qmp0
iw phy $d set name $index
index=$(($index+1))
done
wifi detect | sed s/"disabled 1"/"country $country"/g > /etc/config/wireless
......@@ -91,8 +77,30 @@ configure() {
#To be sure channel is set...
iw reg set $country || iw reg set 00
}
configure() {
log Redirecting stderr to $QMP_LOG
exec 2>>$QMP_LOG
log Starting qmp configuration...
log Waiting 10 seconds to be sure all is configured
sleep 10
# Execute birth hooks if it is the first boot of the device
[ ! -e "$BIRTH_FILE" ] && exechooks birth
# Execute firstboot hooks
log "[Executing hooks]"
exechooks firstboot
#Generating default wifi configuration
log "[Configuring wifi]"
country="$(uci get qmp.wireless.country 2>/dev/null)"
country="${country:-00}"
log Using countrycode $country
#Configuring wifi using QMP
prepare_wifi
. $QMP_DIR/qmp_wireless.sh
qmp_configure_wifi_initial
qmp_configure_wifi
......
tl-wdr4300/
\ No newline at end of file
../scripts/switch_wdr.sh
\ No newline at end of file
......@@ -183,7 +183,7 @@ qmp_get_rescue_ip() {
[ -z "$device" ] && return 1
local rprefix=$(qmp_uci_get networks.rescue_prefix24 2>/dev/null)
rprefix=${rprefix:-169.254.0}
rprefix=${rprefix:-169.254}
# if device is virtual, get the ifname
if qmp_uci_test network.$device.ifname; then
......@@ -220,9 +220,18 @@ qmp_configure_smart_network() {
local lan=""
local dev=""
local phydevs=""
local ignore_devs="$(qmp_uci_get interfaces.ignore_devices)"
for dev in $(ls /sys/class/net/); do
[ -e /sys/class/net/$dev/device ] && phydevs="$phydevs $dev\n"
[ -e /sys/class/net/$dev/device ] && {
local id
local ignore=0
# Check if device is in the ignore list
for id in $ignore_devs; do
[ "$id" == "$dev" ] && ignore=1
done
[ $ignore -eq 0 ] && phydevs="$phydevs $dev\n"
}
done
phydevs="$(echo -e "$phydevs" | grep -v -e ".*ap$" | grep -v "\\." | sort -u | tr -d ' ' \t)"
......@@ -285,9 +294,15 @@ qmp_configure_smart_network() {
echo "- MESH $mesh"
echo "- WAN $wan"
qmp_uci_set interfaces.lan_devices "$(echo $lan | sed -e s/"^ "//g -e s/" $"//g)"
qmp_uci_set interfaces.mesh_devices "$(echo $mesh | sed -e s/"^ "//g -e s/" $"//g)"
qmp_uci_set interfaces.wan_devices "$(echo $wan | sed -e s/"^ "//g -e s/" $"//g)"
# Join found devices and already configured ones
lan_devices=$(echo "$(qmp_uci_get interfaces.lan_devices) $lan" | tr ' ' '\n' | sort -u)
wan_devices=$(echo "$(qmp_uci_get interfaces.wan_devices) $wan" | tr ' ' '\n' | sort -u)
mesh_devices=$(echo "$(qmp_uci_get interfaces.mesh_devices) $mesh" | tr ' ' '\n' | sort -u)
# Writes the devices to the config
qmp_uci_set interfaces.lan_devices "$(echo $lan_devices | sed -e s/"^ "//g -e s/" $"//g)"
qmp_uci_set interfaces.mesh_devices "$(echo $mesh_devices | sed -e s/"^ "//g -e s/" $"//g)"
qmp_uci_set interfaces.wan_devices "$(echo $wan_devices | sed -e s/"^ "//g -e s/" $"//g)"
}
qmp_attach_device_to_interface() {
......@@ -1205,12 +1220,12 @@ qmp_configure_system() {
local community_node_id
if qmp_uci_test qmp.node.community_node_id; then
community_node_id="$(uci get qmp.node.community_node_id)"
community_node_id="$(qmp_uci_get node.community_node_id)"
else
community_node_id="$(qmp_get_mac_for_dev $primary_mesh_device | awk -F':' '{print $6}' )"
fi
local community_id="$(uci get qmp.node.community_id)"
local community_id="$(qmp_uci_get node.community_id)"
[ -z "$community_id" ] && community_id="qmp"
# set hostname
......@@ -1233,20 +1248,23 @@ qmp_restart_firewall() {
}
qmp_check_force_internet() {
[ "$(uci get qmp.networks.force_internet)" == "1" ] && qmp_gw_offer_default
[ "$(uci get qmp.networks.force_internet)" == "0" ] && qmp_gw_search_default
[ "$(qmp_uci_get networks.force_internet)" == "1" ] && qmp_gw_offer_default
[ "$(qmp_uci_get networks.force_internet)" == "0" ] && qmp_gw_search_default
}
qmp_configure_initial() {
qmp_hooks_exec firstboot
qmp_configure_smart_network
}
qmp_configure() {
qmp_hooks_exec preconf
qmp_check_force_internet
qmp_configure_network
qmp_configure_bmx6
qmp_configure_olsr6
qmp_configure_lan_v6
qmp_configure_system
qmp_hooks_exec postconf
}
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