forked from coolsnowwolf/lede
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
389 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (C) 2018-2019 Lienol | ||
# Copyright (C) 2018-2020 Lienol <[email protected]> | ||
# | ||
# This is free software, licensed under the Apache License, Version 2.0 . | ||
# | ||
|
@@ -9,7 +9,7 @@ LUCI_TITLE:=LuCI support for KodExplorer | |
LUCI_DEPENDS:=+nginx +zoneinfo-asia +php7 +php7-fpm +php7-mod-curl +php7-mod-gd +php7-mod-iconv +php7-mod-json +php7-mod-mbstring +php7-mod-opcache +php7-mod-session +php7-mod-zip | ||
LUCI_PKGARCH:=all | ||
PKG_VERSION:=1.0 | ||
PKG_RELEASE:=5-20190518 | ||
PKG_RELEASE:=10-20191217 | ||
|
||
include $(TOPDIR)/feeds/luci/luci.mk | ||
|
||
|
62 changes: 35 additions & 27 deletions
62
package/lean/luci-app-kodexplorer/luasrc/controller/kodexplorer.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,54 @@ | ||
-- Copyright 2018-2020 Lienol <[email protected]> | ||
module("luci.controller.kodexplorer", package.seeall) | ||
|
||
local http = require "luci.http" | ||
local api = require "luci.model.cbi.kodexplorer.api" | ||
|
||
function index() | ||
if not nixio.fs.access("/etc/config/kodexplorer") then | ||
return | ||
end | ||
|
||
entry({"admin","nas","kodexplorer"},cbi("kodexplorer/settings"),_("KodExplorer"),3).dependent=true | ||
|
||
entry({"admin","nas","kodexplorer","check"},call("action_check")).leaf=true | ||
entry({"admin","nas","kodexplorer","download"},call("action_download")).leaf=true | ||
entry({"admin","nas","kodexplorer","status"},call("act_status")).leaf=true | ||
if not nixio.fs.access("/etc/config/kodexplorer") then return end | ||
|
||
entry({"admin", "nas"}, firstchild(), "NAS", 44).dependent = false | ||
entry({"admin", "nas", "kodexplorer"}, cbi("kodexplorer/settings"), | ||
_("KodExplorer"), 3).dependent = true | ||
|
||
entry({"admin", "nas", "kodexplorer", "check"}, call("action_check")).leaf = | ||
true | ||
entry({"admin", "nas", "kodexplorer", "download"}, call("action_download")).leaf = | ||
true | ||
entry({"admin", "nas", "kodexplorer", "status"}, call("act_status")).leaf = | ||
true | ||
end | ||
|
||
local function http_write_json(content) | ||
http.prepare_content("application/json") | ||
http.write_json(content or { code = 1 }) | ||
http.prepare_content("application/json") | ||
http.write_json(content or {code = 1}) | ||
end | ||
|
||
function act_status() | ||
local e={} | ||
e.nginx_status=luci.sys.call("ps -w | grep nginx | grep kodexplorer | grep -v grep > /dev/null") == 0 | ||
e.php_status=luci.sys.call("ps -w | grep php | grep kodexplorer | grep -v grep > /dev/null") == 0 | ||
http_write_json(e) | ||
local e = {} | ||
e.nginx_status = luci.sys.call( | ||
"ps -w | grep nginx | grep kodexplorer | grep -v grep > /dev/null") == | ||
0 | ||
e.php_status = luci.sys.call( | ||
"ps -w | grep php | grep kodexplorer | grep -v grep > /dev/null") == | ||
0 | ||
http_write_json(e) | ||
end | ||
|
||
function action_check() | ||
local json = api.to_check() | ||
http_write_json(json) | ||
local json = api.to_check() | ||
http_write_json(json) | ||
end | ||
|
||
function action_download() | ||
local json = nil | ||
local task = http.formvalue("task") | ||
if task == "extract" then | ||
json = api.to_extract(http.formvalue("file")) | ||
elseif task == "move" then | ||
json = api.to_move(http.formvalue("file")) | ||
else | ||
json = api.to_download(http.formvalue("url")) | ||
end | ||
http_write_json(json) | ||
local json = nil | ||
local task = http.formvalue("task") | ||
if task == "extract" then | ||
json = api.to_extract(http.formvalue("file")) | ||
elseif task == "move" then | ||
json = api.to_move(http.formvalue("file")) | ||
else | ||
json = api.to_download(http.formvalue("url")) | ||
end | ||
http_write_json(json) | ||
end |
Oops, something went wrong.