diff --git a/Makefile b/Makefile index 843fcd9..b1fd6ee 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,18 @@ # -# Copyright (C) 2022 jjm2473 +# Copyright (C) 2022 jason # # This is free software, licensed under the MIT License. # include $(TOPDIR)/rules.mk +PKG_VERSION=2.0.2.001 LUCI_TITLE:=Task library LUCI_DEPENDS:=+luci-lib-xterm +taskd LUCI_EXTRA_DEPENDS:=taskd (>=1.0.3-1) LUCI_PKGARCH:=all -PKG_MAINTAINER:=jjm2473 +PKG_MAINTAINER:=jason include $(TOPDIR)/feeds/luci/luci.mk diff --git a/luasrc/view/tasks/docker.htm b/luasrc/view/tasks/docker.htm index 66ce0e6..75d8abe 100644 --- a/luasrc/view/tasks/docker.htm +++ b/luasrc/view/tasks/docker.htm @@ -1,56 +1,91 @@ +<% +local taskd = require "luci.model.tasks" +local status = taskd.status(self.task_id) -<% if self.task_start_failed then %> -
<%:Another task running, try again later.%> <%:Click here to check running task%>
+-- Check if a task is running +local task_running = status.running + +-- Check for a task start failure +if self.task_start_failed then +%> +
+ <%:Another task running, try again later.%> + + <%:Click here to check running task%> + +
<% end %> <%+cbi/map%> -<% -local task_running = false -local taskd = require "luci.model.tasks" -local status = taskd.status(self.task_id) -task_running = status.running --%> + +
<% -if not task_running then -%> - <% - local util = require "luci.util" - local container_status = util.trim(util.exec(self.script_path.." status")) - local container_install = (string.len(container_status) > 0) - local container_running = container_status == "running" - if container_install then - -%> - - <% - if container_running then - -%> - - - - <% else %> - - - - <% end - else %> - - <% end -else - %> - + if not task_running then + local util = require "luci.util" + + local container_status = util.trim(util.exec(self.script_path.." status")) + local container_status_lower = string.lower(container_status) + + local container_install = not string.match(container_status_lower, " is not installed$") + local container_running = string.match(container_status_lower, "^up%W") + + if container_install then +%> + +<% + if container_running then +%> + + +<% + else +%> + + +<% + end + else +%> + +<% + end + else +%> + <% -end + end %>
-<%+tasks/embed%> -<% -if self.auto_show_task and task_running then --%> -<% -end + +<%+tasks/embed%> + +<% +if self.auto_show_task and task_running then +%> + +<% +end %>