Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

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