gluon-location: move information to /etc/config/gluon-location
This commit is contained in:
parent
1dd9a9a8a1
commit
59c1900e9a
@ -21,10 +21,10 @@ set -e
|
||||
json_init
|
||||
json_add_string "hostname" "$(uci get 'system.@system[0].hostname')"
|
||||
|
||||
if [ "$(uci -q get 'system.@system[0].share_location')" = 1 ]; then
|
||||
if [ "$(uci -q get 'gluon-location.@location[0].share_location')" = 1 ]; then
|
||||
json_add_object "location"
|
||||
json_add_double "latitude" "$(uci get 'system.@system[0].latitude')"
|
||||
json_add_double "longitude" "$(uci get 'system.@system[0].longitude')"
|
||||
json_add_double "latitude" "$(uci get 'gluon-location.@location[0].latitude')"
|
||||
json_add_double "longitude" "$(uci get 'gluon-location.@location[0].longitude')"
|
||||
json_close_object # location
|
||||
fi
|
||||
|
||||
|
@ -45,16 +45,16 @@ o.datatype = "integer"
|
||||
s = f:section(SimpleSection, "GPS Koordinaten", "Hier kannst du die GPS-Koordinaten deines Knotens eintragen, um ihn in der Knotenkarte anzeigen zu lassen.")
|
||||
|
||||
o = s:option(Flag, "_location", "Koordinaten veröffentlichen?")
|
||||
o.default = uci:get_first("system", "system", "share_location", o.disabled)
|
||||
o.default = uci:get_first("gluon-locaton", "location", "share_location", o.disabled)
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "_latitude", "Breitengrad")
|
||||
o.default = string.format("%f", uci:get_first("system", "system", "latitude", "0"))
|
||||
o.default = string.format("%f", uci:get_first("gluon-location", "location", "latitude", "0"))
|
||||
o.rmempty = false
|
||||
o.datatype = "float"
|
||||
|
||||
o = s:option(Value, "_longitude", "Längengrad")
|
||||
o.default = string.format("%f", uci:get_first("system", "system", "longitude", "0"))
|
||||
o.default = string.format("%f", uci:get_first("gluon-location", "location", "longitude", "0"))
|
||||
o.rmempty = false
|
||||
o.datatype = "float"
|
||||
|
||||
@ -79,13 +79,18 @@ function f.handle(self, state, data)
|
||||
|
||||
uci:foreach("system", "system", function(s)
|
||||
uci:set("system", s[".name"], "hostname", data._hostname)
|
||||
uci:set("system", s[".name"], "share_location", data._location)
|
||||
uci:set("system", s[".name"], "latitude", data._latitude)
|
||||
uci:set("system", s[".name"], "longitude", data._longitude)
|
||||
end)
|
||||
uci:save("system")
|
||||
uci:commit("system")
|
||||
|
||||
uci:foreach("gluon-location", "location", function(s)
|
||||
uci:set("gluon-location", s[".name"], "share_location", data._location)
|
||||
uci:set("gluon-location", s[".name"], "latitude", data._latitude)
|
||||
uci:set("gluon-location", s[".name"], "longitude", data._longitude)
|
||||
end)
|
||||
uci:save("gluon-location")
|
||||
uci:commit("gluon-location")
|
||||
|
||||
luci.http.redirect(luci.dispatcher.build_url("gluon-config-mode", "reboot"))
|
||||
end
|
||||
|
||||
|
@ -11,12 +11,12 @@ include $(INCLUDE_DIR)/package.mk
|
||||
define Package/gluon-location
|
||||
SECTION:=gluon
|
||||
CATEGORY:=Gluon
|
||||
TITLE:=Add system.location to uci
|
||||
TITLE:=Add /etc/config/gluon-location to uci
|
||||
DEPENDS:=+gluon-core
|
||||
endef
|
||||
|
||||
define Package/gluon-location/description
|
||||
This packages creates /lib/gluon/location.
|
||||
This packages creates /etc/config/gluon-location.
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
|
4
package/gluon-location/files/etc/config/gluon-location
Normal file
4
package/gluon-location/files/etc/config/gluon-location
Normal file
@ -0,0 +1,4 @@
|
||||
config location
|
||||
option share_location '0'
|
||||
option latitude '0.000000'
|
||||
option longitude '0.000000'
|
@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
CFG="@system[0]"
|
||||
|
||||
uci -q batch <<EOF
|
||||
|
||||
set system.${CFG}.share_location=0
|
||||
set system.${CFG}.latitude=0
|
||||
set system.${CFG}.longitude=0
|
||||
|
||||
commit system
|
||||
EOF
|
Loading…
Reference in New Issue
Block a user