summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-aria2/luasrc/controller/aria2.lua
diff options
context:
space:
mode:
Diffstat (limited to 'applications/luci-app-aria2/luasrc/controller/aria2.lua')
-rw-r--r--applications/luci-app-aria2/luasrc/controller/aria2.lua62
1 files changed, 0 insertions, 62 deletions
diff --git a/applications/luci-app-aria2/luasrc/controller/aria2.lua b/applications/luci-app-aria2/luasrc/controller/aria2.lua
deleted file mode 100644
index 52d7c94ebb..0000000000
--- a/applications/luci-app-aria2/luasrc/controller/aria2.lua
+++ /dev/null
@@ -1,62 +0,0 @@
--- Copyright 2016-2019 Xingwang Liao <kuoruan@gmail.com>
--- Licensed to the public under the MIT License.
-
-local fs = require "nixio.fs"
-local sys = require "luci.sys"
-local http = require "luci.http"
-local util = require "luci.util"
-local uci = require "luci.model.uci".cursor()
-
-module("luci.controller.aria2", package.seeall)
-
-function index()
- if not nixio.fs.access("/etc/config/aria2") then
- return
- end
-
- local e = entry({"admin", "services", "aria2"}, firstchild(), _("Aria2"))
- e.dependent = false
- e.acl_depends = { "luci-app-aria2" }
-
- entry({"admin", "services", "aria2", "config"},
- cbi("aria2/config"), _("Configuration"), 1)
-
- entry({"admin", "services", "aria2", "file"},
- form("aria2/files"), _("Files"), 2)
-
- entry({"admin", "services", "aria2", "log"},
- firstchild(), _("Log"), 3)
-
- entry({"admin", "services", "aria2", "log", "view"},
- template("aria2/log_template"))
-
- entry({"admin", "services", "aria2", "log", "read"},
- call("action_log_read"))
-
- entry({"admin", "services", "aria2", "status"},
- call("action_status"))
-
-end
-
-function action_status()
- local status = {
- running = (sys.call("pidof aria2c >/dev/null") == 0)
- }
-
- http.prepare_content("application/json")
- http.write_json(status)
-end
-
-function action_log_read()
- local data = { log = "", syslog = "" }
-
- local log_file = uci:get("aria2", "main", "log") or "/var/log/aria2.log"
- if fs.access(log_file) then
- data.log = util.trim(sys.exec("tail -n 50 %s | sed 'x;1!H;$!d;x'" % log_file))
- end
-
- data.syslog = util.trim(sys.exec("logread | grep aria2 | tail -n 50 | sed 'x;1!H;$!d;x'"))
-
- http.prepare_content("application/json")
- http.write_json(data)
-end