Pārlūkot izejas kodu

gluon-location: move information to /etc/config/gluon-location

Matthias Schiffer 10 gadi atpakaļ
vecāks
revīzija
59c1900e9a

+ 3 - 3
package/gluon-alfred/files/lib/gluon/alfred/announce.sh

@@ -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
 

+ 11 - 6
package/gluon-config-mode/files/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua

@@ -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
 

+ 2 - 2
package/gluon-location/Makefile

@@ -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 - 0
package/gluon-location/files/etc/config/gluon-location

@@ -0,0 +1,4 @@
+config location
+	option share_location '0'
+	option latitude '0.000000'
+	option longitude '0.000000'

+ 0 - 12
package/gluon-location/files/lib/gluon/upgrade/location/initial/010-location

@@ -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