From c4ae2050f23ff285f345c2f02aea9ba5ed49b82c Mon Sep 17 00:00:00 2001 From: Jan-Tarek Butt <buttjantarek@googlemail.com> Date: Tue, 11 Aug 2015 11:41:26 +0200 Subject: [PATCH] add new upgrade script for static location --- .../upgrade/540-node-info-staticlocation | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 ffnw-node-info/files/lib/gluon/upgrade/540-node-info-staticlocation diff --git a/ffnw-node-info/files/lib/gluon/upgrade/540-node-info-staticlocation b/ffnw-node-info/files/lib/gluon/upgrade/540-node-info-staticlocation new file mode 100755 index 0000000..7a399d1 --- /dev/null +++ b/ffnw-node-info/files/lib/gluon/upgrade/540-node-info-staticlocation @@ -0,0 +1,20 @@ +#!/usr/bin/lua + +local site = require 'gluon.site_config' +local uci = require('luci.model.uci').cursor() +local config = 'gluon-node-info' +local longitude = uci:get(config, uci:get_first(config, 'location'), 'longitude') +local latitude = uci:get(config, uci:get_first(config, 'location'), 'latitude') +local staticlocation = uci:get(config, uci:get_first(config, 'location'), 'static_location') + +if tonumber(longitude) ~= nil and tonumber(latitude) ~= nil then + default_static_location = 1 +else + default_static_location = 0 +end + +if not staticlocation then + uci:set(config, uci:get_first(config, 'location'), 'static_location', default_static_location) + uci:save(config) + uci:commit(config) +end -- GitLab