Timezone information is updated to 2015d, released on 24 Apr 2015.
# Version == major.minor.patch
# increase on new functionality (minor) or patches (patch)
-PKG_VERSION:=2.2.3
+PKG_VERSION:=2.2.4
# Release == build
# increase on changes of translation files
-- compare versions using "<=" "<" ">" ">=" "=" "<<" ">>"
function ipkg_ver_compare(ver1, comp, ver2)
- if not ver1 or not (#ver1 > 0)
- or not ver2 or not (#ver2 > 0)
+ if not ver1 or not ver2
or not comp or not (#comp > 0) then return nil end
-- correct compare string
if comp == "<>" or comp == "><" or comp == "!=" or comp == "~=" then comp = "~="
for i = 1, math.max(table.getn(av1),table.getn(av2)), 1 do
local s1 = av1[i] or ""
local s2 = av2[i] or ""
- local n1 = tonumber(s1)
- local n2 = tonumber(s2)
- -- one numeric and other empty string then set other to 0
- if n1 and not n2 and (not s2 or #s2 == 0) then n2 = 0 end
- if n2 and not n1 and (not s1 or #s1 == 0) then n1 = 0 end
-
- local nc = (n1 and n2) -- numeric compare
-
- if nc then
- -- first "not equal" found return true
- if comp == "~=" and (n1 ~= n2) then return true end
- -- first "lower" found return true
- if (comp == "<" or comp == "<=") and (n1 < n2) then return true end
- -- first "greater" found return true
- if (comp == ">" or comp == ">=") and (n1 > n2) then return true end
- -- not equal then return false
- if (n1 ~= n2) then return false end
- else
- if comp == "~=" and (s1 ~= s2) then return true end
- if (comp == "<" or comp == "<=") and (s1 < s2) then return true end
- if (comp == ">" or comp == ">=") and (s1 > s2) then return true end
- if (s1 ~= s2) then return false end
- end
+ -- first "not equal" found return true
+ if comp == "~=" and (s1 ~= s2) then return true end
+ -- first "lower" found return true
+ if (comp == "<" or comp == "<=") and (s1 < s2) then return true end
+ -- first "greater" found return true
+ if (comp == ">" or comp == ">=") and (s1 > s2) then return true end
+ -- not equal then return false
+ if (s1 ~= s2) then return false end
end
- -- all equal then true
- return true
+
+ -- all equal and not compare greater or lower then true
+ return not (comp == "<" or comp == ">")
end
-- read version information for given package if installed
commit ucitrack
EOF
-if [ -f /usr/bin/fwknop ]; then
- uci set fwknopd.@access[0].keytype='Base 64 key'
- uci set fwknopd.@access[0].hkeytype='Base 64 key'
- uci set fwknopd.@access[0].KEY_BASE64=`fwknop --key-gen | awk '/^KEY/ {print $2;}'`
- uci set fwknopd.@access[0].HMAC_KEY_BASE64=`fwknop --key-gen | awk '/^HMAC/ {print $2;}'`
- uci commit fwknopd
-fi
+uci set fwknopd.@access[0].keytype='Base 64 key'
+uci set fwknopd.@access[0].hkeytype='Base 64 key'
+uci set fwknopd.@access[0].KEY_BASE64=`fwknopd --key-gen | awk '/^KEY/ {print $2;}'`
+uci set fwknopd.@access[0].HMAC_KEY_BASE64=`fwknopd --key-gen | awk '/^HMAC/ {print $2;}'`
+uci commit fwknopd
rm -f /tmp/luci-indexcache
exit 0
function action_json()
local http = require "luci.http"
local utl = require "luci.util"
- local uci = require "luci.model.uci".cursor_state()
+ local uci = require "luci.model.uci".cursor()
local jsonreq4
local jsonreq6
- jsonreq4 = utl.exec("echo /status | nc 127.0.0.1 9090")
- jsonreq6 = utl.exec("echo /status | nc ::1 9090")
+ local v4_port = uci:get("olsrd", "olsrd_jsoninfo", "port") or 9090
+ local v6_port = uci:get("olsrd6", "olsrd_jsoninfo", "port") or 9090
+
+ jsonreq4 = utl.exec("(echo /status | nc 127.0.0.1 " .. v4_port .. ") 2>/dev/null" )
+ jsonreq6 = utl.exec("(echo /status | nc ::1 " .. v6_port .. ") 2>/dev/null")
http.prepare_content("application/json")
if not jsonreq4 or jsonreq4 == "" then
jsonreq4 = "{}"
local IpVersion = uci:get_first("olsrd", "olsrd","IpVersion")
local jsonreq4 = ""
local jsonreq6 = ""
- jsonreq4 = utl.exec("echo /" .. otable .. " | nc 127.0.0.1 9090")
- jsonreq6 = utl.exec("echo /" .. otable .. " | nc ::1 9090")
+ local v4_port = uci:get("olsrd", "olsrd_jsoninfo", "port") or 9090
+ local v6_port = uci:get("olsrd6", "olsrd_jsoninfo", "port") or 9090
+
+ jsonreq4 = utl.exec("(echo /" .. otable .. " | nc 127.0.0.1 " .. v4_port .. ") 2>/dev/null")
+ jsonreq6 = utl.exec("(echo /" .. otable .. " | nc ::1 " .. v6_port .. ") 2>/dev/null")
local jsondata4 = {}
local jsondata6 = {}
local data4 = {}
-%>
<%
-local ipv = luci.model.uci.cursor():get_first("olsrd", "olsrd", "IpVersion", "4")
+
+has_ipv4_conf = luci.model.uci.cursor():get_first("olsrd", "olsrd", "IpVersion")
+has_ipv6_conf = luci.model.uci.cursor():get_first("olsrd6", "olsrd", "IpVersion")
function write_conf(conf, file)
local fs = require "nixio.fs"
conf = luci.http.formvalue()
-if conf.openwrt then
+if conf.openwrt_v4 then
write_conf("/etc/config/olsrd", "olsrd")
return false
end
-if conf.conf_v4 then
- write_conf("/var/etc/olsrd.conf.ipv4", "olsrd.conf.ipv4")
+if conf.openwrt_v6 then
+ write_conf("/etc/config/olsrd6", "olsrd6")
return false
end
-if conf.conf_v6 then
- write_conf("/var/etc/olsrd.conf.ipv6", "olsrd.conf.ipv6")
+if conf.conf_v4 then
+ write_conf("/var/etc/olsrd.conf", "olsrd.conf")
return false
end
-if conf.conf then
- write_conf("/var/etc/olsrd.conf", "olsrd.conf")
+if conf.conf_v6 then
+ write_conf("/var/etc/olsrd6.conf", "olsrd6.conf")
return false
end
<span id="version">-<span>
</td></tr>
<tr><td width="33%"><%:Download Config%></td><td>
- <a href="<%=REQUEST_URI%>?openwrt">OpenWrt</a>,
- <% if ipv == "6and4" then %>
- <a href="<%=REQUEST_URI%>?conf_v4">OLSRD IPv4</a>,
- <a href="<%=REQUEST_URI%>?conf_v6">OLSRD IPv6</a>
- <% else %>
- <a href="<%=REQUEST_URI%>?conf">OLSRD</a>
- <% end %>
+ <% if has_ipv4_conf then %>
+ <a href="<%=REQUEST_URI%>?openwrt_v4">OpenWrt (IPv4)</a>,
+ <% end %>
+ <% if has_ipv6_conf then %>
+ <a href="<%=REQUEST_URI%>?openwrt_v6">OpenWrt (IPv6)</a>,
+ <% end %>
+ <% if has_ipv4_conf then %>
+ <a href="<%=REQUEST_URI%>?conf_v4">OLSRD (IPv4)</a>,
+ <% end %>
+ <% if has_ipv6_conf then %>
+ <a href="<%=REQUEST_URI%>?conf_v6">OLSRD (IPv6)</a>
+ <% end %>
</td></tr>
</table>
</fieldset>
# Version == major.minor.patch
# increase "minor" on new functionality and "patch" on patches/optimization
-PKG_VERSION:=1.0.3
+PKG_VERSION:=1.0.4
# Release == build
# increase on changes of translation files
-- compare versions using "<=" "<" ">" ">=" "=" "<<" ">>"
function ipkg_ver_compare(ver1, comp, ver2)
- if not ver1 or not (#ver1 > 0)
- or not ver2 or not (#ver2 > 0)
+ if not ver1 or not ver2
or not comp or not (#comp > 0) then return nil end
-- correct compare string
if comp == "<>" or comp == "><" or comp == "!=" or comp == "~=" then comp = "~="
for i = 1, math.max(table.getn(av1),table.getn(av2)), 1 do
local s1 = av1[i] or ""
local s2 = av2[i] or ""
- local n1 = tonumber(s1)
- local n2 = tonumber(s2)
-
- -- one numeric and other empty string then set other to 0
- if n1 and not n2 and (not s2 or #s2 == 0) then n2 = 0 end
- if n2 and not n1 and (not s1 or #s1 == 0) then n1 = 0 end
-
- local nc = (n1 and n2) -- numeric compare
-
- if nc then
- -- first "not equal" found return true
- if comp == "~=" and (n1 ~= n2) then return true end
- -- first "lower" found return true
- if (comp == "<" or comp == "<=") and (n1 < n2) then return true end
- -- first "greater" found return true
- if (comp == ">" or comp == ">=") and (n1 > n2) then return true end
- -- not equal then return false
- if (n1 ~= n2) then return false end
- else
- if comp == "~=" and (s1 ~= s2) then return true end
- if (comp == "<" or comp == "<=") and (s1 < s2) then return true end
- if (comp == ">" or comp == ">=") and (s1 > s2) then return true end
- if (s1 ~= s2) then return false end
- end
+
+ -- first "not equal" found return true
+ if comp == "~=" and (s1 ~= s2) then return true end
+ -- first "lower" found return true
+ if (comp == "<" or comp == "<=") and (s1 < s2) then return true end
+ -- first "greater" found return true
+ if (comp == ">" or comp == ">=") and (s1 > s2) then return true end
+ -- not equal then return false
+ if (s1 ~= s2) then return false end
end
- -- all equal then true
- return true
+
+ -- all equal and not compare greater or lower then true
+ return not (comp == "<" or comp == ">")
end
-- read version information for given package if installed
local f = SimpleForm("_no_config")
f.title = TITLE
f.description = DESC
+ f.embedded = true
f.submit = false
f.reset = false
dsth:value("", translate("all"))
wa.cbi_add_knownips(dsth)
-l7 = s:option(ListValue, "layer7", translate("Service"))
-l7.rmempty = true
-l7:value("", translate("all"))
-
-local pats = io.popen("find /etc/l7-protocols/ -type f -name '*.pat'")
-if pats then
- local l
- while true do
- l = pats:read("*l")
- if not l then break end
-
- l = l:match("([^/]+)%.pat$")
- if l then
- l7:value(l)
- end
- end
- pats:close()
-end
-
p = s:option(Value, "proto", translate("Protocol"))
p:value("", translate("all"))
p:value("tcp", "TCP")
# Version == major.minor.patch
# increase "minor" on new functionality and "patch" on patches/optimization
-PKG_VERSION:=1.0.0
+PKG_VERSION:=1.0.1
# Release == build
# increase on changes of translation files
-- compare versions using "<=" "<" ">" ">=" "=" "<<" ">>"
function ipkg_ver_compare(ver1, comp, ver2)
- if not ver1 or not (#ver1 > 0)
- or not ver2 or not (#ver2 > 0)
+ if not ver1 or not ver2
or not comp or not (#comp > 0) then return nil end
-- correct compare string
if comp == "<>" or comp == "><" or comp == "!=" or comp == "~=" then comp = "~="
for i = 1, math.max(table.getn(av1),table.getn(av2)), 1 do
local s1 = av1[i] or ""
local s2 = av2[i] or ""
- local n1 = tonumber(s1)
- local n2 = tonumber(s2)
-
- -- one numeric and other empty string then set other to 0
- if n1 and not n2 and (not s2 or #s2 == 0) then n2 = 0 end
- if n2 and not n1 and (not s1 or #s1 == 0) then n1 = 0 end
-
- local nc = (n1 and n2) -- numeric compare
-
- if nc then
- -- first "not equal" found return true
- if comp == "~=" and (n1 ~= n2) then return true end
- -- first "lower" found return true
- if (comp == "<" or comp == "<=") and (n1 < n2) then return true end
- -- first "greater" found return true
- if (comp == ">" or comp == ">=") and (n1 > n2) then return true end
- -- not equal then return false
- if (n1 ~= n2) then return false end
- else
- if comp == "~=" and (s1 ~= s2) then return true end
- if (comp == "<" or comp == "<=") and (s1 < s2) then return true end
- if (comp == ">" or comp == ">=") and (s1 > s2) then return true end
- if (s1 ~= s2) then return false end
- end
+
+ -- first "not equal" found return true
+ if comp == "~=" and (s1 ~= s2) then return true end
+ -- first "lower" found return true
+ if (comp == "<" or comp == "<=") and (s1 < s2) then return true end
+ -- first "greater" found return true
+ if (comp == ">" or comp == ">=") and (s1 > s2) then return true end
+ -- not equal then return false
+ if (s1 ~= s2) then return false end
end
- -- all equal then true
- return true
+
+ -- all equal and not compare greater or lower then true
+ return not (comp == "<" or comp == ">")
end
-- read version information for given package if installed
#!/bin/sh
$(uci -q get luci_splash.general.redirect_url) || {
- set -x
touch /var/state/luci_splash_locations
touch /etc/config/luci_splash_locations
MAC=$(grep "$REMOTE_HOST" /proc/net/arp | awk '{print $4}')
uci -P /var/state set luci_splash_locations.${MAC//:/}=redirect
uci -P /var/state set luci_splash_locations.${MAC//:/}.location="http://${HTTP_HOST}${REQUEST_URI}"
- set +x
}
echo -en "Cache-Control: no-cache, max-age=0, no-store, must-revalidate\r\n"
option '1' '02:CA:FF:EE:BA:BE'
config 'defaults' 'luci_splash'
- option 'limit_up' '20'
- option 'limit_down' '50'
+ option 'limit_up' '40'
+ option 'limit_down' '120'
+ option 'leasetime' '8'
config widget 'customindex'
option enabled '1'
option 'bssid' '02:07:04:08:08:09'
config 'defaults' 'bssidscheme'
- option '13' '02:07:04:08:08:09'
+ option '13' '02:07:04:08:08:09'
+ option '36' '02:36:CA:FF:EE:EE'
+
+config 'defaults' 'ssidscheme'
+ option '13' 'ch13.freifunk.net'
+ option '36' 'ch36.freifunk.net'
include $(TOPDIR)/rules.mk
PKG_NAME:=meshwizard
-PKG_RELEASE:=0.1.1
+PKG_RELEASE:=0.3.0
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
done
}
+# string_contains(string, substring)
+#
+# Returns 0 if the specified string contains the specified substring,
+# otherwise returns 1.
+string_contains() {
+ string="$1"
+ substring="$2"
+ if test "${string#*$substring}" != "$string"
+ then
+ return 0 # $substring is in $string
+ else
+ return 1 # $substring is not in $string
+ fi
+}
+
# Takes 2 arguments
# $1 = text to be displayed in the output for this section
# $2 = section (optional)
a="$(echo $option |cut -d '=' -f1)"
b="$(echo $option |cut -d '=' -f2-)"
b="${b//_/ }"
- uci set $2.$a="$b"
+ string_contains "$a" "_LENGTH" && return
+ string_contains "$a" "_ITEM" && {
+ # special threatment for lists. use add_list and remove the
+ # item index (_ITEMx).
+ uci add_list $2.${a//_ITEM[0-9]*/}="$b"
+ } || {
+ uci set $2.$a="$b"
+ }
done
}
-# 3 arguements: 1=config name 2=oldname 3=newname
+# 3 arguments: 1=config name 2=oldname 3=newname
section_rename() {
uci -q rename $1.$2=$3 && msg_rename $1.$2 $1.$3 || msg_rename_error $1.$2 $1.$3
}
msg_rename_error() {
echo " \033[1mWarning:\033[0m Could not rename $1 to $2."
}
+
+
+restore_factory_defaults() {
+ echo "+ Restore default config as requested with cleanup=1"
+ cp -f /rom/etc/config/* /etc/config/
+ rm /etc/config/wireless
+ wifi detect > /etc/config/wireless
+ rm /etc/config/network
+ if [ -f /etc/init.d/defconfig ]; then
+ # legacy (AA)
+ /etc/init.d/defconfig start
+ [ -f /rom/etc/uci-defaults/network ] && sh /rom/etc/uci-defaults/network
+ else
+ sh /rom/etc/uci-defaults/02_network
+ fi
+}
+
+is_in_list() {
+ # checks if an item is in a list
+ local list="$1"
+ local item="$2"
+ for word in $list; do
+ [ $word = "$item" ] && return 0
+ done
+ return 1
+}
+
+add_to_list() {
+ local list="$1"
+ local item="$2"
+ is_in_list "$list" "$item" && echo $list
+ if [ -z "$list" ]; then
+ echo "$item"
+ else
+ echo "$list $item"
+ fi
+}
#!/bin/sh
-# This reads the settings we need to have to configure everything
-# Argument $1: community
+# These functions read the settings we need for configuration of the router
-. /lib/functions.sh
-community="$1"
+read_defaults() {
+ # read default values from the 3 relevant config files and export them
+ # into the environment. Later loaded configs overwrite earlier ones. The
+ # The ordering here is from most generic to most specific:
+ # freifunk (most generic defaults)
+ # profile_* (community defaults)
+ # nodes custom config from meshwizard config file
-# reads variables from uci files, parameter $1 is the section
-get_var() {
- uci -q show $1 | cut -d "." -f 2-100 |grep "\." | sed -e 's/^\([A-Za-z0-9_]*\)\./\1_/g' -e 's/=\(.*\)$/="\1"/g'
-}
-
-handle_widgets() {
- widgets="$widgets $1"
-}
-config_load freifunk
-config_foreach handle_widgets widget
-config_load profile_$community
-config_foreach handle_widgets widget
-echo "widgets=$widgets"
+ local community="$1"
-# read default values from /etc/config/freifunk
-for v in system wifi_device wifi_iface interface alias dhcp olsr_interface olsr_interfacedefaults zone_freifunk include $widgets; do
- get_var freifunk.$v
-done
+ config_cb() {
+ local type="$1"
+ local name="$2"
+ local allowed_section_types="widget"
+ local allowed_section_names="
+ system
+ wifi_device
+ wifi_iface
+ interface
+ alias
+ dhcp
+ olsr_interface
+ olsr_interfacedefaults
+ profile
+ zone_freifunk
+ include
+ luci_splash
+ ipv6
+ luci_main
+ contact
+ community
+ wan
+ lan
+ general
+ ipv6
+ qos
+ "
-# now read all values from the selected community profile, will override some values from the defaults before
-for v in system wifi_device wifi_iface interface alias dhcp olsr_interface olsr_interfacedefaults profile zone_freifunk include luci_splash ipv6 $widgets; do
- get_var profile_$community.$v
-done
+ if [ "$type" = "widget" ]; then
+ widgets=$(add_to_list "$widgets" "$name")
+ fi
-# read values from meshwizard
-for v in system luci_main contact community wan lan general ipv6 qos; do
- get_var meshwizard.$v
-done
+ if ([ -n "$name" ] && is_in_list "$allowed_section_names" $name) \
+ || is_in_list "$allowed_section_types" $type ; then
+ option_cb() {
+ local option="$1"
+ local value="$2"
+ export "${CONFIG_SECTION}_${option}"="$value"
+ }
+ else
+ option_cb() { return; }
+ fi
+ }
+ config_load freifunk
+ config_load profile_${community}
+ config_load meshwizard
+ export widgets="$widgets"
+}
uci show meshwizard.netconfig | grep $IBwifi | while read line; do
oldline=$(echo $line | cut -d "=" -f 1)
uci set $oldline=""
- newline=$(echo $line |sed "s/$IBwifi/$syswifi/g")
+ newline=$(echo $line |sed -e "s/$IBwifi/$syswifi/g" -e "s/'//g")
uci set $newline
done
;;
+++ /dev/null
-#!/bin/sh
-# This will restore default "factory" settings before running the meshwizard
-# and is used when cleanup=1
-# Warning: This will reset network settings for wan and lan to defaults too.
-
-echo "+ Restore default config as requested with cleanup=1"
-cp -f /rom/etc/config/* /etc/config/
-rm /etc/config/wireless
-wifi detect > /etc/config/wireless
-rm /etc/config/network
-/etc/init.d/defconfig start
fi
-# Rules, Forwardings, advanced config and includes
-
-for config in freifunk profile_$community; do
-
- config_load $config
-
- for section in advanced include fw_rule fw_forwarding; do
- handle_firewall() {
- local options=$(uci show $config."$1")
- options=$(echo "$options" | sed -e "s/fw_//g" -e "s/^$config/firewall/g")
- for o in $options; do
- uci set $o
- done
- }
- config_foreach handle_firewall $section
- done
-done
+# Rules, Forwardings, advanced config and includes from freifunk and
+# profile_$community config files.
+
+add_fw_rules() {
+ config_cb() {
+ local type="$1"
+ local name="$2"
+ local allowed_section_types="advanced include fw_rule fw_forwarding"
+ if is_in_list "$allowed_section_types" $type ; then
+ uci set firewall.${name}="${type/fw_/}"
+ option_cb() {
+ local option="$1"
+ local value="$2"
+ uci set firewall.${CONFIG_SECTION}.${option}="$value"
+ }
+ else
+ option_cb() { return; }
+ fi
+ }
+ config_load freifunk
+ config_load profile_${community}
+}
+add_fw_rules
+
# If we use auto-ipv6-dhcp then allow 547/udp on the freifunk zone
if [ "$ipv6_config" = "auto-ipv6-dhcpv6" ]; then
}
setup_jsoninfo() {
- # Setup jsoninfo
+ proto="$1"
uci batch <<- EOF
set $cfg.olsrd_jsoninfo=LoadPlugin
set $cfg.olsrd_jsoninfo.library="olsrd_jsoninfo.so.0.0"
EOF
- uci_commitverbose "Setup olsr jsoninfo plugin" $cfg
+ if [ "$proto" = "6" ]; then
+ uci set $cfg.olsrd_jsoninfo.ipv6only='1'
+ fi
+ uci_commitverbose "Setup olsr jsoninfo plugin" $cfg
}
+setup_txtinfo() {
+ proto="$1"
+ uci batch <<- EOF
+ set $cfg.olsrd_txtinfo=LoadPlugin
+ set $cfg.olsrd_txtinfo.library="olsrd_txtinfo.so.0.1"
+ EOF
+ if [ "$proto" = "6" ]; then
+ uci set $cfg.olsrd_txtinfo.ipv6only='1'
+ fi
+ uci_commitverbose "Setup olsr txtinfo plugin" $cfg
+}
+
for proto in $protocols; do
cfg="olsrd"
setup_nameservice
setup_dyngw_plain
setup_watchdog
- setup_jsoninfo
-
+ setup_jsoninfo $proto
+ setup_txtinfo $proto
done
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-. /lib/functions.sh
-
echo "
-/* Meshwizard 0.2.0 */
+/* Meshwizard 0.3.0 */
"
# config
export dir="/usr/bin/meshwizard"
+
+. /lib/functions.sh
. $dir/functions.sh
+. $dir/helpers/read_defaults.sh
[ -f /proc/net/ipv6_route ] && export has_ipv6=1
# Check which packages we have installed
# Check whether we want to cleanup/restore uci config before setting new options
cleanup=$(uci -q get meshwizard.general.cleanup)
-[ "$cleanup" == 1 ] && $dir/helpers/restore_default_config.sh
+[ "$cleanup" == 1 ] && restore_factory_defaults
# Rename wifi interfaces
$dir/helpers/rename-wifi.sh
# Get community
-community=$(uci -q get meshwizard.community.name || uci -q get freifunk.community.name)
+community="$(uci -q get meshwizard.community.name || uci -q get freifunk.community.name)"
[ -z "$community" ] && echo "Error: Community is not set in /etc/config/freifunk, aborting now." && exit 1
export community="$community"
-echo $community
+
+# we need a list of widgets later on. It will be populated in read_defaults.sh
+local widgets=""
# Get a list of networks we need to setup
networks=$(uci show meshwizard.netconfig | grep -v "netconfig=" | sed -e 's/meshwizard.netconfig\.\(.*\)\_.*/\1/' |sort|uniq)
export networks
[ -z "$networks" ] && echo "Error: No networks to setup could be found in /etc/config/meshwizard, aborting now." && exit 1
-# Read default values (first from /etc/config/freifunk, then from /etc/config/profile_$community
-# then /etc/config/meshwizard
-# last will overwrite first
-
-$dir/helpers/read_defaults.sh $community > /tmp/meshwizard.tmp
-while read line; do
- export "${line//\"/}"
-done < /tmp/meshwizard.tmp
+# Read defaults and node config
+read_defaults $community
# Do config
$dir/helpers/initial_config.sh
local fs = require("nixio.fs")
local uci = require("luci.model.uci")
local datatypes = require("luci.cbi.datatypes")
+local dispatcher = require("luci.dispatcher")
local class = util.class
local instanceof = util.instanceof
self.changed = false
- if not self.uci:load(self.config) then
- error("Unable to read UCI data: " .. self.config)
+ local path = "%s/%s" %{ self.uci:get_confdir(), self.config }
+ if fs.stat(path, "type") ~= "reg" then
+ fs.writefile(path, "")
+ end
+
+ local ok, err = self.uci:load(self.config)
+ if not ok then
+ local url = dispatcher.build_url(unpack(dispatcher.context.request))
+ local source = self:formvalue("cbi.source")
+ if type(source) == "string" then
+ fs.writefile(path, source:gsub("\r\n", "\n"))
+ ok, err = self.uci:load(self.config)
+ if ok then
+ luci.http.redirect(url)
+ end
+ end
+ self.save = false
+ end
+
+ if not ok then
+ self.template = "cbi/error"
+ self.error = err
+ self.source = fs.readfile(path) or ""
+ self.pageaction = false
end
end
--- /dev/null
+<div class="cbi-map" id="cbi-<%=self.config%>">
+ <% if self.title and #self.title > 0 then %><h2><a id="content" name="content"><%=self.title%></a></h2><% end %>
+ <% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
+
+ <p class="alert-message danger">
+ <%: The configuration file could not be loaded due to the following error: %><br />
+ <code><%=pcdata(self.error)%></code>
+ </p>
+
+ <textarea name="cbi.source" style="width:100%; margin-bottom:1em" rows="<%=math.max(self.source:cmatch("\n"), 10)%>"><%=pcdata(self.source)%></textarea>
+
+ <p class="alert-message">
+ <%: Edit the raw configuration data above to fix any error and hit "Save" to reload the page. %>
+ </p>
+
+ <div class="cbi-page-actions">
+ <input class="cbi-button cbi-button-apply" type="submit" name="cbi.save" value="<%:Save%>" />
+ </div>
+</div>
msgid "Edit"
msgstr "Edita"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "Edita aquesta interfície"
"Els caràcters permets són: <code>A-Z</code>, <code>a-z</code>, <code>0-9</"
"code> i <code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Upravit"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "Upravit toto rozhraní"
"Povolené znaky jsou: <code>A-Z</code>, <code>a-z</code>, <code>0-9</code> a "
"<code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Bearbeiten"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "Diese Schnittstelle bearbeiten"
"Erlaubte Buchstaben sind: <code>A-Z</code>, <code>a-z</code>, <code>0-9</"
"code> and <code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Επεξεργασία"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "Επεξεργασία αυτής της διεπαφής"
"Οι επιτρεπόμενοι χαρακτήρες είναι: <code>A-Z</code>, <code>a-z</code>, "
"<code>0-9</code> και <code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Edit"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr ""
"code> and <code>_</code>"
msgstr ""
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Editar"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "Editar esta interfaz"
"Los caracteres permitidos son: <code>A-Z</code>, <code>a-z</code>, "
"<code>0-9</code> y <code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Éditer"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "Éditer cette interface"
"Les caractères autorisés sont : <code>A-Z</code>, <code>a-z</code>, "
"<code>0-9</code> et <code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "ערוך"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "ערוך ממשק זה"
"code> and <code>_</code>"
msgstr ""
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Szerkesztés"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "Interfész szerkesztése"
"A következő karakterek használhatók: <code>A-Z</code>, <code>a-z</code>, "
"<code>0-9</code> and <code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Modifica"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "Modifica questa interfaccia"
"code> and <code>_</code>"
msgstr ""
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "編集"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "インターフェースを編集"
"使用可能な文字は右記の通りです: <code>A-Z</code>, <code>a-z</code>, "
"<code>0-9</code>, <code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Sunting"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr ""
"Karakter yang diizinkan adalah: <code>A-Z</code>, <code>a-z</code>, "
"<code>0-9</code> dan <code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Endre"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "Endre dette grensesnittet"
"Gyldige tegn er: <code>A-Z</code>, <code>a-z</code>, <code>0-9</code> og "
"<code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Edycja"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "Edytuj ten interfejs"
"Dozwolone znaki to: <code>A-Z</code>, <code>a-z</code>, <code>0-9</code> "
"oraz <code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Editar"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "Editar esta interface"
"Os caracteres permitidos são: <code>A-Z</code>, <code>a-z</code>, <code>0-9</"
"code> e <code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Editar"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "Editar esta interface"
"Os caracteres permitidos são: <code>A-Z</code>, <code>a-z</code>, <code>0-9</"
"code> e <code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Editeaza"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "Editeaza aceasta interfata"
"code> and <code>_</code>"
msgstr ""
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Редактировать"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
#, fuzzy
msgid "Edit this interface"
msgstr "Редактировать этот интерфейс"
"Допустимые символы: <code>A-Z</code>, <code>a-z</code>, <code>0-9</code> и "
"<code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr ""
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr ""
"code> and <code>_</code>"
msgstr ""
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr ""
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr ""
"code> and <code>_</code>"
msgstr ""
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr ""
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr ""
"code> and <code>_</code>"
msgstr ""
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Редагувати"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "Редагувати цей інтерфейс"
"Дозволені символи: <code>A-Z</code>, <code>a-z</code>, <code>0-9</code> та "
"<code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "Edit"
msgstr "Chỉnh sửa"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr ""
"code> and <code>_</code>"
msgstr ""
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "CPU"
msgstr "CPU"
-msgid "CPU frequency"
-msgstr "CPU 频率"
-
msgid "CPU usage (%)"
msgstr "CPU使用率(%)"
msgid "Checksum"
msgstr "校验值"
-msgid "Chip Model"
-msgstr "芯片型号"
-
msgid ""
"Choose the firewall zone you want to assign to this interface. Select "
"<em>unspecified</em> to remove the interface from the associated zone or "
msgid "Edit"
msgstr "修改"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "修改此接口"
"合法字符:<code>A-Z</code>, <code>a-z</code>, <code>0-9</code> 和 <code>_</"
"code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
msgid "« Back"
msgstr "« 后退"
+#~ msgid "CPU frequency"
+#~ msgstr "CPU 频率"
+
+#~ msgid "Chip Model"
+#~ msgstr "芯片型号"
+
#~ msgid ""
#~ "Always use 40MHz channels even if the secondary channel overlaps. Using "
#~ "this option does not comply with IEEE 802.11n-2009!"
msgid "Edit"
msgstr "編輯"
+msgid ""
+"Edit the raw configuration data above to fix any error and hit \"Save\" to "
+"reload the page."
+msgstr ""
+
msgid "Edit this interface"
msgstr "修改這個介面"
"所允許的字元是: <code>A-Z</code>, <code>a-z</code>, <code>0-9</code> and "
"<code>_</code>"
+msgid "The configuration file could not be loaded due to the following error:"
+msgstr ""
+
msgid ""
"The device file of the memory or partition (<abbr title=\"for example\">e.g."
"</abbr> <code>/dev/sda1</code>)"
local fs = require "nixio.fs"
local util = require "luci.util"
local uci = require "luci.model.uci".cursor()
-local profiles = "/etc/config/profile_"
+local profiles = "/etc/config/profile_*"
m = Map("freifunk", translate ("Community"))
c = m:section(NamedSection, "community", "public", nil, translate("These are the basic settings for your local wireless community. These settings define the default values for the wizard and DO NOT affect the actual configuration of the router."))
community.rmempty = false
local profile
-for profile in fs.dir(profiles) do
+for profile in fs.glob(profiles) do
local name = uci:get_first(profile, "community", "name") or "?"
community:value(profile, name)
end