1
0

wifi_schedule.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. -- Copyright (c) 2016, prpl Foundation
  2. --
  3. -- Permission to use, copy, modify, and/or distribute this software for any purpose with or without
  4. -- fee is hereby granted, provided that the above copyright notice and this permission notice appear
  5. -- in all copies.
  6. --
  7. -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
  8. -- INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
  9. -- FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  10. -- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  11. -- ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  12. --
  13. -- Author: Nils Koenig <openwrt@newk.it>
  14. module("luci.controller.wifischedule.wifi_schedule", package.seeall)
  15. local fs = require "nixio.fs"
  16. local sys = require "luci.sys"
  17. local template = require "luci.template"
  18. local i18n = require "luci.i18n"
  19. function index()
  20. if not nixio.fs.access("/etc/config/wifi_schedule") then
  21. return
  22. end
  23. entry({"admin", "services", "wifi_schedule"}, firstchild(), _("Wifi Schedule"), 60).dependent=false
  24. entry({"admin", "services", "wifi_schedule", "tab_from_cbi"}, cbi("wifischedule/wifi_schedule"), _("Schedule"), 1)
  25. entry({"admin", "services", "wifi_schedule", "wifi_schedule"}, call("wifi_schedule_log"), _("View Logfile"), 2)
  26. entry({"admin", "services", "wifi_schedule", "cronjob"}, call("view_crontab"), _("View Cron Jobs"), 3)
  27. end
  28. function wifi_schedule_log()
  29. local logfile = fs.readfile("/tmp/log/wifi_schedule.log") or ""
  30. template.render("wifischedule/file_viewer",
  31. {title = i18n.translate("Wifi Schedule Logfile"), content = logfile})
  32. end
  33. function view_crontab()
  34. local crontab = fs.readfile("/etc/crontabs/root") or ""
  35. template.render("wifischedule/file_viewer",
  36. {title = i18n.translate("Cron Jobs"), content = crontab})
  37. end