diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2014-12-03 15:17:05 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-01-08 16:26:20 +0100 |
commit | 1bb4822dca6113f73e3bc89e2acf15935e6f8e92 (patch) | |
tree | 35e16f100466e4e00657199b38bb3d87d52bf73f /applications/luci-vnstat | |
parent | 9edd0e46c3f880727738ce8ca6ff1c8b85f99ef4 (diff) |
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 <jow@openwrt.org>
Diffstat (limited to 'applications/luci-vnstat')
-rw-r--r-- | applications/luci-vnstat/Makefile | 4 | ||||
-rwxr-xr-x | applications/luci-vnstat/ipkg/postinst | 7 | ||||
-rw-r--r-- | applications/luci-vnstat/luasrc/controller/vnstat.lua | 11 | ||||
-rw-r--r-- | applications/luci-vnstat/luasrc/model/cbi/vnstat.lua | 91 | ||||
-rw-r--r-- | applications/luci-vnstat/luasrc/view/vnstat.htm | 108 | ||||
-rwxr-xr-x | applications/luci-vnstat/root/etc/uci-defaults/luci-vnstat | 11 |
6 files changed, 0 insertions, 232 deletions
diff --git a/applications/luci-vnstat/Makefile b/applications/luci-vnstat/Makefile deleted file mode 100644 index 0d76c05e1..000000000 --- a/applications/luci-vnstat/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -PO = vnstat - -include ../../build/config.mk -include ../../build/module.mk diff --git a/applications/luci-vnstat/ipkg/postinst b/applications/luci-vnstat/ipkg/postinst deleted file mode 100755 index 816084a48..000000000 --- a/applications/luci-vnstat/ipkg/postinst +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -[ -n "${IPKG_INSTROOT}" ] || { - ( . /etc/uci-defaults/luci-vnstat ) && rm -f /etc/uci-defaults/luci-vnstat - /etc/init.d/vnstat enabled || /etc/init.d/vnstat enable - exit 0 -} diff --git a/applications/luci-vnstat/luasrc/controller/vnstat.lua b/applications/luci-vnstat/luasrc/controller/vnstat.lua deleted file mode 100644 index 3871fa254..000000000 --- a/applications/luci-vnstat/luasrc/controller/vnstat.lua +++ /dev/null @@ -1,11 +0,0 @@ -module("luci.controller.vnstat", package.seeall) - -function index() - entry({"admin", "status", "vnstat"}, alias("admin", "status", "vnstat", "graphs"), _("VnStat Traffic Monitor"), 90) - entry({"admin", "status", "vnstat", "graphs"}, template("vnstat"), _("Graphs"), 1) - entry({"admin", "status", "vnstat", "config"}, cbi("vnstat"), _("Configuration"), 2) - - entry({"mini", "network", "vnstat"}, alias("mini", "network", "vnstat", "graphs"), _("VnStat Traffic Monitor"), 90) - entry({"mini", "network", "vnstat", "graphs"}, template("vnstat"), _("Graphs"), 1) - entry({"mini", "network", "vnstat", "config"}, cbi("vnstat"), _("Configuration"), 2) -end 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 38b06ba9a..000000000 --- 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 <xm@subsignal.org> - -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 diff --git a/applications/luci-vnstat/luasrc/view/vnstat.htm b/applications/luci-vnstat/luasrc/view/vnstat.htm deleted file mode 100644 index d67f9b3be..000000000 --- a/applications/luci-vnstat/luasrc/view/vnstat.htm +++ /dev/null @@ -1,108 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> - -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 fs = require "nixio.fs" -local sys = require "luci.sys" -local utl = require "luci.util" - -local param = luci.http.formvalue - -local iface = param("iface") -local style = param("style") - -style = (style and #style > 0) and style or "s" - - --- --- render image --- -if iface then - style = style:gsub("[^%w]", "") - iface = iface:gsub("[^%w%.%-]", "") - - luci.http.prepare_content("image/png") - - local png = io.popen("vnstati -i '%s' '-%s' -o -" % { iface, style }) - luci.http.write(png:read("*a")) - png:close() - - return - --- --- update database --- -else - sys.call("vnstat -u >/dev/null 2>/dev/null") -end - - --- --- find databases --- -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" - --%> - -<%+header%> - -<h2><a id="content" name="content"><%:VnStat Graphs%></a></h2> - -<form action="" method="get"> - -<select name="style"> - <option value="s"<%=(style == "s") and ' selected="selected"' or ''%>><%:Summary display%></option> - <option value="t"<%=(style == "t") and ' selected="selected"' or ''%>><%:Top 10 display%></option> - <option value="h"<%=(style == "h") and ' selected="selected"' or ''%>><%:Hourly traffic%></option> - <option value="d"<%=(style == "d") and ' selected="selected"' or ''%>><%:Daily traffic%></option> - <option value="m"<%=(style == "m") and ' selected="selected"' or ''%>><%:Monthly traffic%></option> -</select> - -<input type="submit" value="<%:Update ยป%>" /> - -</form> - -<br /><hr /><br /> - -<div style="text-align:center"> -<% - empty = true - ifdir = fs.dir(dbdir) - - if ifdir then - for iface in ifdir do - if iface:sub(1,1) ~= "." then - empty = false -%> - <img src="<%=REQUEST_URI%>?iface=<%=iface%>&style=<%=param('style')%>" alt="" /> - <br /><br /> -<% - end - end - end -%> - -<% if empty then %> -<p><em><%:No database has been set up yet. Go to the VnStat configuration and enable monitoring for one or more interfaces.%></em></p> -<% end %> - -</div> - -<%+footer%> diff --git a/applications/luci-vnstat/root/etc/uci-defaults/luci-vnstat b/applications/luci-vnstat/root/etc/uci-defaults/luci-vnstat deleted file mode 100755 index fa204b3b4..000000000 --- a/applications/luci-vnstat/root/etc/uci-defaults/luci-vnstat +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -uci -q batch <<-EOF >/dev/null - delete ucitrack.@vnstat[-1] - add ucitrack vnstat - set ucitrack.@vnstat[-1].init=vnstat - commit ucitrack -EOF - -rm -f /tmp/luci-indexcache -exit 0 |