1
0

aria2.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --[[
  2. LuCI - Lua Configuration Interface - aria2 support
  3. Copyright 2014-2015 nanpuyue <nanpuyue@gmail.com>
  4. Modified by kuoruan <kuoruan@gmail.com>
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. ]]--
  10. module("luci.controller.aria2", package.seeall)
  11. function index()
  12. if not nixio.fs.access("/etc/config/aria2") then
  13. return
  14. end
  15. local page = entry({"admin", "services", "aria2"}, cbi("aria2"), _("Aria2 Settings"))
  16. page.dependent = true
  17. entry({"admin", "services", "aria2", "status"}, call("status")).leaf = true
  18. end
  19. function status()
  20. local sys = require "luci.sys"
  21. local ipkg = require "luci.model.ipkg"
  22. local http = require "luci.http"
  23. local uci = require "luci.model.uci".cursor()
  24. local status = {
  25. running = (sys.call("pidof aria2c > /dev/null") == 0),
  26. yaaw = ipkg.installed("yaaw"),
  27. webui = ipkg.installed("webui-aria2")
  28. }
  29. http.prepare_content("application/json")
  30. http.write_json(status)
  31. end