Developing lightweight computation at the DSG edge

Commit 0bab1460 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[qmp-system] Several changes on /etc/config/qmp and web GUI

 · Drop community_id and community_node_id and replace it with community_name, mesh_name, device_name and mesh_id when appropriate
 · Revamp qMp easy setup
 · Rename node to device to avoid confusions (node == physical/geographical location, device == router)
parent 7e81697e
......@@ -25,9 +25,9 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
QMP_RELEASE?=r20161111-1
QMP_RELEASE?=r$(shell date +%Y%m%d-%H%M)
QMP_CODENAME?=testing
QMP_BUILDDATE:=$(shell date +%Y%m%d_%H%M)
QMP_BUILDDATE:=$(shell date +%Y%m%d-%H%M)
PKG_NAME:=qmp-system
PKG_VERSION:=$(QMP_RELEASE)
......
......@@ -29,10 +29,10 @@ config 'qmp' 'node'
option primary_device 'eth0'
# The node name (human readable).
option community_id 'qMp'
option device_name 'qMp'
# The node id (2 hex digits). Leave blank to use crc16 from MAC address.
option community_node_id ''
option device_id ''
# Temporay key file for session (autogenerated in each boot).
option key '/tmp/qmp_key'
......
......@@ -245,10 +245,11 @@ qmp_get_crc16() {
# qmp_get_id [8bit]
qmp_get_id() {
local community_node_id="$(qmp_uci_get node.community_node_id)"
[ -z "$community_node_id" ] && \
community_node_id="$(qmp_get_crc16)"
[ "$1" == "8bit" ] && echo "$(( 0x$community_node_id % 0x100 ))" || echo "$community_node_id"
local device_id="$(qmp_uci_get node.device_id)"
device_id="$(echo -n $device_id | tr -cd 'ABCDEFabcdef0123456789' | tail -c 4)"
[ -z "$device_id" ] && \
device_id="$(qmp_get_crc16)"
[ "$1" == "8bit" ] && echo "$(( 0x$device_id % 0x100 ))" || echo "$device_id"
}
# qmp_get_id_ip <1,2>
......@@ -282,12 +283,12 @@ qmp_get_dec_node_id() {
PRIMARY_MESH_DEVICE="$(uci get qmp.interfaces.mesh_devices | awk '{print $1}')"
LSB_PRIM_MAC="$( qmp_get_mac_for_dev $PRIMARY_MESH_DEVICE | awk -F':' '{print $6}' )"
if qmp_uci_test qmp.node.community_node_id; then
COMMUNITY_NODE_ID="$(uci get qmp.node.community_node_id)"
if qmp_uci_test qmp.node.device_id; then
DEVICE_ID="$(uci get qmp.node.device_id)"
elif ! [ -z "$PRIMARY_MESH_DEVICE" ] ; then
COMMUNITY_NODE_ID=$LSB_PRIM_MAC
DEVICE_ID=$LSB_PRIM_MAC
fi
echo $(printf %d 0x$COMMUNITY_NODE_ID)
echo $(printf %d 0x$DEVICE_ID)
}
# Returns the prefix /XX from netmask
......
......@@ -789,8 +789,8 @@ fi
local primary_mesh_device="$(qmp_get_primary_device)"
local community_node_id=$(qmp_get_id)
local device_id=$(qmp_get_id)
device_id="$(echo -n $device_id | tr -cd 'ABCDEFabcdef0123456789' | tail -c 4)"
if qmp_uci_test qmp.interfaces.mesh_devices &&
qmp_uci_test qmp.networks.mesh_protocol_vids
......@@ -866,10 +866,10 @@ fi
if qmp_uci_test qmp.networks.bmx6_ripe_prefix48 ; then
uci set $conf.general.tun6Address="$(uci get qmp.networks.bmx6_ripe_prefix48):$community_node_id:0:0:0:1/64"
uci set $conf.general.tun6Address="$(uci get qmp.networks.bmx6_ripe_prefix48):$device_id:0:0:0:1/64"
uci set $conf.tmain=tunDev
uci set $conf.tmain.tunDev=tmain
uci set $conf.tmain.tun6Address="$(qmp_uci_get networks.bmx6_ripe_prefix48):$community_node_id:0:0:0:1/64"
uci set $conf.tmain.tun6Address="$(qmp_uci_get networks.bmx6_ripe_prefix48):$device_id:0:0:0:1/64"
fi
qmp_configure_bmx6_gateways
......
......@@ -471,7 +471,8 @@ qmp_get_rescue_ip() {
# apply the non-overlapping DHCP-range preset policy
# qmp_configure_dhcp <node_id>
qmp_configure_dhcp() {
local community_node_id="$1"
local device_id="$1"
device_id="$(echo -n $device_id | tr -cd 'ABCDEFabcdef0123456789' | tail -c 4)"
local start=2
local limit=253
local leasetime="$(qmp_uci_get non_overlapping.qmp_leasetime)"
......@@ -485,7 +486,7 @@ qmp_configure_dhcp() {
uci_offset=${uci_offset:-2}
local offset=0
[ $uci_offset -lt $num_grp ] && offset=$uci_offset
start=$(( 0x$community_node_id * $num_grp + $offset ))
start=$(( 0x$device_id * $num_grp + $offset ))
limit=$(( $num_grp - $offset ))
fi
......
......@@ -8,28 +8,35 @@ SOURCE_SYS=1
qmp_configure_system() {
if [ -n "$(qmp_uci_get node.community_node_id)" ]; then
local community_node_id=$(qmp_uci_get node.community_node_id)
if [ -n "$(qmp_uci_get node.device_id)" ]; then
local device_id=$(qmp_uci_get node.device_id)
device_id="$(echo -n $device_id | tr -cd 'ABCDEFabcdef0123456789' | tail -c 10)"
else
local community_node_id=$(qmp_get_id_hostname)
qmp_uci_set node.community_node_id $community_node_id
local device_id=$(qmp_get_id_hostname)
device_id="$(echo -n $device_id | tr -cd 'ABCDEFabcdef0123456789' | tail -c 4)"
qmp_uci_set node.device_id $device_id
fi
# check if community_node_id is hexadecimal and get last 4 characters
community_node_id="$(echo -n $community_node_id | tr -cd 'ABCDEFabcdef0123456789' | tail -c 4)"
[ $(echo -n $community_node_id | wc -c) -lt 4 ] && {
qmp_log "Warning, community_node_id not defined properly, using failsafe 0000"
community_node_id=0000
[ $(echo -n $device_id | wc -c) -lt 4 ] && {
qmp_log "Warning, device_id not defined properly, using failsafe 0000"
device_id=0000
}
local community_id="$(qmp_uci_get node.community_id)"
[ -z "$community_id" ] && community_id="qmp" && qmp_uci_set node.community_id $community_id
local device_name="$(qmp_uci_get node.device_name)"
[ -z "$device_name" ] && device_name="qMp" && qmp_uci_set node.device_name $device_name
# set hostname
uci set system.@system[0].hostname="${community_id}-${community_node_id}"
local ig_roaming="$(uci get qmp.roaming.ignore)"
if [ $ig_roaming -eq 1 ]; then
uci set system.@system[0].hostname="${device_name}"
echo "${device_name}" > /proc/sys/kernel/hostname
else
uci set system.@system[0].hostname="${device_name}-${device_id}"
echo "${device_name}-${device_id}" > /proc/sys/kernel/hostname
fi
uci commit system
echo "${community_id}-${community_node_id}" > /proc/sys/kernel/hostname
uci set uhttpd.main.listen_http="80"
uci set uhttpd.main.listen_https="443"
......
#!/bin/sh
[ -f /etc/config/qmp ] && {
if uci get qmp.node.community_id; then
uci set qmp.node.device_name=$(uci get qmp.node.community_id)
uci set qmp.node.community_id=""
fi
if uci get qmp.node.community_node_id; then
uci set qmp.node.device_id=$(uci get qmp.node.community_node_id)
uci set qmp.node.community_node_id=""
fi
uci commit
}
......@@ -37,9 +37,9 @@ function index()
-- Rest of entries
entry({"qmp","status"}, template("admin_status/index"), "Status", 2).dependent=false
entry({"qmp","configuration"}, cbi("qmp/easy_setup"), "Node configuration", 4).dependent=false
entry({"qmp","configuration"}, cbi("qmp/easy_setup"), "Device configuration", 4).dependent=false
entry({"qmp","configuration","easy_setup"}, cbi("qmp/easy_setup"), "qMp easy setup", 1).dependent=false
entry({"qmp","configuration","node"}, cbi("qmp/node"), "Basic settings", 2).dependent=false
entry({"qmp","configuration","basic"}, cbi("qmp/basic"), "Basic settings", 2).dependent=false
entry({"qmp","configuration","network"}, cbi("qmp/network"), "Network settings", 3).dependent=false
entry({"qmp","configuration","network","advanced"}, cbi("qmp/network_adv"), "Advanced network settings", 1).dependent=false
entry({"qmp","configuration","wifi"}, cbi("qmp/wireless"), "Wireless settings", 4).dependent=false
......
--[[
Copyright (C) 2011 Fundacio Privada per a la Xarxa Oberta, Lliure i Neutral guifi.net
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; either version 2 of the License, or
(at your option) any later version.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
--]]
require("luci.sys")
local http = require "luci.http"
local uciout = uci.cursor()
m = Map("qmp", "Basic qMp device settings")
local networkmode
if uciout:get("qmp","roaming","ignore") == "1" then
networkmode="community"
else
networkmode="roaming"
end
device_section = m:section(NamedSection, "node", "qmp", translate("Device identity"), translate("Use this page to define basic qMp settings, like the device\'s name, etc."))
device_section.addremove = False
if networkmode == "community" then
community_name = device_section:option(Value, "community_name", translate ("Community Network name"), translate("Select a predefined Community Network or type your own name."))
community_name.datatype="string"
community_name:value("Bogotá Mesh","Bogotá Mesh")
community_name:value("DigitalMerthyr","Digital Merthyr")
community_name:value("Guifi.net","Guifi.net")
guifimesh_name = device_section:option(Value, "mesh_name", translate ("Mesh Network name"), translate("Select a predefined Mesh Network or type your own name."))
guifimesh_name:depends("community_name","Guifi.net")
guifimesh_name.datatype="string"
guifimesh_name:value("GuifiBaix", "Baix Llobregat (GB)")
guifimesh_name:value("Bellvitge", "Bellvitge")
guifimesh_name:value("GraciaSenseFils", "Gràcia Sense Fils (GSF)")
guifimesh_name:value("PoblenouSenseFils", "Poblenou Sense Fils (P9SF)")
guifimesh_name:value("Quesa", "Quesa (QUESA)")
guifimesh_name:value("Raval", "Raval (GuifiBaix)")
guifimesh_name:value("GuifiSants", "Sants-Les Corts-UPC (GS)")
guifimesh_name:value("SantAndreu", "Sant Andreu (SAND)")
guifimesh_name:value("Vallcarca", "Vallcarca (VKK)")
end
device_name = device_section:option(Value,"device_name", translate("Device name"), translate("The name for this device (use alphanumeric characters, without spaces)."))
device_name.default = "qMp"
device_name.datatype = "hostname"
device_name.optional = false
device_id = device_section:option(Value,"device_id", translate("Device id"), translate("The id of this device in the mesh network (use alphanumeric characters, without spaces)."))
device_id.datatype = "string"
device_id.optional = true
primary_device = device_section:option(Value,"primary_device", translate("Primary network device"), translate("The name of the node's primary network device. The last four digits of this device's MAC address will be appended to the node name."))
primary_device.default = "eth0"
primary_device.datatype = "network"
location_section = m:section(NamedSection, "node", "qmp", translate("Device location"))
location_section.addremove = False
geopos_lat = location_section:option(Value,"latitude", translate("Latitude"), translate("Latitude geoposition to use in the maps (optional)."))
geopos_lon = location_section:option(Value,"longitude", translate("Longitude"), translate("Longitude geoposition to use in the maps (optional)."))
geopos_elv = location_section:option(Value,"elevation", translate("Elevation"), translate("Elevation of the node relative to the ground level (optional)."))
contact_section = m:section(NamedSection, "node", "qmp", translate("Contact information"))
contact_section.addremove = False
contact = contact_section:option(Value,"contact", translate("Contact e-mail"), translate("An e-mail to contact you if needed (optional)."))
function m.on_commit(self,map)
http.redirect("/luci-static/resources/qmp/wait_short.html")
luci.sys.exec('/etc/qmp/qmp_control.sh configure_system > /tmp/qmp_control_system.log &')
end
return m
......@@ -29,14 +29,14 @@ local uciout = uci.cursor()
package.path = package.path .. ";/etc/qmp/?.lua"
qmpinfo = require "qmpinfo"
m = SimpleForm("qmp", translate("qMp easy setup"),translate("This page provides a fast and simple way to configure the basic settings of a qMp node.").." "..translate("Use the fields below to specify the network mode, the IP addressing and the interface modes."))
m = SimpleForm("qmp", translate("qMp easy setup"), translate("This page provides a fast and simple way to configure the basic settings of a qMp device.") .. " " .. translate("Use the form below to specify the required settings, such as mesh mode, naming, addressing and interface operation modes."))
local mode_help
mode_help = m:field(DummyValue,"mode_help")
mode_help.rawhtml = true
mode_help.default = "<strong>"..translate("Network mode").."</strong>".."<br/> <br/>"..translate("qMp nodes can operate in two different modes, depending on the kind of network to deploy.").." "..translate("According to your needs, you can choose between")..":<br/> <br/> · "..translate("roaming mode, for quick, temporal deployments. User devices connected to the network can roam between Access Points without loosing connectivity. However, they can not see other devices connected to the Mesh.").."<br/> · "..translate("community mode for static, long-term deployments (such as community networks). User devices connected to the network get an IP address from a specific range and are accessible from the rest of the Mesh. However, roaming between stations is not possible.").."<br/> <br/>"
mode_help.default = "<strong>"..translate("Mesh mode").."</strong>".."<br/> <br/>" .. translate("qMp devices can operate in two different modes, depending on the kind of network to deploy.").." "..translate("According to your needs, you can choose between")..":<br/> <br/> · " .. translate("<i>roaming</i> mode, for quick, temporal or ephemeral deployments") .. "<br/> · " .. translate("<i>community</i> mode for static, long-term deployments such as community networks") .. "<br /> <br >" .. translate ("In <i>roaming</i> mode, end-users' devices can roam between Access Points without losing connectivity. However, they are hidden from other devices in the mesh. In <i>community</i> mode, end-users' devices get an IP address accessible from anywhere in the mesh network.").."<br/> <br/>"
netmode = m:field(ListValue, "_netmode","<strong>"..translate(" ").."</strong>",translate("\"Roaming\" mode for quick, temporal network setups. \"Community\" mode for community networks and long-term deployments."))
netmode = m:field(ListValue, "_netmode","<strong>"..translate(" ").."</strong>",translate("Select <i>roaming</i> or <i>community</i> mode."))
netmode:value("community","community")
netmode:value("roaming","roaming")
......@@ -55,15 +55,84 @@ else
end
netmode.default=networkmode
--Community Network
local communityname_help
communityname_help = m:field(DummyValue,"_communityname_help")
communityname_help.rawhtml = true
communityname_help:depends("_netmode","community")
communityname_help.default = "<strong>"..translate("Community network name").."</strong>".."<br/> <br/>"..translate("The name of the Community Network this device belongs to.").."<br/> <br/>"
local communityname = m:field(Value, "_communityname", " ", translate("Select a predefined Community Network or type your own name."))
communityname:depends("_netmode","community")
communityname.datatype="string"
communityname:value("Bogotá Mesh","Bogotá Mesh")
communityname:value("DigitalMerthyr","Digital Merthyr")
communityname:value("Guifi.net","Guifi.net")
if uciout:get("qmp","node","community_name") ~= nil then
communityname.default=uciout:get("qmp","node","community_name")
end
--Mesh network name, if applicable
local guifimeshname = m:field(Value, "_guifimeshname", " ", translate("Select a predefined Mesh Network or type your own name."))
guifimeshname:depends("_communityname","Guifi.net")
guifimeshname.datatype="string"
guifimeshname.default="GuifiSants"
guifimeshname:value("GuifiBaix", "Baix Llobregat (GB)")
guifimeshname:value("Bellvitge", "Bellvitge")
guifimeshname:value("GraciaSenseFils", "Gràcia Sense Fils (GSF)")
guifimeshname:value("PoblenouSenseFils", "Poblenou Sense Fils (P9SF)")
guifimeshname:value("Quesa", "Quesa (QUESA)")
guifimeshname:value("Raval", "Raval (GuifiBaix)")
guifimeshname:value("GuifiSants", "Sants-Les Corts-UPC (GS)")
guifimeshname:value("SantAndreu", "Sant Andreu (SAND)")
guifimeshname:value("Vallcarca", "Vallcarca (VKK)")
if uciout:get("qmp","node","mesh_name") ~= nil then
guifimeshname.default=uciout:get("qmp","node","mesh_name")
end
--Device name and ID
local devicename_help
local devicename_help = m:field(DummyValue,"_devicename_help")
devicename_help.rawhtml = true
devicename_help.default = "<strong>"..translate("Device name").."</strong>".."<br/> <br/>"..translate("Choose a name for this device. It will be used to identify it in the mesh network.").."<br/> <br/>"
local devicename = m:field(Value, "_devicename", " ", translate("Device name. Use only alphanumeric characters, spaces are not allowed."))
devicename.datatype="hostname"
devicename.optional=false
devicename.default="MyMeshDevice"
if uciout:get("qmp","node","device_name") ~= nil then
devicename.default=uciout:get("qmp","node","device_name")
end
local guifideviceid = m:field(Value, "_guifideviceid", " ", translate("Device ID in Guifi.net's web site. Use numbers only."))
guifideviceid:depends({_communityname = "Guifi.net"})
guifideviceid.datatype="uinteger"
if uciout:get("qmp","node","device_id") ~= nil then
guifideviceid.default=uciout:get("qmp","node","device_id")
end
local roaming_ipaddress_help
roaming_ipaddress_help = m:field(DummyValue,"roaming_ipaddress_help")
roaming_ipaddress_help.rawhtml = true
roaming_ipaddress_help:depends("_netmode","roaming")
roaming_ipaddress_help.default = "<strong>"..translate("IP address").."</strong>".."<br/> <br/>"..translate("Specify here an IP address for this node.").." "..translate("In roaming mode, all qMp nodes in a mesh network need a unique IPv4 address.").." "..translate("If unsure about which one to select, leave the field blank and a random one will be assigned automatically.").."<br/> <br/>"
roaming_ipaddress_help.default = "<strong>"..translate("IP address and network mask").."</strong>".."<br/> <br/>"..translate("Specify here an IP address for this device.").." "..translate("In roaming mode, all qMp devices in a mesh network need a unique IPv4 address.").." "..translate("If unsure about which one to select, leave the field blank and a random one will be assigned automatically.").."<br/> <br/>"
local nodeip_roaming = m:field(Value, "_nodeip_roaming", " ",
translate("Main IPv4 address for this node.").." "..translate("Leave it blank to get a random one."))
translate("Main IPv4 address for this device.").." "..translate("Leave it blank to get a random one."))
nodeip_roaming:depends("_netmode","roaming")
......@@ -78,31 +147,18 @@ end
nodeip_roaming.default=rip
nodeip_roaming.datatype="ip4prefix"
local community_name_help
community_name_help = m:field(DummyValue,"community_name_help")
community_name_help.rawhtml = true
community_name_help:depends("_netmode","community")
community_name_help.default = "<strong>"..translate("Node name").."</strong>".."<br/> <br/>"..translate("Choose a name for this node. It will be used to identify the device in the network. Use only alphanumeric characters, spaces are not allowed.").."<br/> <br/>"
local nodename = m:field(Value, "_nodename", " ",
translate("The name of this node. Four hex numbers will be appended, according the the device's MAC address."))
nodename:depends("_netmode","community")
nodename.default="qMp"
nodename.datatype="hostname"
if uciout:get("qmp","node","community_id") ~= nil then
nodename.default=uciout:get("qmp","node","community_id")
end
local community_addressing_help
community_addressing_help = m:field(DummyValue,"community_addressing_help")
community_addressing_help.rawhtml = true
community_addressing_help:depends("_netmode","community")
community_addressing_help.default = "<strong>"..translate("IP address and network mask").."</strong>".."<br/> <br/>"..translate("Specify the IP address and the network mask for this node, according to the planification of your community or your network deployment.").." "..translate("End-user devices will get an IP address within the valid range determined by these two values.").."<br/> <br/>"
community_addressing_help.default = "<strong>"..translate("IP address and network mask").."</strong>".."<br/> <br/>"..translate("Specify the IP address and the network mask for this device, according to the planification of your community or your network deployment.").." "..translate("End-user devices will get an IP address within the valid range determined by these two values.").."<br/> <br/>"
local nodeip = m:field(Value, "_nodeip", " ",
translate("Main IPv4 address for this node."))
translate("Main IPv4 address for this device."))
nodeip:depends("_netmode","community")
nodeip.default = "10.30."..util.trim(util.exec("echo $((($(date +%M)*$(date +%S)%254)+1))"))..".1"
......@@ -111,13 +167,20 @@ nodeip.datatype="ip4addr"
local nodemask = m:field(Value, "_nodemask"," ",
translate("Network mask to be used with the IPv4 address above."))
nodemask:depends("_netmode","community")
nodemask.default = "255.255.255.0"
nodemask.default = "255.255.255.224"
nodemask:value("255.255.255.0", "255.255.255.0 (/24, 254 hosts)")
nodemask:value("255.255.255.128", "255.255.255.128 (/25, 126 hosts)")
nodemask:value("255.255.255.192", "255.255.255.192 (/26, 62 hosts)")
nodemask:value("255.255.255.224", "255.255.255.224 (/27, 30 hosts)")
nodemask:value("255.255.255.240", "255.255.255.240 (/28, 14 hosts)")
nodemask:value("255.255.255.248", "255.255.255.248 (/29, 6 hosts)")
nodemask.datatype="ip4addr"
local interface_mode_help
interface_mode_help = m:field(DummyValue,"interface_mode_help")
interface_mode_help.rawhtml = true
interface_mode_help.default = "<strong>"..translate("Interface modes").."</strong>".."<br/> <br/>"..translate("Select the working mode of the network interfaces")..":<br/> <br/> · "..translate("LAN mode is used to provide connectivity to end-users (a DHCP server will be enabled to assign IP addresses to the devices connecting)").."<br/> · "..translate("WAN mode is used on interfaces connected to an Internet up-link or any other gateway connection").."<br/> · "..translate("Mesh mode is used on wireless interfaces to join the qMp mesh and, on wired interfaces, to link with other qMp nodes").."<br/> · "..translate("AP mode is used on wireless interfaces to act as an access point and provide connectivity to end-users").."<br/> <br/>"
interface_mode_help.default = "<strong>"..translate("Interface modes").."</strong>".."<br/> <br/>"..translate("Select the working mode of the network interfaces")..":<br/> <br/> · "..translate("LAN mode is used to provide connectivity to end-users (a DHCP server will be enabled to assign IP addresses to the devices connecting)").."<br/> · "..translate("WAN mode is used on interfaces connected to an Internet up-link or any other gateway connection").."<br/> · "..translate("Mesh mode is used on wireless interfaces to join the qMp mesh and, on wired interfaces, to link with other qMp devices").."<br/> · "..translate("AP mode is used on wireless interfaces to act as an access point and provide connectivity to end-users").."<br/> <br/>"
if networkmode == "community" then
nodeip.default=uciout:get("qmp","networks","lan_address")
......@@ -195,19 +258,30 @@ end
function netmode.write(self, section, value)
local name = nodename:formvalue(section)
local device_name = devicename:formvalue(section)
local mode = netmode:formvalue(section)
local nodeip = nodeip:formvalue(section)
local nodemask = nodemask:formvalue(section)
local nodeip_roaming = nodeip_roaming:formvalue(section)
if mode == "community" then
local community_name = communityname:formvalue(section)
uciout:set("qmp","roaming","ignore","1")
uciout:set("qmp","networks","publish_lan","1")
uciout:set("qmp","networks","lan_address",nodeip)
uciout:set("qmp","networks","bmx6_ipv4_address",ip.IPv4(nodeip,nodemask):string())
uciout:set("qmp","networks","lan_netmask",nodemask)
uciout:set("qmp","node","community_id",name)
uciout:set("qmp","node","device_name",device_name)
uciout:set("qmp","node","community_name",community_name)
if community_name == "Guifi.net" then
local mesh_name = guifimeshname:formvalue(section)
local device_id = guifideviceid:formvalue(section)
uciout:set("qmp","node","mesh_name",mesh_name)
uciout:set("qmp","node","device_id",device_id)
end
else
uciout:set("qmp","roaming","ignore","0")
......
--[[
Copyright (C) 2011 Fundacio Privada per a la Xarxa Oberta, Lliure i Neutral guifi.net
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; either version 2 of the License, or
(at your option) any later version.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
--]]
require("luci.sys")
local http = require "luci.http"
m = Map("qmp", "qMp node basic settings")
node_section = m:section(NamedSection, "node", "qmp", translate("Node identity"), translate("Use this page to define basic qMp settings, like the node\'s name."))
node_section.addremove = False
community_id = node_section:option(Value,"community_id", translate("Node name"), translate("The name for this node (use alphanumeric characters, without spaces)."))
community_id.default = "qMp"
community_id.datatype = "hostname"
primary_device = node_section:option(Value,"primary_device", translate("Primary network device"), translate("The name of the node's primary network device. The last four digits of this device's MAC address will be appended to the node name."))
primary_device.default = "eth0"
primary_device.datatype = "network"
geopos_lat = node_section:option(Value,"latitude", translate("Latitude"), translate("Latitude geoposition to use in the maps (optional)."))
geopos_lon = node_section:option(Value,"longitude", translate("Longitude"), translate("Longitude geoposition to use in the maps (optional)."))
geopos_elv = node_section:option(Value,"elevation", translate("Elevation"), translate("Elevation of the node relative to the ground level (optional)."))
contact = node_section:option(Value,"contact", translate("Contact e-mail"), translate("An e-mail to contact you if needed (optional)."))
function m.on_commit(self,map)
http.redirect("/luci-static/resources/qmp/wait_short.html")
luci.sys.exec('/etc/qmp/qmp_control.sh configure_system > /tmp/qmp_control_system.log &')
end
return m
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