From 1bb4822dca6113f73e3bc89e2acf15935e6f8e92 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 3 Dec 2014 15:17:05 +0100 Subject: Rework LuCI build system * Rename subdirectories to their repective OpenWrt package names * Make each LuCI module its own standalone package * Deploy a shared luci.mk which is used by each module Makefile Signed-off-by: Jo-Philipp Wich --- .../luci-vnstat/luasrc/model/cbi/vnstat.lua | 91 ---------------------- 1 file changed, 91 deletions(-) delete mode 100644 applications/luci-vnstat/luasrc/model/cbi/vnstat.lua (limited to 'applications/luci-vnstat/luasrc/model') diff --git a/applications/luci-vnstat/luasrc/model/cbi/vnstat.lua b/applications/luci-vnstat/luasrc/model/cbi/vnstat.lua deleted file mode 100644 index 38b06ba9a7..0000000000 --- a/applications/luci-vnstat/luasrc/model/cbi/vnstat.lua +++ /dev/null @@ -1,91 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2010-2011 Jo-Philipp Wich - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 -]]-- - -local utl = require "luci.util" -local sys = require "luci.sys" -local fs = require "nixio.fs" -local nw = require "luci.model.network" - -local dbdir, line - -for line in io.lines("/etc/vnstat.conf") do - dbdir = line:match("^%s*DatabaseDir%s+[\"'](%S-)[\"']") - if dbdir then break end -end - -dbdir = dbdir or "/var/lib/vnstat" - - -m = Map("vnstat", translate("VnStat"), - translate("VnStat is a network traffic monitor for Linux that keeps a log of network traffic for the selected interface(s).")) - -m.submit = translate("Restart VnStat") -m.reset = false - -nw.init(luci.model.uci.cursor_state()) - -local ifaces = { } -local enabled = { } -local iface - -if fs.access(dbdir) then - for iface in fs.dir(dbdir) do - if iface:sub(1,1) ~= '.' then - ifaces[iface] = iface - enabled[iface] = iface - end - end -end - -for _, iface in ipairs(sys.net.devices()) do - ifaces[iface] = iface -end - - -local s = m:section(TypedSection, "vnstat") -s.anonymous = true -s.addremove = false - -mon_ifaces = s:option(Value, "interface", translate("Monitor selected interfaces")) -mon_ifaces.template = "cbi/network_ifacelist" -mon_ifaces.widget = "checkbox" -mon_ifaces.cast = "table" -mon_ifaces.noinactive = true -mon_ifaces.nocreate = true - -function mon_ifaces.write(self, section, val) - local i - local s = { } - - if val then - for _, i in ipairs(type(val) == "table" and val or { val }) do - s[i] = true - end - end - - for i, _ in pairs(ifaces) do - if not s[i] then - fs.unlink(dbdir .. "/" .. i) - fs.unlink(dbdir .. "/." .. i) - end - end - - if next(s) then - m.uci:set_list("vnstat", section, "interface", utl.keys(s)) - else - m.uci:delete("vnstat", section, "interface") - end -end - -mon_ifaces.remove = mon_ifaces.write - -return m -- cgit v1.2.3