diff --git a/.circleci/config.yml b/.circleci/config.yml index cc1893b1..e9aca158 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -48,6 +48,10 @@ jobs: name: Build command: make MAINTARGET=ipq40xx SUBTARGET=mikrotik no_output_timeout: 2h + - run: + name: Build + command: make MAINTARGET=x86 SUBTARGET=64 + no_output_timeout: 2h - run: name: Compress build files command: tar -cjf ~/${CIRCLE_BRANCH}_${ARTIFACTS_FILE} -C ${MY_WORKING_DIRECTORY}/${ARTIFACTS_DIR} . diff --git a/Makefile b/Makefile index b89e8360..e16e5a6d 100644 --- a/Makefile +++ b/Makefile @@ -149,7 +149,7 @@ compile: stamp-clean-compiled .stamp-compiled $(UMASK); \ $(MAKE) -C $(OPENWRT_DIR) $(MAKE_ARGS) for FILE in `find $(TOP_DIR)/firmware/targets/$(MAINTARGET)/$(SUBTARGET) -path "*packages" -prune -o \( -type f -a \ - ! \( -name "*factory.bin" -o -name "*sysupgrade.bin" -o -name "*initramfs*" -o -name sha256sums -o -name "*.buildinfo" -o -name "*.json" \) \ + ! \( -name "*factory.bin" -o -name "*sysupgrade.bin" -o -name "*x86*" -o -name "*initramfs*" -o -name sha256sums -o -name "*.buildinfo" -o -name "*.json" \) \ -print \)`; do rm $$FILE; \ done; $(TOP_DIR)/scripts/tests-postbuild.sh diff --git a/configs/x86-64.config b/configs/x86-64.config new file mode 100755 index 00000000..3307fca5 --- /dev/null +++ b/configs/x86-64.config @@ -0,0 +1,6 @@ +CONFIG_TARGET_x86=y +CONFIG_TARGET_x86_64=y +CONFIG_TARGET_ALL_PROFILES=y +CONFIG_TARGET_ROOTFS_INITRAMFS=n +CONFIG_TARGET_ROOTFS_TARGZ=n +CONFIG_TARGET_ROOTFS_SQUASHFS=n diff --git a/files/etc/radios.json b/files/etc/radios.json index 949208dd..f810629d 100644 --- a/files/etc/radios.json +++ b/files/etc/radios.json @@ -541,5 +541,8 @@ "name" : "Ubiquiti PowerBridge M5", "maxpower" : "22", "pwroffset" : "5" + }, + "QEMU Standard PC (i440FX + PIIX, 1996)" : { + "name" : "QEMU PC" } } diff --git a/files/usr/lib/lua/aredn/hardware.lua b/files/usr/lib/lua/aredn/hardware.lua index 65d49389..14d6d773 100644 --- a/files/usr/lib/lua/aredn/hardware.lua +++ b/files/usr/lib/lua/aredn/hardware.lua @@ -240,6 +240,14 @@ function hardware.has_usb() return false end +function hardware.has_wifi() + if nixio.fs.stat("/sys/kernel/debug/ieee80211") then + return true + else + return false + end +end + function hardware.get_rfbandwidths(wifiintf) return { 5, 10, 20 } end diff --git a/files/usr/local/bin/node-setup b/files/usr/local/bin/node-setup index e799f6d5..4bc1418e 100755 --- a/files/usr/local/bin/node-setup +++ b/files/usr/local/bin/node-setup @@ -102,8 +102,8 @@ local ieee80211 = "/sys/class/ieee80211/" local lanintf = aredn.hardware.get_board_network_ifname("lan") local node = aredn_info.get_nvram("node") local tactical = aredn_info.get_nvram("tactical") -local mac2 = mac_to_ip(aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("wifi")), 0) -local dtdmac = mac_to_ip(aredn.hardware.get_interface_mac(lanintf:match("^(%S+)")), 0) -- *not* based of dtdlink +local mac2 = aredn_info.get_nvram("mac2") +local dtdmac = aredn_info.get_nvram("dtdmac") local deleteme = {} local cfg = { @@ -739,119 +739,121 @@ c:commit("dhcp") local config = "" local ifacenum = 0 local ifacecount = 0 -for devname in nixio.fs.dir(ieee80211) -do - ifacecount = ifacecount + 1 -end -for devname in nixio.fs.dir(ieee80211) -do - local dev = devname:match("^phy(%d+)$") - local radio = "radio" .. dev - local wlan = "wlan" .. dev - local devpath = nixio.fs.realpath(ieee80211 .. nixio.fs.readlink(ieee80211 .. devname)):match("^/sys/devices/(.*)/ieee802.*$") - if devpath:match("^platform.*/pci.*") then - devpath = devpath:match("^platform/(.*)") +if nixio.fs.stat(ieee80211) then + for devname in nixio.fs.dir(ieee80211) + do + ifacecount = ifacecount + 1 end - local is_mesh_rf = false - local htmode = "HT20" - local disabled = "0" - local chanbw = nil - local country = nil - local channel = nil - local distance = nil - local hwmode = "11g" - if iwinfo.nl80211.freqlist(devname)[1].mhz > 5000 then - hwmode="11a" - end - local network = nil - local mode = nil - local ssid = nil - local encryption = nil - local key = nil - - if wlan == cfg.wifi_intf then - -- mesh RF adhoc configuration - is_mesh_rf = true - channel = cfg.wifi_channel - chanbw = cfg.wifi_chanbw - country = "HX" - distance = cfg.wifi_distance - ssid = cfg.wifi_ssid .. "-" .. chanbw .. "-v3" - mode = "adhoc" - encryption = "none" - network = "wifi" - elseif cfg.wifi2_enable == "1" and (ifacecount == 1 or (ifacecount > 1 and hwmode == cfg.wifi2_hwmode)) then - -- lan AP interface - channel = cfg.wifi2_channel - ssid = h2s(cfg.wifi2_ssid) - mode = "ap" - encryption = cfg.wifi2_encryption - key = h2s(cfg.wifi2_key) - network = "lan" - elseif cfg.wifi3_enable == "1" and (ifacecount == 1 or (ifacecount > 1 and hwmode == cfg.wifi3_hwmode)) then - -- wan client - ssid = h2s(cfg.wifi3_ssid) - mode = "sta" - if cfg.wifi3_key and cfg.wifi3_key ~= "" then - encryption = "psk2" - key = h2s(cfg.wifi3_key) - else - enable = "none" + for devname in nixio.fs.dir(ieee80211) + do + local dev = devname:match("^phy(%d+)$") + local radio = "radio" .. dev + local wlan = "wlan" .. dev + local devpath = nixio.fs.realpath(ieee80211 .. nixio.fs.readlink(ieee80211 .. devname)):match("^/sys/devices/(.*)/ieee802.*$") + if devpath:match("^platform.*/pci.*") then + devpath = devpath:match("^platform/(.*)") end - network = "wan" - htmode = nil - else - disabled = "1" - end + local is_mesh_rf = false + local htmode = "HT20" + local disabled = "0" + local chanbw = nil + local country = nil + local channel = nil + local distance = nil + local hwmode = "11g" + if iwinfo.nl80211.freqlist(devname)[1].mhz > 5000 then + hwmode="11a" + end + local network = nil + local mode = nil + local ssid = nil + local encryption = nil + local key = nil - config = config .. "config wifi-device '" .. radio .. "'\n option type 'mac80211'\n" - config = config .. " option disabled '" .. disabled .. "'\n" - if channel then - config = config .. " option channel '" .. channel .. "'\n" - end - if chanbw then - config = config .. " option chanbw '" .. chanbw .. "'\n" - end - if country then - config = config .. " option country '" .. country .. "'\n" - end - if distance then - config = config .. " option distance '" .. distance .. "'\n" - end - config = config .. " option hwmode '" .. hwmode .. "'\n" - if htmode then - config = config .. " option htmode '" .. htmode .. "'\n" - end - config = config .. " option path '" .. devpath .. "'\n\n" + if wlan == cfg.wifi_intf then + -- mesh RF adhoc configuration + is_mesh_rf = true + channel = cfg.wifi_channel + chanbw = cfg.wifi_chanbw + country = "HX" + distance = cfg.wifi_distance + ssid = cfg.wifi_ssid .. "-" .. chanbw .. "-v3" + mode = "adhoc" + encryption = "none" + network = "wifi" + elseif cfg.wifi2_enable == "1" and (ifacecount == 1 or (ifacecount > 1 and hwmode == cfg.wifi2_hwmode)) then + -- lan AP interface + channel = cfg.wifi2_channel + ssid = h2s(cfg.wifi2_ssid) + mode = "ap" + encryption = cfg.wifi2_encryption + key = h2s(cfg.wifi2_key) + network = "lan" + elseif cfg.wifi3_enable == "1" and (ifacecount == 1 or (ifacecount > 1 and hwmode == cfg.wifi3_hwmode)) then + -- wan client + ssid = h2s(cfg.wifi3_ssid) + mode = "sta" + if cfg.wifi3_key and cfg.wifi3_key ~= "" then + encryption = "psk2" + key = h2s(cfg.wifi3_key) + else + enable = "none" + end + network = "wan" + htmode = nil + else + disabled = "1" + end - config = config .. "config wifi-iface\n" - config = config .. " option ifname '" .. wlan .. "'\n" - config = config .. " option device '" .. radio .. "'\n" - if network then - config = config .. " option network '" .. network .. "'\n" - end - if mode then - config = config .. " option mode '" .. mode .. "'\n" - end - if ssid then - config = config .. " option ssid '" .. ssid .. "'\n" - end - if encryption then - config = config .. " option encryption '" .. encryption .. "'\n" - end - if key then - config = config .. " option key '" .. key .. "'\n" - end - config = config .. "\n" + config = config .. "config wifi-device '" .. radio .. "'\n option type 'mac80211'\n" + config = config .. " option disabled '" .. disabled .. "'\n" + if channel then + config = config .. " option channel '" .. channel .. "'\n" + end + if chanbw then + config = config .. " option chanbw '" .. chanbw .. "'\n" + end + if country then + config = config .. " option country '" .. country .. "'\n" + end + if distance then + config = config .. " option distance '" .. distance .. "'\n" + end + config = config .. " option hwmode '" .. hwmode .. "'\n" + if htmode then + config = config .. " option htmode '" .. htmode .. "'\n" + end + config = config .. " option path '" .. devpath .. "'\n\n" - if is_mesh_rf then - config = config .. "config wifi-iface\n" - config = config .. " option ifname '" .. wlan .. "-1'\n" + config = config .. "config wifi-iface\n" + config = config .. " option ifname '" .. wlan .. "'\n" config = config .. " option device '" .. radio .. "'\n" - config = config .. " option network 'wifi_mon'\n option mode 'monitor'\n\n" - end + if network then + config = config .. " option network '" .. network .. "'\n" + end + if mode then + config = config .. " option mode '" .. mode .. "'\n" + end + if ssid then + config = config .. " option ssid '" .. ssid .. "'\n" + end + if encryption then + config = config .. " option encryption '" .. encryption .. "'\n" + end + if key then + config = config .. " option key '" .. key .. "'\n" + end + config = config .. "\n" - ifacenum = ifacenum + 1 + if is_mesh_rf then + config = config .. "config wifi-iface\n" + config = config .. " option ifname '" .. wlan .. "-1'\n" + config = config .. " option device '" .. radio .. "'\n" + config = config .. " option network 'wifi_mon'\n option mode 'monitor'\n\n" + end + + ifacenum = ifacenum + 1 + end end write_all("/etc/config/wireless", config) diff --git a/files/usr/local/bin/nvram-setup b/files/usr/local/bin/nvram-setup index c07aa1ce..7947b9e9 100755 --- a/files/usr/local/bin/nvram-setup +++ b/files/usr/local/bin/nvram-setup @@ -1,37 +1,37 @@ #! /usr/bin/lua --[[ - Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks - Copyright (C) 2021 Tim Wilkinson - Original Perl Copyright (C) 2015 Conrad Lara - See Contributors file for additional contributors + Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks + Copyright (C) 2021 Tim Wilkinson + Original Perl Copyright (C) 2015 Conrad Lara + See Contributors file for additional contributors - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation version 3 of the License. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation version 3 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . + You should have received a copy of the GNU General Public License + along with this program. If not, see . - Additional Terms: + Additional Terms: - Additional use restrictions exist on the AREDN(TM) trademark and logo. - See AREDNLicense.txt for more info. + Additional use restrictions exist on the AREDN(TM) trademark and logo. + See AREDNLicense.txt for more info. - Attributions to the AREDN Project must be retained in the source code. - If importing this code into a new or existing project attribution - to the AREDN project must be added to the source code. + Attributions to the AREDN Project must be retained in the source code. + If importing this code into a new or existing project attribution + to the AREDN project must be added to the source code. - You must not misrepresent the origin of the material contained within. + You must not misrepresent the origin of the material contained within. - Modified versions must be modified to attribute to the original source - and be marked in reasonable ways as differentiate it from the original - version + Modified versions must be modified to attribute to the original source + and be marked in reasonable ways as differentiate it from the original + version --]] @@ -55,36 +55,46 @@ local dtdmac = aredn_info.get_nvram("dtdmac") local hardware_mac if wifi_mac == "" or mac2 == "" then - local phy - for i = 1,5 - do - local f = io.popen("iwinfo " .. get_ifname("wifi") .. " info") - if f then - for line in f:lines() - do - phy = line:match("PHY name:%s*([a-z0-4]+)") - if phy then - break - end - end - f:close() - end - if phy then - break - end - sleep(5) - end - for line in io.lines("/sys/class/ieee80211/" .. phy .. "/macaddress") - do - local m = line:match("(%w%w:%w%w:%w%w:%w%w:%w%w:%w%w)") - if m then - hardware_mac = m - break + local wlan = get_ifname("wifi") + if wlan then + local phy + for i = 1,5 + do + local f = io.popen("iwinfo " .. wlan .. " info") + if f then + for line in f:lines() + do + phy = line:match("PHY name:%s*([a-z0-4]+)") + if phy then + break + end + end + f:close() + end + if phy then + break + end + sleep(5) + end + for line in io.lines("/sys/class/ieee80211/" .. phy .. "/macaddress") + do + local m = line:match("(%w%w:%w%w:%w%w:%w%w:%w%w:%w%w)") + if m then + hardware_mac = m + break + end end end if not hardware_mac then - io.stderr:write("ERROR: hardware mac not found\n") - os.exit(-1) + if not aredn.hardware.has_wifi() then + -- Non wifi device, create a random mac address instead + hardware_mac = capture([[hexdump -n5 -e'/5 "02" 5/1 ":%02X"' /dev/random]]):match("^(%S+)") + -- Disable wifi + os.execute("sed -i -e 's/wifi_enable = 1/wifi_enable = 0/' /etc/config.mesh/_setup") + else + io.stderr:write("ERROR: hardware mac not found\n") + os.exit(-1) + end end end diff --git a/files/www/cgi-bin/admin b/files/www/cgi-bin/admin index adc8e1e1..56efabdd 100755 --- a/files/www/cgi-bin/admin +++ b/files/www/cgi-bin/admin @@ -186,7 +186,7 @@ if os.getenv("REQUEST_METHOD") == "POST" then if not fp then if meta and meta.file then firmfile = meta.file - if firmfile:match("sysupgrade%.bin$") then + if firmfile:match("sysupgrade%.bin$") or firmfile:match("ext4%-combined%.img%.gz$") then -- Uploading a system upgrade - clear out memory early os.execute("/usr/local/bin/upgrade_prepare.sh stop > /dev/null 2>&1") end @@ -226,6 +226,13 @@ serverpaths[#serverpaths + 1] = uciserverpath local hardwaretype = aredn.hardware.get_type() local targettype = conn:call("system", "board", {}).release.target +local local_firmware = "local_firmware.bin" +local firmware_type = "bin" +if targettype:match("x86") then + local_firmware = "local_firmware.img.gz" + firmware_type = "gz" +end + -- handle TPLink and Mikrotik exception conditions local mfg = aredn.hardware.get_manufacturer() local mfgprefix = "" @@ -237,52 +244,6 @@ elseif mfg:match("[Tt][Pp]-[Ll]ink") then mfgprefix = "cpe" end -local hardwaretypev -if hardwaretype == "nanostation-m" then - hardwaretypev = "nano-m" -- Nano XM -elseif hardwaretype == "nanostation-m-xw" then - hardwaretypev = "nano-m-xw" -- Nano XW -elseif hardwaretype == "rb-952ui-5ac2nd" then - hardwaretypev = "rb-nor-flash-16M-ac" -- hAP AC Lite -elseif hardwaretype:match("rb-911g-[25]hpnd") or hardwaretype:match("rb-912uag-[25]hpnd") then - hardwaretypev = "nand-large" -- Basebox 2/5 and QRT 2/5 -elseif hardwaretype:match("rb-l[dfhg]+-[25]nd") or hardwaretype:match("rb-lhg-[25]hpnd") then - hardwaretypev = "rb-nor-flash-16M" -- LHGs & LDFs -elseif mfgprefix == "cpe" then - local hwmodel = aredn.hardware.get_board_id() - if hwmodel:match("CPE210 v1%.[01]") then - hardwaretypev = "210-220-v1" -- v1.0/v1.1 - elseif hwmodel:match("CPE210 v2%.0") then - hardwaretypev = "210-v2" -- v2.0 - elseif hwmodel:match("CPE210 v3%.0") then - hardwaretypev = "210-v3" -- v3.0 - elseif hwmodel:match("CPE220 v2%.0") then - hardwaretypev = "220-v2" -- v3.0 - elseif hwmodel:match("CPE220 v3%.0") then - hardwaretypev = "220-v3" -- v3.0 - elseif hwmodel:match("CPE510 v2%.0") then - hardwaretypev = "510-v2" -- v2.0 - elseif hwmodel:match("CPE510 v3%.0") then - hardwaretypev = "510-v3" -- v3.0 - elseif hwmodel:match("CPE510") then - hardwaretypev = "510-520-v1" -- CPE510 V1.0/v1.1 - elseif hwmodel:match("CPE605") then - hardwaretypev = "605-v1" -- CPE605 V1.0 - elseif hwmodel:match("CPE610 v2%.0") then - hardwaretypev = "610-v2" -- CPE610 V2.0 - elseif hwmodel:match("CPE610") then - hardwaretypev = "610-v1" -- CPE610 V1.0 - elseif hwmodel:match("WBS510 v2%.0") then - mfgprefix="wbs" - hardwaretypev = "510-v2" -- WBS510 v2.0 - elseif hwmodel:match("WBS210 v1%.[012]") then - mfgprefix="wbs" - hardwaretypev = "210-v1" -- WBS210 v1.0/v1.1 - end -else - hardwaretypev = hardwaretype -end - -- refresh fw if parms.button_refresh_fw then nixio.fs.remove("/tmp/web/firmware.list") @@ -393,10 +354,14 @@ if f then end -- sideload fw -if parms.button_apply_fw and nixio.fs.stat("/tmp/web/local_firmware.bin") then +if parms.button_apply_fw and nixio.fs.stat("/tmp/web/" .. local_firmware) then nixio.fs.mkdir("/tmp/web/upload") - os.execute("mv -f /tmp/web/local_firmware.bin /tmp/web/upload/file") - firmfile = "arednmesh-sideload-sysupgrade.bin" + os.execute("mv -f /tmp/web/" .. local_firmware .. " /tmp/web/upload/file") + if firmware_type == "gz" then + firmfile = "arednmesh-sideload-ext4-combined.img.gz" + else + firmfile = "arednmesh-sideload-sysupgrade.bin" + end parms.button_ul_fw = "Upload" os.execute("/usr/local/bin/upgrade_prepare.sh stop > /dev/null 2>&1") end @@ -404,7 +369,7 @@ end -- upload fw if parms.button_ul_fw and nixio.fs.stat("/tmp/web/upload/file") then os.execute("mv -f /tmp/web/upload/file " .. tmpdir .. "/firmware") - if firmfile:match("sysupgrade%.bin$") then -- full firmware + if firmware_type == "bin" and firmfile:match("sysupgrade%.bin$") then -- full firmware fw_install = true -- drop the page cache to take pressure off tmps when checking the firmware write_all("/proc/sys/vm/drop_caches", "3") @@ -419,6 +384,8 @@ if parms.button_ul_fw and nixio.fs.stat("/tmp/web/upload/file") then fwout("Failed to restart all services, please reboot this node.") end end + elseif firmware_type == "gz" and firmfile:match("ext4%-combined%.img%.gz$") then -- full x86 firmware + fw_install = true else fwout("Firmware CANNOT be updated") fwout("the uploaded file is not recognized") @@ -448,7 +415,7 @@ if parms.button_dl_fw and parms.dl_fw ~= "default" then local fwimage for _, image in ipairs(fwinfo.images) do - if image.type == "sysupgrade" or image.type == "nand-sysupgrade" then + if (firmware.type == "bin" and (image.type == "sysupgrade" or image.type == "nand-sysupgrade")) or (firmware_type == "gz" and image.type == "combined") then fwimage = { url = fw_versions[parms.dl_fw].target .. "/" .. image.name, sha = image.sha256 @@ -468,7 +435,7 @@ if parms.button_dl_fw and parms.dl_fw ~= "default" then end end else - err = "sysupgrade is not available" + err = "upgrade is not available" end else err = "the downloaded file cannot be found" @@ -844,7 +811,7 @@ end html.print("") html.print("Upload Firmware") -html.print("") +html.print("") html.print("") html.print("") @@ -864,8 +831,8 @@ html.print("") html.print("") html.print("Load Local Firmware") html.print("") -html.print("") -html.print(" /tmp/web/local_firmware.bin") +html.print("") +html.print(" /tmp/web/" .. local_firmware .. "") html.print("") html.print("") diff --git a/files/www/cgi-bin/setup b/files/www/cgi-bin/setup index e14256a0..115b22ff 100755 --- a/files/www/cgi-bin/setup +++ b/files/www/cgi-bin/setup @@ -175,6 +175,7 @@ wan_gw = "" passwd1 = "" passwd2 = "" +local haswifi = aredn.hardware.has_wifi() local wifiintf = aredn.hardware.get_iface_name("wifi") local phy = iwinfo.nl80211.phyname(wifiintf) local phycount = tonumber(capture("ls -1d /sys/class/ieee80211/* | wc -l"):chomp()) @@ -226,8 +227,8 @@ end if parms.button_default then local node = aredn_info.get_nvram("node") - local mac2 = mac_to_ip(aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("wifi")), 0) - local dtdmac = mac_to_ip(aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("lan")), 0) + local mac2 = aredn_info.get_nvram("mac2") + local dtdmac = aredn_info.get_nvram("dtdmac") for line in io.lines("/etc/config.mesh/_setup.default") do if not (line:match("^%s*#") or line:match("^%s*$")) then @@ -246,8 +247,8 @@ else end if parms.button_reset or not has_parms then local node = aredn_info.get_nvram("node") - local mac2 = mac_to_ip(aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("wifi")), 0) - local dtdmac = mac_to_ip(aredn.hardware.get_interface_mac(aredn.hardware.get_iface_name("lan")), 0) + local mac2 = aredn_info.get_nvram("mac2") + local dtdmac = aredn_info.get_nvram("dtdmac") for line in io.lines("/etc/config.mesh/_setup") do if not (line:match("^%s*#") or line:match("^%s*$")) then @@ -535,20 +536,20 @@ if parms.button_save then if not valid then err("invalid Mesh RF channel") end - end - local wifi_country_validated = false - local countries = { "00","HX","AD","AE","AL","AM","AN","AR","AT","AU","AW","AZ","BA","BB","BD","BE","BG","BH","BL","BN","BO","BR","BY","BZ","CA","CH","CL","CN","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GE","GB","GD","GR","GL","GT","GU","HN","HK","HR","HT","HU","ID","IE","IL","IN","IS","IR","IT","JM","JP","JO","KE","KH","KP","KR","KW","KZ","LB","LI","LK","LT","LU","LV","MC","MA","MO","MK","MT","MY","MX","NL","NO","NP","NZ","OM","PA","PE","PG","PH","PK","PL","PT","PR","QA","RO","RS","RU","RW","SA","SE","SG","SI","SK","SV","SY","TW","TH","TT","TN","TR","UA","US","UY","UZ","VE","VN","YE","ZA","ZW" } - for _,country in ipairs(countries) - do - if country == wifi_country then - wifi_country_validated = true - break + local wifi_country_validated = false + local countries = { "00","HX","AD","AE","AL","AM","AN","AR","AT","AU","AW","AZ","BA","BB","BD","BE","BG","BH","BL","BN","BO","BR","BY","BZ","CA","CH","CL","CN","CO","CR","CY","CZ","DE","DK","DO","DZ","EC","EE","EG","ES","FI","FR","GE","GB","GD","GR","GL","GT","GU","HN","HK","HR","HT","HU","ID","IE","IL","IN","IS","IR","IT","JM","JP","JO","KE","KH","KP","KR","KW","KZ","LB","LI","LK","LT","LU","LV","MC","MA","MO","MK","MT","MY","MX","NL","NO","NP","NZ","OM","PA","PE","PG","PH","PK","PL","PT","PR","QA","RO","RS","RU","RW","SA","SE","SG","SI","SK","SV","SY","TW","TH","TT","TN","TR","UA","US","UY","UZ","VE","VN","YE","ZA","ZW" } + for _,country in ipairs(countries) + do + if country == wifi_country then + wifi_country_validated = true + break + end + end + if not wifi_country_validated then + wifi_country = "00" + err("Invalid country") end - end - if not wifi_country_validated then - wifi_country = "00" - err("Invalid country") end if lan_proto == "static" then @@ -1035,7 +1036,7 @@ html.print([[ ]]) -- reset wifi channel/bandwidth to default -if nixio.fs.stat("/etc/config/unconfigured") or parms.button_reset then +if haswifi and (nixio.fs.stat("/etc/config/unconfigured") or parms.button_reset) then local defaultwifi = aredn.hardware.get_default_channel(wifiintf) wifi_channel = defaultwifi.channel wifi_chanbw = tostring(defaultwifi.bandwidth) @@ -1043,16 +1044,22 @@ end -- mesh rf settings html.print("") -html.print("") +if haswifi then + html.print("") +else + html.print("") +end hidden[#hidden + 1] = "" -- add enable/disable -html.print("") end -html.print(">") html.print("") if wifi_enable == "1" then diff --git a/files/www/cgi-bin/status b/files/www/cgi-bin/status index c3f76c6c..86f03881 100755 --- a/files/www/cgi-bin/status +++ b/files/www/cgi-bin/status @@ -153,11 +153,12 @@ if config == "" or nixio.fs.stat("/etc/config.mesh", "type") ~= "dir" then config = "not set" end +local haswifi = aredn.hardware.has_wifi() local wifi_iface = aredn.hardware.get_iface_name("wifi") local wifi_nr = wifi_iface:match("wlan(%d+)") local wifi_disabled = true local radio = "radio0" -if wifi_nr then +if haswifi and wifi_nr then wifi_disabled = false radio = "radio" .. wifi_nr end @@ -260,7 +261,7 @@ if config == "not set" then config_mode = "ram" for line in io.lines("/proc/mounts") do - if line:match("overlay") then + if line:match("overlay") or line:match("ext4") then config_mode = "setup" break end @@ -305,12 +306,18 @@ local col2 = {} -- left column - network interface info local ip = cursor:get("network", "wifi", "ipaddr") -local cidr = netmask_to_cidr(cursor:get("network", "wifi", "netmask")) -if wifi_disabled then - col1[#col1 + 1] = "" + cidr = netmask_to_cidr(mask) + if wifi_disabled then + col1[#col1 + 1] = "" + end end ip = cursor:get("network", "lan", "ipaddr") diff --git a/patches/751-x86.patch b/patches/751-x86.patch new file mode 100755 index 00000000..1fbb1381 --- /dev/null +++ b/patches/751-x86.patch @@ -0,0 +1,14 @@ +--- a/target/linux/x86/base-files/etc/board.d/02_network ++++ b/target/linux/x86/base-files/etc/board.d/02_network +@@ -45,6 +45,11 @@ + macaddr="$(cat /sys/class/net/eth0/address)" 2>/dev/null + [ -n "$macaddr" ] && ucidef_set_interface_macaddr "wan" "$macaddr" + ;; ++*) ++ ucidef_set_interfaces_lan_wan "eth0" "eth0.1" ++ ucidef_set_interface "dtdlink" device "eth0.2" protocol "static" ++ ;; ++ + esac + board_config_flush + diff --git a/patches/series b/patches/series index 47c99f84..861f84ae 100644 --- a/patches/series +++ b/patches/series @@ -36,5 +36,6 @@ 749-fix-tiny.patch 749-ubiquiti-extra-support.patch 750-ibss-2g-fix.patch +751-x86.patch 800-upgrade-compatibility.patch 801-mikrotik-lhg-variants.patch
Mesh RF (" .. (M3model and "3GHz" or M9model and "900MHz" or wifi_channel < 36 and "2GHz" or "5GHz") .. ")
Mesh RF (" .. (M3model and "3GHz" or M9model and "900MHz" or wifi_channel < 36 and "2GHz" or "5GHz") .. ")
Mesh
EnableEnable
IP Address
Netmask
primary address:" .. ip .. " / " .. cidr .. "
" +local mask = cursor:get("network", "wifi", "netmask") +local cidr +if not ip or not mask then + col1[#col1 + 1] = "
primary address:none
" else - wifi_gw = get_default_gw("wifi") - col1[#col1 + 1] = "
mesh RF address:
mesh gateway:
gateway node:
SSID:
channel:
channel width:
" .. ip .. " / " .. cidr .. "
" .. wifi_gw .. "
" .. mesh_ip_to_hostnames(wifi_gw) .. "
" .. wifi_ssid .. "
" .. wifi_channel .. "
" .. wifi_chanbw .. " MHz
primary address:" .. ip .. " / " .. cidr .. "
" + else + wifi_gw = get_default_gw("wifi") + col1[#col1 + 1] = "
mesh RF address:
mesh gateway:
gateway node:
SSID:
channel:
channel width:
" .. ip .. " / " .. cidr .. "
" .. wifi_gw .. "
" .. mesh_ip_to_hostnames(wifi_gw) .. "
" .. wifi_ssid .. "
" .. wifi_channel .. "
" .. wifi_chanbw .. " MHz