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_init
|
||||||
json_add_string "hostname" "$(uci get 'system.@system[0].hostname')"
|
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_object "location"
|
||||||
json_add_double "latitude" "$(uci get 'system.@system[0].latitude')"
|
json_add_double "latitude" "$(uci get 'gluon-location.@location[0].latitude')"
|
||||||
json_add_double "longitude" "$(uci get 'system.@system[0].longitude')"
|
json_add_double "longitude" "$(uci get 'gluon-location.@location[0].longitude')"
|
||||||
json_close_object # location
|
json_close_object # location
|
||||||
fi
|
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.")
|
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 = 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.rmempty = false
|
||||||
|
|
||||||
o = s:option(Value, "_latitude", "Breitengrad")
|
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.rmempty = false
|
||||||
o.datatype = "float"
|
o.datatype = "float"
|
||||||
|
|
||||||
o = s:option(Value, "_longitude", "Längengrad")
|
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.rmempty = false
|
||||||
o.datatype = "float"
|
o.datatype = "float"
|
||||||
|
|
||||||
@ -79,13 +79,18 @@ function f.handle(self, state, data)
|
|||||||
|
|
||||||
uci:foreach("system", "system", function(s)
|
uci:foreach("system", "system", function(s)
|
||||||
uci:set("system", s[".name"], "hostname", data._hostname)
|
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)
|
end)
|
||||||
uci:save("system")
|
uci:save("system")
|
||||||
uci:commit("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"))
|
luci.http.redirect(luci.dispatcher.build_url("gluon-config-mode", "reboot"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,12 +11,12 @@ include $(INCLUDE_DIR)/package.mk
|
|||||||
define Package/gluon-location
|
define Package/gluon-location
|
||||||
SECTION:=gluon
|
SECTION:=gluon
|
||||||
CATEGORY:=Gluon
|
CATEGORY:=Gluon
|
||||||
TITLE:=Add system.location to uci
|
TITLE:=Add /etc/config/gluon-location to uci
|
||||||
DEPENDS:=+gluon-core
|
DEPENDS:=+gluon-core
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/gluon-location/description
|
define Package/gluon-location/description
|
||||||
This packages creates /lib/gluon/location.
|
This packages creates /etc/config/gluon-location.
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Build/Prepare
|
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