Taskd compatibility update, Minor Improvements and Bug Fixes #2

Open
Ghost wants to merge 5 commits from <deleted>:main into main

@ -9,12 +9,12 @@ local m, s, o
m = taskd.docker_map("nodered", "nodered", "/usr/libexec/apps/nodered/nodered.sh", m = taskd.docker_map("nodered", "nodered", "/usr/libexec/apps/nodered/nodered.sh",
translate("Nodered"), translate("Nodered"),
translate("Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.") translate("Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.")
.. translate("Official website:") .. ' <a href=\"https://www.nodered.org/\" target=\"_blank\">https://www.nodered.org/</a>') .. "<br/>" .. translate("Official website:") .. ' <a href=\"https://www.nodered.org/\" target=\"_blank\">https://www.nodered.org/</a>')
s = m:section(SimpleSection, translate("Service Status"), translate("nodered status:")) s = m:section(SimpleSection, translate("Service Status"))
s:append(Template("nodered/status")) s:append(Template("nodered/status"))
s = m:section(TypedSection, "nodered", translate("Setup"), translate("Refresh to update settings.")) s = m:section(TypedSection, "nodered", translate("Setup"), translate("The following parameters will only take effect during installation or upgrade:"))
s.addremove=false s.addremove=false
s.anonymous=true s.anonymous=true

@ -1,31 +1,22 @@
<% <%
local util = require "luci.util" local util = require "luci.util"
local container_status = util.trim(util.exec("/usr/libexec/apps/nodered/nodered.sh status")) local container_status = util.trim(util.exec("/usr/libexec/apps/nodered/nodered.sh status"))
local container_running = string.find(string.lower(container_status), "up") and string.find(string.lower(container_status), "(healthy)") local container_running = string.match(string.lower(container_status), "^up%W")
local port=util.trim(util.exec("/usr/libexec/apps/nodered/nodered.sh port"))
-%> -%>
<div class="cbi-value"> <div class="cbi-value">
<label class="cbi-value-title">Status</label>
<div class="cbi-value-field"> <div class="cbi-value-field">
<% if container_running then %> <% if container_running then %>
<button class="cbi-button cbi-button-success" disabled="true"><%= container_status %></button> <button class="cbi-button cbi-button-success" disabled="true"><%= container_status %></button>
<% else %>
<button class="cbi-button cbi-button-negative" disabled="true"><%= container_status %></button>
<% end %>
</div>
</div>
<% <%
if container_running then
local port=util.trim(util.exec("/usr/libexec/apps/nodered/nodered.sh port"))
if port == "" then if port == "" then
port="1880" port="1880"
end end
-%> -%>
<div class="cbi-value cbi-value-last">
<label class="cbi-value-title">&nbsp;</label>
<div class="cbi-value-field">
<input type="button" class="btn cbi-button cbi-button-apply" name="start" value="<%:Open nodered%>" onclick="window.open('http://'+location.hostname+':<%=port%>/', '_blank')"> <input type="button" class="btn cbi-button cbi-button-apply" name="start" value="<%:Open nodered%>" onclick="window.open('http://'+location.hostname+':<%=port%>/', '_blank')">
<% else %>
<button class="cbi-button cbi-button-negative" disabled="true"><%= container_status %></button>
<% end %>
</div> </div>
</div> </div>
<% end %>

@ -87,15 +87,30 @@ case "${ACTION}" in
;; ;;
"start" | "stop" | "restart") "start" | "stop" | "restart")
APP_NAME="node-red" APP_NAME="node-red"
CONTAINER_IDS=$(docker ps -a --filter "ancestor=${APP_NAME}" --format '{{.ID}}') CONTAINER_IDS=$(docker ps -a | grep "$APP_NAME" | awk '{print $1}')
# Echo action message
if [ "$ACTION" == "start" ]; then
echo "Starting $APP_NAME container(s)"
elif [ "$ACTION" == "stop" ]; then
echo "Stopping $APP_NAME container(s)"
elif [ "$ACTION" == "restart" ]; then
echo "Restarting $APP_NAME container(s)"
fi
for ID in $CONTAINER_IDS; do for ID in $CONTAINER_IDS; do
docker "${ACTION}" "${ID}" docker "${ACTION}" "${ID}"
done done
;; ;;
"status") "status")
APP_NAME="node-red" APP_NAME="node-red"
CONTAINER_NAMES=$(docker ps -a --filter "name=${APP_NAME}" --format '{{.Names}}') CONTAINER_NAME=$(docker ps -a --filter "name=${APP_NAME}" --format '{{.Names}}')
docker ps --all -f "name=${CONTAINER_NAMES}" --format '{{.Status}}' CONTAINER_STATUS=$(docker ps --all --filter "name=${CONTAINER_NAME}" --format '{{.Status}}' | awk '/^Up/ { print "up " substr($0, 4) } !/^Up/ && /.+/ { print "down" }')
if [ -z "$CONTAINER_NAME" ]; then
echo "${APP_NAME} is not installed"
else
echo "${CONTAINER_STATUS}"
fi
;; ;;
"port") "port")
APP_NAME="node-red" APP_NAME="node-red"

Loading…
Cancel
Save