Rename gluon-location to gluon-node-info, add owner section

This commit is contained in:
Matthias Schiffer 2014-02-24 05:06:34 +01:00
parent 7586b3e393
commit c2cda254ae
8 changed files with 46 additions and 25 deletions

View File

@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/package.mk
define Package/gluon-alfred
SECTION:=gluon
CATEGORY:=Gluon
DEPENDS:=+gluon-core +gluon-location +gluon-cron +alfred +ethtool
DEPENDS:=+gluon-core +gluon-node-info +gluon-cron +alfred +ethtool
TITLE:=Configure alfred
endef

View File

@ -21,13 +21,19 @@ set -e
json_init
json_add_string "hostname" "$(uci get 'system.@system[0].hostname')"
if [ "$(uci -q get 'gluon-location.@location[0].share_location')" = 1 ]; then
if [ "$(uci -q get 'gluon-node-info.@location[0].share_location')" = 1 ]; then
json_add_object "location"
json_add_double "latitude" "$(uci get 'gluon-location.@location[0].latitude')"
json_add_double "longitude" "$(uci get 'gluon-location.@location[0].longitude')"
json_add_double "latitude" "$(uci get 'gluon-node-info.@location[0].latitude')"
json_add_double "longitude" "$(uci get 'gluon-node-info.@location[0].longitude')"
json_close_object # location
fi
if [ -n "$(uci -q get 'gluon-node-info.@owner[0].contact')" ]; then
json_add_object "owner"
json_add_string "contact" "$(uci get 'gluon-node-info.@owner[0].contact')"
json_close_object # owner
fi
json_add_object "software"
json_add_object "firmware"
json_add_string "base" "gluon"

View File

@ -15,7 +15,7 @@ define Package/gluon-config-mode
SECTION:=gluon
CATEGORY:=Gluon
TITLE:=Luci based config mode for user friendly setup of new meshnodes
DEPENDS:=+gluon-luci-core +gluon-lock-password +gluon-location +gluon-simple-tc +uhttpd +dnsmasq +ip
DEPENDS:=+gluon-luci-core +gluon-lock-password +gluon-node-info +gluon-simple-tc +uhttpd +dnsmasq +ip
endef
define Package/gluon-config-mode/description

View File

@ -53,17 +53,17 @@ zu können, benötigen wir seine Koordinaten. Hier hast du die Möglichkeit,
diese zu hinterlegen.]])
o = s:option(Flag, "_location", "Knoten auf der Karte anzeigen")
o.default = uci:get_first("gluon-location", "location", "share_location", o.disabled)
o.default = uci:get_first("gluon-node-info", "location", "share_location", o.disabled)
o.rmempty = false
o = s:option(Value, "_latitude", "Breitengrad")
o.default = string.format("%f", uci:get_first("gluon-location", "location", "latitude", "0"))
o.default = string.format("%f", uci:get_first("gluon-node-info", "location", "latitude", "0"))
o.rmempty = false
o.datatype = "float"
o.description = "z.B. 53.873621"
o = s:option(Value, "_longitude", "Längengrad")
o.default = string.format("%f", uci:get_first("gluon-location", "location", "longitude", "0"))
o.default = string.format("%f", uci:get_first("gluon-node-info", "location", "longitude", "0"))
o.rmempty = false
o.datatype = "float"
o.description = "z.B. 10.689901"
@ -103,13 +103,13 @@ function f.handle(self, state, data)
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)
uci:foreach("gluon-node-info", "location", function(s)
uci:set("gluon-node-info", s[".name"], "share_location", data._location)
uci:set("gluon-node-info", s[".name"], "latitude", data._latitude)
uci:set("gluon-node-info", s[".name"], "longitude", data._longitude)
end)
uci:save("gluon-location")
uci:commit("gluon-location")
uci:save("gluon-node-info")
uci:commit("gluon-node-info")
luci.http.redirect(luci.dispatcher.build_url("gluon-config-mode", "reboot"))
end

View File

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

View File

@ -1,6 +1,6 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=gluon-location
PKG_NAME:=gluon-node-info
PKG_VERSION:=1
PKG_RELEASE:=1
@ -8,15 +8,15 @@ PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/gluon-location
define Package/gluon-node-info
SECTION:=gluon
CATEGORY:=Gluon
TITLE:=Add /etc/config/gluon-location to uci
TITLE:=Add /etc/config/gluon-node-info to uci
DEPENDS:=+gluon-core
endef
define Package/gluon-location/description
This packages creates /etc/config/gluon-location.
define Package/gluon-node-info/description
This packages creates /etc/config/gluon-node-info.
endef
define Build/Prepare
@ -29,8 +29,8 @@ endef
define Build/Compile
endef
define Package/gluon-location/install
define Package/gluon-node-info/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,gluon-location))
$(eval $(call BuildPackage,gluon-node-info))

View File

@ -0,0 +1,4 @@
config location
option share_location '0'
config owner

View File

@ -0,0 +1,15 @@
#!/bin/sh
# This is a temporary upgrade script for an upgrade between experimental versions. It should be removed before the first Gluon release
. /lib/functions.sh
if [ -e /etc/config/gluon-location ]; then
uci_set gluon-node-info '@location[0]' share_location "$(uci get gluon-location.@location[0].share_location)"
uci_set gluon-node-info '@location[0]' latitude "$(uci get gluon-location.@location[0].latitude)"
uci_set gluon-node-info '@location[0]' longitude "$(uci get gluon-location.@location[0].longitude)"
uci_commit gluon-node-info
rm /etc/config/gluon-location
fi