update xunlei kuainiao luci to fit new luci api

This commit is contained in:
coolsnowwolf 2018-06-08 16:01:03 +08:00
parent 4186aca221
commit bbdff6fa1d
4 changed files with 10 additions and 9 deletions

View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-xlnetacc
PKG_VERSION:=1.0.3
PKG_RELEASE:=7
PKG_RELEASE:=8
PKG_LICENSE:=GPLv2
PKG_MAINTAINER:=Sense <sensec@gmail.com>

View File

@ -18,14 +18,14 @@ function index()
entry({"admin", "services", "xlnetacc", "logdata"}, call("action_log"))
end
local function is_running(name)
return luci.sys.call("pidof %s >/dev/null" %{name}) == 0
local function is_running()
return luci.sys.call("(ps | grep xlnetacc.sh | grep -v 'grep') >/dev/null" ) == 0
end
function action_status()
luci.http.prepare_content("application/json")
luci.http.write_json({
run_state = is_running("xlnetacc.sh"),
run_state = is_running(),
down_state = nixio.fs.readfile("/var/state/xlnetacc_down_state") or "",
up_state = nixio.fs.readfile("/var/state/xlnetacc_up_state") or ""
})

View File

@ -13,7 +13,7 @@
var up_state = document.getElementById('_up_state');
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "xlnetacc", "status")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
run_state.innerHTML = status.run_state ? '<%:RUNNING%>' : '<%:NOT RUNNING%>';
run_state.innerHTML = status.run_state ? '<em><b><font color=green><%:RUNNING%></font></b></em>' : '<em><b><font color=red><%:NOT RUNNING%></font></b></em>';
down_state.innerHTML = status.down_state ? status.down_state : '<%:No upgrade information%>';
up_state.innerHTML = status.up_state ? status.up_state : '<%:No upgrade information%>';
}

View File

@ -27,15 +27,15 @@ start() {
}
stop() {
pidof "${NAME}.sh" >/dev/null 2>&1 || return 1
ps | grep xlnetacc.sh | grep -v 'grep' >/dev/null 2>&1 || return 1
local pid spid
for pid in $(pidof "${NAME}.sh"); do
for pid in $(ps | grep xlnetacc.sh | grep -v 'grep' | awk '{print $1}'); do
echo "Stop XLNetAcc process PID: $pid"
kill $pid >/dev/null 2>&1
kill -9 $pid >/dev/null 2>&1
for spid in $(pgrep -P $pid "sleep"); do
echo "Stop XLNetAcc process SPID: $spid"
kill $spid >/dev/null 2>&1
kill -9 $spid >/dev/null 2>&1
done
done
logger -p "daemon.notice" -t "$NAME" "XLNetAcc has stoped."
@ -43,6 +43,7 @@ stop() {
}
restart() {
rm -rf /tmp/state/xlnetacc*
stop && sleep 1
start
}