Skip to content
Commits on Source (67)
include $(TOPDIR)/rules.mk
PKG_NAME:=ffnw-banner
PKG_VERSION:=1
PKG_RELEASE:=1
PKG_VERSION:=2
PKG_RELEASE:=$(GLUON_VERSION)
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
include $(GLUONDIR)/include/package.mk
define Package/ffnw-banner
SECTION:=config
......@@ -26,10 +26,12 @@ define Build/Configure
endef
define Build/Compile
$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
endef
define Package/ffnw-banner/install
$(CP) ./files/* $(1)/
$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
endef
$(eval $(call BuildPackage,ffnw-banner))
......@@ -11,12 +11,17 @@ PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
define Package/ffnw-config-mode-contact-info
SECTION:=config-mode
SECTION:=gluon
CATEGORY:=Freifunk Nordwest
TITLE:=Set a custom string that will be distributed in the mesh.
TITLE:=Allows the user to provide contact information to be distributed in the mesh
DEPENDS:=gluon-config-mode-core-virtual +ffnw-node-info
endef
define Package/gluon-config-mode-contact-info/description
Allows the user to provide contact information to be distributed in the mesh.
Can be made obligatory in site.conf
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
......@@ -26,11 +31,17 @@ endef
define Build/Compile
$(call GluonBuildI18N,ffnw-config-mode-contact-info,i18n)
$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
endef
define Package/ffnw-config-mode-contact-info/install
$(CP) ./files/* $(1)/
$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
$(call GluonInstallI18N,ffnw-config-mode-contact-info,$(1))
endef
define Package/ffnw-config-mode-contact-info/postinst
#!/bin/sh
$(call GluonCheckSite,check_site.lua)
endef
$(eval $(call BuildPackage,ffnw-config-mode-contact-info))
if need_table('config_mode', nil, false) and need_table('config_mode.owner', nil, false) then
need_boolean('config_mode.owner.obligatory', false)
end
......@@ -14,14 +14,13 @@ msgid "Contact info"
msgstr "Kontakt"
msgid ""
"You can provide your contact information here to allow others to contact "
"you. Please note that this information will be visible <em>publicly</em> on "
"the internet together with your node's coordinates."
"Please provide your contact information here to allow others to contact "
"you. Note that this information will be visible <em>publicly</em> on "
"the internet."
msgstr ""
"Hier kannst du einen <em>öffentlichen</em> Hinweis hinterlegen, um anderen "
"zu ermöglichen, Kontakt mit dir aufzunehmen. Bitte beachte, dass "
"dieser Hinweis auch öffentlich im Internet, zusammen mit den Koordinaten "
"deines Knotens, einsehbar sein wird."
"Bitte hinterlege hier eine Kontaktmöglichkeit, um anderen zu ermöglichen, "
"Kontakt mit dir aufzunehmen. Beachte, dass diese Kontaktmöglichkeit auch "
"<em>öffentlich</em> im Internet einsehbar sein wird."
msgid "e.g. E-mail or phone number"
msgstr "z.B. E-Mail oder Telefonnummer"
......@@ -5,9 +5,9 @@ msgid "Contact info"
msgstr ""
msgid ""
"You can provide your contact information here to allow others to contact "
"you. Please note that this information will be visible <em>publicly</em> on "
"the internet together with your node's coordinates."
"Please provide your contact information here to allow others to contact "
"you. Note that this information will be visible <em>publicly</em> on "
"the internet."
msgstr ""
msgid "e.g. E-mail or phone number"
......
local cbi = require "luci.cbi"
local i18n = require "luci.i18n"
local uci = luci.model.uci.cursor()
local site = require 'gluon.site_config'
local M = {}
function M.section(form)
local s = form:section(cbi.SimpleSection, nil, i18n.translate(
'You can provide your contact information here to '
.. 'allow others to contact you. Please note that '
.. 'this information will be visible <em>publicly</em> '
.. 'on the internet together with your node\'s coordinates.'
'Please provide your contact information here to '
.. 'allow others to contact you. Note that '
.. 'this information will be visible <em>publicly</em> '
.. ' on the internet.'
)
)
local o = s:option(cbi.Value, "_contact", i18n.translate("Contact info"))
o.default = uci:get_first("gluon-node-info", "owner", "contact", "")
o.rmempty = true
o.rmempty = not ((site.config_mode or {}).owner or {}).obligatory
o.datatype = "string"
o.description = i18n.translate("e.g. E-mail or phone number")
o.maxlen = 140
......
......@@ -9,9 +9,8 @@ include $(GLUONDIR)/include/package.mk
PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
define Package/ffnw-config-mode-geo-location
SECTION:=config-mode
SECTION:=gluon
CATEGORY:=Freifunk Nordwest
TITLE:=Set geographic location of a node
DEPENDS:=gluon-config-mode-core-virtual +ffnw-node-info +lwtrace +libwlocate
......@@ -26,11 +25,17 @@ endef
define Build/Compile
$(call GluonBuildI18N,ffnw-config-mode-geo-location,i18n)
$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
endef
define Package/ffnw-config-mode-geo-location/install
$(CP) ./files/* $(1)/
$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
$(call GluonInstallI18N,ffnw-config-mode-geo-location,$(1))
endef
define Package/ffnw-config-mode-geo-location/postinst
#!/bin/sh
$(call GluonCheckSite,check_site.lua)
endef
$(eval $(call BuildPackage,ffnw-config-mode-geo-location))
if need_table('config_mode', nil, false) and need_table('config_mode.geo_location', nil, false) then
need_boolean('config_mode.geo_location.show_altitude', false)
end
......@@ -11,13 +11,19 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
msgid ""
"If you want the location of your node to be displayed on the map, you can set an automatically localization of your router or "
"enter its coordinates here. Also to enhance the network quallity. Specifying the altitude is optional and should "
"only be done if a proper value is known."
"If you want the location of your node to "
"be displayed on the map, you can set an automatically localization "
"of your router or enter its coordinates here. Also to enhance the "
"network quallity."
msgstr ""
"Um deinen Knoten auf der Karte anzeigen zu können, benötigen wir seine "
"Koordinaten. Hier hast du die Möglichkeit, diese zu hinterlegen oder dies Automatisch bestimmen zu lassen. Die koordinaten tragen auch zur verbesserung der netzwerk qualität bie. Die "
"Höhenangabe ist optional und sollte nur gesetzt werden, wenn ein exakter "
"Koordinaten. Hier hast du die Möglichkeit, diese zu hinterlegen oder diese Automatisch bestimmen zu lassen. Die koordinaten tragen auch zur verbesserung der netzwerk qualität bie."
msgid ""
"Specifying the altitude is "
"optional and should only be done if a proper value is known."
msgstr ""
"Die Höhenangabe ist optional und sollte nur gesetzt werden, wenn ein exakter "
"Wert bekannt ist."
msgid "Share your location to see your router on the map"
......@@ -41,10 +47,10 @@ msgstr "Deaktivieren"
msgid "Automaticaly location service over wifi."
msgstr "Automatischer Positionsbestimmungs service über Wifi."
msgid "Manual setting of geo coordinations."
msgid "Manual setting of geo coordinates."
msgstr "Manuelles setzen einer Geo Position."
msgid "Manual setting of geo coordinations and sending wifi informations to the openwifi.su project."
msgid "Manual setting of geo coordinates and sending wifi informations to the openwifi.su project."
msgstr "Manuelles setzen einer Geo Position und senden von wifi Informationen an das openwifi.su Projekt."
msgid "WARNING !"
......
......@@ -2,9 +2,15 @@ msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid ""
"If you want the location of your node to be displayed on the map, you can set an automatically localization of your router or "
"enter its coordinates here. Also to enhance the network quallity. Specifying the altitude is optional and should "
"only be done if a proper value is known."
"If you want the location of your node to "
"be displayed on the map, you can set an automatically localization "
"of your router or enter its coordinates here. Also to enhance the "
"network quallity."
msgstr ""
msgid ""
"Specifying the altitude is "
"optional and should only be done if a proper value is known."
msgstr ""
msgid "Share your location to see your router on the map"
......@@ -28,10 +34,10 @@ msgstr ""
msgid "Automaticaly location service over wifi."
msgstr ""
msgid "Manual setting of geo coordinations."
msgid "Manual setting of geo coordinates."
msgstr ""
msgid "Manual setting of geo coordinations and sending wifi informations to the openwifi.su project."
msgid "Manual setting of geo coordinates and sending wifi informations to the openwifi.su project."
msgstr ""
msgid "WARNING !"
......
local cbi = require "luci.cbi"
local i18n = require "luci.i18n"
local uci = luci.model.uci.cursor()
local site = require 'gluon.site_config'
local M = {}
local function show_altitude()
if ((site.config_mode or {}).geo_location or {}).show_altitude ~= false then
return true
end
if uci:get_first("gluon-node-info", "location", "altitude") then
return true
end
return false
end
function M.section(form)
local s = form:section(cbi.SimpleSection, nil, i18n.translate(
'If you want the location of your node to be displayed on the map, '
.. 'you can set an automatically localization of your router or enter its coordinates here. Also to enhance the network quallity. Specifying the altitude '
.. 'is optional and should only be done if a proper value is known.'))
local text = i18n.translate('If you want the location of your node to '
.. 'be displayed on the map, you can set an automatically localization '
.. 'of your router or enter its coordinates here. Also to enhance the '
.. 'network quallity.')
if show_altitude() then
text = text .. ' ' .. i18n.translate('Specifying the altitude is '
.. 'optional and should only be done if a proper value is known.')
end
local s = form:section(cbi.SimpleSection, nil, text)
local s = form:section(cbi.SimpleSection, nil,
[[
......@@ -139,7 +155,7 @@ function M.section(form)
local o
o = s:option(cbi.Flag, "_sharelocation", i18n.translate("Share your location to see your router on the map"))
o.default = uci:get_bool("gluon-node-info", "location", "share_location") and o.enabled or o.disabled
o.default = uci:get_first("gluon-node-info", "location", "share_location")
o:depends("_geolocation","_automatic")
o:depends("_geolocation","_static")
o:depends("_geolocation","_auto_static")
......@@ -168,11 +184,11 @@ function M.section(form)
o = s:option(cbi.DummyValue, "_static_disc", " ")
o:depends("_geolocation","_static")
o.description = i18n.translatef("Manual setting of geo coordinations.")
o.description = i18n.translatef("Manual setting of geo coordinates.")
o = s:option(cbi.DummyValue, "_auto_static_disc", " ")
o:depends("_geolocation","_auto_static")
o.description = i18n.translatef("Manual setting of geo coordinations and sending wifi informations to the openwifi.su project.")
o.description = i18n.translatef("Manual setting of geo coordinates and sending wifi informations to the openwifi.su project.")
o = s:option(cbi.DummyValue, "_none_disc", i18n.translate("WARNING !"))
o:depends("_geolocation","_none")
......@@ -202,13 +218,15 @@ function M.section(form)
o.datatype = "float"
o.description = i18n.translatef("e.g. %s", "10.689901")
o = s:option(cbi.Value, "_altitude", i18n.translate("Altitude"))
o.default = uci:get_first("gluon-node-info", "location", "altitude")
o:depends("_geolocation","_static")
o:depends("_geolocation","_auto_static")
o.rmempty = true
o.datatype = "float"
o.description = i18n.translatef("e.g. %s", "11.51")
if show_altitude() then
o = s:option(cbi.Value, "_altitude", i18n.translate("Altitude"))
o.default = uci:get_first("gluon-node-info", "location", "altitude")
o:depends("_geolocation","_static")
o:depends("_geolocation","_auto_static")
o.rmempty = true
o.datatype = "float"
o.description = i18n.translatef("e.g. %s", "11.51")
end
end
function M.handle(data)
......@@ -223,8 +241,8 @@ function M.handle(data)
if data._geolocation == "_automatic" or data._geolocation == "_auto_static" then
uci:set("gluon-node-info", sname, "auto_location", 1)
if data._interval ~= nil and tonumber(data._interval) >= 1 and tonumber(data._interval) <= 43200 then
uci:set("gluon-node-info", sname, "refresh_interval", data._interval)
elseif tonumber(data._interval) > 43200 then
uci:set("gluon-node-info", sname, "refresh_interval", data._interval:trim())
elseif tonumber(data._interval:trim()) > 43200 then
uci:set("gluon-node-info", sname, "refresh_interval", 43200)
end
else
......@@ -233,10 +251,10 @@ function M.handle(data)
if (data._geolocation == "_static" or data._geolocation == "_auto_static") and data._latitude ~= nil and data._longitude ~= nil then
uci:set("gluon-node-info", sname, "static_location", 1)
uci:set("gluon-node-info", sname, "latitude", data._latitude)
uci:set("gluon-node-info", sname, "longitude", data._longitude)
uci:set("gluon-node-info", sname, "latitude", data._latitude:trim())
uci:set("gluon-node-info", sname, "longitude", data._longitude:trim())
if data._altitude ~= nil then
uci:set("gluon-node-info", sname, "altitude", data._altitude)
uci:set("gluon-node-info", sname, "altitude", data._altitude:trim())
else
uci:delete("gluon-node-info", sname, "altitude")
end
......
......@@ -10,7 +10,7 @@ PKG_BUILD_DEPENDS := respondd
include $(GLUONDIR)/include/package.mk
define Package/ffnw-node-info
SECTION:=daemon
SECTION:=gluon
CATEGORY:=Freifunk Nordwest
TITLE:=Add /etc/config/gluon-node-info to uci
DEPENDS:=+lwtrace +libwlocate +gluon-core +libgluonutil
......@@ -21,9 +21,14 @@ define Build/Prepare
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(call Build/Compile/Default)
$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
endef
define Package/ffnw-node-info/install
$(CP) ./files/* $(1)/
$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
$(INSTALL_DIR) $(1)/lib/gluon/respondd
$(CP) $(PKG_BUILD_DIR)/respondd.so $(1)/lib/gluon/respondd/node-info.so
endef
......
#!/bin/sh
AUTO_LOCATION=`uci get gluon-node-info.@location[0].auto_location`
[ $AUTO_LOCATION -eq 0 ] && exit 0
AUTO_LOCATION=$(uci get gluon-node-info.@location[0].auto_location)
[ "$AUTO_LOCATION" -eq 0 ] && exit 0
PID_PART="/var/run/geolocator.pid"
TIME_STAMP="/tmp/geolocator_timestamp"
HOODS_F="/lib/ffnw/hoods/hoods.json"
if [ -f $PID_PART ]; then
echo "The geolocator is still running"
......@@ -19,41 +20,46 @@ Clean_pid() {
}
# Get localization interval
INTERVAL=`uci get gluon-node-info.@location[0].refresh_interval`
INTERVAL=$(uci get gluon-node-info.@location[0].refresh_interval)
# get position
Get_geolocation_info() {
(lwtrace -t 2> /dev/null 1>/tmp/lwtrace_out) & subpid=$!
hoods=$(cat $HOODS_F)
b=0
bssid=""
for x in $hoods; do
[ $b -eq 1 ] && bssid=$bssid" "$(echo "$x" | grep -o '[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]') && b=$(( b -1 ))
[ "$x" = '"bssid":' ] && b=$(( b +1 ))
done
(lwtrace -b "$bssid" 2> /dev/null 1>/tmp/lwtrace_out) & subpid=$!
(sleep 15 && kill -9 $subpid > /dev/null 2>&1) & waitpid=$!
wait $subpid
kill -INT $waitpid >/dev/null 2>&1
LWTRACE=$(cat /tmp/lwtrace_out)
rm /tmp/lwtrace_out
echo $LWTRACE | grep "Scan completed : Your location:" >> /dev/null
[ $? -eq "0" ] || {
[ "$(echo "$LWTRACE" | grep "Scan completed : Your location:" >> /dev/null)" ] || {
echo "lwtrace doesn't gif a location"
return 1
}
last_val="";
for x in $LWTRACE; do
[ $x == '(lat)' ] && LAT=$last_val
[ $x == '(lon)' ] && LON=$last_val
[ $x == '%' ] && QUALITY=$last_val
[ "$x" = '(lat)' ] && LAT=$last_val
[ "$x" = '(lon)' ] && LON=$last_val
last_val=$x;
done
return 0
}
#check if interval over or not exist
if [ ! -f $TIME_STAMP ] || [ $(( `date +%s` - `cat $TIME_STAMP` )) -gt $(( $INTERVAL * 60 )) ]; then
if [ ! -f $TIME_STAMP ] || [ $(( $(date +%s) - $(cat $TIME_STAMP) )) -gt $(( INTERVAL * 60 )) ]; then
Get_geolocation_info
[ $? -eq 1 ] && Clean_pid
#ceck if static location true or not
STATIC_LOCATION=`uci get gluon-node-info.@location[0].static_location`
[ $STATIC_LOCATION -eq 0 ] && {
$(uci set gluon-node-info.@location[0].latitude=$LAT)
$(uci set gluon-node-info.@location[0].longitude=$LON)
`uci commit gluon-node-info`
STATIC_LOCATION=$(uci get gluon-node-info.@location[0].static_location)
[ "$STATIC_LOCATION" -eq 0 ] && {
uci set gluon-node-info.@location[0].latitude=$LAT
uci set gluon-node-info.@location[0].longitude=$LON
uci commit gluon-node-info
}
date +%s > $TIME_STAMP
fi
......
......@@ -7,5 +7,4 @@ local config = 'gluon-node-info'
if not uci:get_first(config, 'system') then
uci:section(config, 'system')
uci:save(config)
uci:commit(config)
end
#!/usr/bin/lua
local uci = require('luci.model.uci').cursor()
local config = 'gluon-node-info'
if not uci:get(config, 'location') then
local get_first = uci:get_first(config, 'location')
local c = {}
c.static_location = uci:get(config, get_first, 'static_location')
c.share_location = uci:get(config, get_first, 'share_location')
c.auto_location = uci:get(config, get_first, 'auto_location')
c.refresh_interval = uci:get(config, get_first, 'refresh_interval')
c.latitude = uci:get(config, get_first, 'latitude')
c.longitude = uci:get(config, get_first, 'longitude')
c.altitude = uci:get(config, get_first, 'altitude')
uci:delete(config, get_first)
uci:section(config, 'location', 'location', c)
uci:save(config)
end
......@@ -15,5 +15,4 @@ end
if not role then
uci:set(config, uci:get_first(config, 'system'), 'role', default_role)
uci:save(config)
uci:commit(config)
end
#!/usr/bin/lua
local uci = require('luci.model.uci').cursor()
local sname = uci:get_first('gluon-node-info', 'location')
if sname then
local options = {'longitude', 'latitude', 'altitude'}
for _, option in ipairs(options) do
local value = uci:get('gluon-node-info', sname, option)
if value then
uci:set('gluon-node-info', sname, option, value:trim())
end
end
uci:save('gluon-node-info')
end