#!/usr/bin/lua local config = require 'lime.config' local uci = config.get_uci_cursor() local function valid_coordinate(value) return type(tonumber(value)) == "number" end local changed = false local lat = uci:get("libremap", "location", "latitude") local long = uci:get("libremap", "location", "longitude") if valid_coordinate(lat) and valid_coordinate(long) then uci:set(config.UCI_NODE_NAME, "node_location", "generic_uci_config") uci:set(config.UCI_NODE_NAME, "node_location", "uci_set", { "location.settings.node_latitude="..lat, "location.settings.node_longitude="..long, } ) uci:commit(config.UCI_NODE_NAME) changed = true end lat = uci:get("libremap", "settings", "community_lat") long = uci:get("libremap", "settings", "community_lon") if valid_coordinate(lat) and valid_coordinate(long) then uci:set(config.UCI_COMMUNITY_NAME, "community_location", "generic_uci_config") uci:set(config.UCI_COMMUNITY_NAME, "community_location", "uci_set", { "location.settings.community_latitude="..lat, "location.settings.community_longitude="..long, } ) uci:commit(config.UCI_COMMUNITY_NAME) changed = true end if changed then os.execute("/usr/bin/lime-config") end