#!/usr/bin/lua UTIL = require 'luci.util' JSON = require 'luci.jsonc' rawdata = UTIL.exec("ubus call gps info") if rawdata == nil or rawdata == '' then os.exit() end gpsdata = JSON.parse(rawdata) if (gpsdata.signal == false) or (gpsdata.age > 900) then UTIL.exec("uci set gluon-node-info.@location[0].share_location='0'") os.exit() end UTIL.exec("uci set gluon-node-info.@location[0].share_location='1'") UTIL.exec("uci set gluon-node-info.@location[0].latitude=" .. gpsdata.latitude) UTIL.exec("uci set gluon-node-info.@location[0].longitude=" .. gpsdata.longitude)