From 70925b47fbdede0dcf6083b54e5650e1ac112dda Mon Sep 17 00:00:00 2001 From: riley Date: Mon, 16 Oct 2023 15:37:29 -0400 Subject: [PATCH 1/8] updated status polling behavior and minor GUI updates --- luasrc/model/cbi/whoogle.lua | 2 +- luasrc/view/whoogle/status.htm | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/luasrc/model/cbi/whoogle.lua b/luasrc/model/cbi/whoogle.lua index 4edd549..c326a4c 100644 --- a/luasrc/model/cbi/whoogle.lua +++ b/luasrc/model/cbi/whoogle.lua @@ -11,7 +11,7 @@ m = taskd.docker_map("whoogle", "whoogle", "/usr/libexec/apps/whoogle/whoogle.sh translate("Whoogle is a free open-source self-hosted metasearch engine that allows you to search and get your Google results without ads, JavaScript trackers, or AMP links. It also ignores cookies, and does not perform any IP address tracking.") .. translate("Official website:") .. ' https://hub.docker.com/r/benbusby/whoogle-search/') -s = m:section(SimpleSection, translate("Service Status"), translate("whoogle status:")) +s = m:section(SimpleSection, translate("Service Status")) s:append(Template("whoogle/status")) s = m:section(TypedSection, "whoogle", translate("Setup"), translate("The following parameters will only take effect during installation or upgrade:")) diff --git a/luasrc/view/whoogle/status.htm b/luasrc/view/whoogle/status.htm index d55b3bc..be2ea29 100644 --- a/luasrc/view/whoogle/status.htm +++ b/luasrc/view/whoogle/status.htm @@ -1,16 +1,14 @@ <% local util = require "luci.util" local container_status = util.trim(util.exec("/usr/libexec/apps/whoogle/whoogle.sh status")) -local container_install = (string.len(container_status) > 0) -local container_running = container_status == "running" +local container_running = string.match(string.lower(container_status), "^up%W") -%>
-
<% if container_running then %> - + <% else %> - + <% end %>
@@ -24,8 +22,7 @@ if container_running then
- - +
-<% end %> +<% end %> \ No newline at end of file -- 2.38.4 From 3902dfe14071171c408026f5850e6958cac281d3 Mon Sep 17 00:00:00 2001 From: riley Date: Mon, 16 Oct 2023 15:48:47 -0400 Subject: [PATCH 2/8] more status polling fixes --- root/usr/libexec/apps/whoogle/whoogle.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/root/usr/libexec/apps/whoogle/whoogle.sh b/root/usr/libexec/apps/whoogle/whoogle.sh index b69f943..0a92a33 100644 --- a/root/usr/libexec/apps/whoogle/whoogle.sh +++ b/root/usr/libexec/apps/whoogle/whoogle.sh @@ -30,9 +30,6 @@ do_install_detail() { [ -z "$port" ] && port=5000 [ -z "$IMAGE_NAME" ] && IMAGE_NAME=benbusby/whoogle-search - - # Create Docker Compose file with custom variables - # Create Docker Compose file with custom variables rm -R /opt/docker2/compose/whoogle-app mkdir /opt/docker2/compose/whoogle-app @@ -130,8 +127,14 @@ case ${ACTION} in docker ${ACTION} whoogle ;; "status") - docker ps --all -f 'name=whoogle' --format '{{.State}}' - ;; + CONTAINER_NAME=$(docker ps -a --filter "name=whoogle-search" --format '{{.Names}}') + 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 "Whoogle is not installed" + else + echo "${CONTAINER_STATUS}" + fi + ;; "port") docker ps --all -f 'name=whoogle' --format '{{.Ports}}' | grep -om1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://' ;; -- 2.38.4 From 99b490c0fd22df4b7fc29a0dc3c09cfebdb5cf8f Mon Sep 17 00:00:00 2001 From: riley Date: Mon, 16 Oct 2023 17:20:37 -0400 Subject: [PATCH 3/8] Minor gui tweaks --- luasrc/view/whoogle/status.htm | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/luasrc/view/whoogle/status.htm b/luasrc/view/whoogle/status.htm index be2ea29..b46f17f 100644 --- a/luasrc/view/whoogle/status.htm +++ b/luasrc/view/whoogle/status.htm @@ -10,19 +10,15 @@ local container_running = string.match(string.lower(container_status), "^up%W") <% else %> <% end %> + + <% if container_running then %> + <% + local port=util.trim(util.exec("/usr/libexec/apps/whoogle/whoogle.sh port")) + if port == "" then + port="5000" + end + -%> + + <% end %> -<% -if container_running then - local port=util.trim(util.exec("/usr/libexec/apps/whoogle/whoogle.sh port")) - if port == "" then - port="5000" - end --%> -
- -
- -
-
-<% end %> \ No newline at end of file -- 2.38.4 From 9bb6ceb2ccfc8cc09b03e577617fe9affdafd9ac Mon Sep 17 00:00:00 2001 From: riley Date: Mon, 16 Oct 2023 17:26:17 -0400 Subject: [PATCH 4/8] start/stop/restart fix --- root/usr/libexec/apps/whoogle/whoogle.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/usr/libexec/apps/whoogle/whoogle.sh b/root/usr/libexec/apps/whoogle/whoogle.sh index 0a92a33..5e6ba17 100644 --- a/root/usr/libexec/apps/whoogle/whoogle.sh +++ b/root/usr/libexec/apps/whoogle/whoogle.sh @@ -124,7 +124,7 @@ case ${ACTION} in docker rm -f whoogle ;; "start" | "stop" | "restart") - docker ${ACTION} whoogle + docker ${ACTION} whoogle-search ;; "status") CONTAINER_NAME=$(docker ps -a --filter "name=whoogle-search" --format '{{.Names}}') -- 2.38.4 From 56d64dbf98f745e258ccd6e51fc8b4c413682725 Mon Sep 17 00:00:00 2001 From: riley Date: Mon, 16 Oct 2023 17:33:20 -0400 Subject: [PATCH 5/8] .sh made exec --- root/usr/libexec/apps/whoogle/whoogle.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 root/usr/libexec/apps/whoogle/whoogle.sh diff --git a/root/usr/libexec/apps/whoogle/whoogle.sh b/root/usr/libexec/apps/whoogle/whoogle.sh old mode 100644 new mode 100755 index 5e6ba17..189d4fc --- a/root/usr/libexec/apps/whoogle/whoogle.sh +++ b/root/usr/libexec/apps/whoogle/whoogle.sh @@ -121,7 +121,7 @@ case ${ACTION} in do_install_detail ;; "rm") - docker rm -f whoogle + docker rm -f whoogle-search ;; "start" | "stop" | "restart") docker ${ACTION} whoogle-search -- 2.38.4 From a7623019be50013fb39fbea06b07c574836f66aa Mon Sep 17 00:00:00 2001 From: riley Date: Mon, 16 Oct 2023 18:42:12 -0400 Subject: [PATCH 6/8] rm cleanup --- root/usr/libexec/apps/whoogle/whoogle.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/root/usr/libexec/apps/whoogle/whoogle.sh b/root/usr/libexec/apps/whoogle/whoogle.sh index 189d4fc..180342a 100755 --- a/root/usr/libexec/apps/whoogle/whoogle.sh +++ b/root/usr/libexec/apps/whoogle/whoogle.sh @@ -121,8 +121,17 @@ case ${ACTION} in do_install_detail ;; "rm") - docker rm -f whoogle-search - ;; + IMAGE_NAME=$(uci get whoogle.@whoogle[0].image_name 2>/dev/null) + [ -z "$IMAGE_NAME" ] && IMAGE_NAME="benbusby/whoogle-search" + CONTAINER_IDS=$(docker ps -a --filter "ancestor=${IMAGE_NAME}" --format '{{.ID}}') + echo "Stopping and removing containers..." + for ID in $CONTAINER_IDS; do + docker stop "$ID" + docker rm "$ID" + done + docker rmi -f "$IMAGE_NAME" + rm -r /opt/docker2/compose/whoogle-app 2>/dev/null + ;; "start" | "stop" | "restart") docker ${ACTION} whoogle-search ;; -- 2.38.4 From 41b6f083d8a72eb5a9e1dc10b0e10afd70237d7a Mon Sep 17 00:00:00 2001 From: riley Date: Tue, 17 Oct 2023 17:31:10 -0400 Subject: [PATCH 7/8] Fixed port number --- luasrc/view/whoogle/status.htm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/luasrc/view/whoogle/status.htm b/luasrc/view/whoogle/status.htm index b46f17f..6380ddd 100644 --- a/luasrc/view/whoogle/status.htm +++ b/luasrc/view/whoogle/status.htm @@ -10,12 +10,11 @@ local container_running = string.match(string.lower(container_status), "^up%W") <% else %> <% end %> - <% if container_running then %> <% local port=util.trim(util.exec("/usr/libexec/apps/whoogle/whoogle.sh port")) if port == "" then - port="5000" + port="1880" end -%> -- 2.38.4 From eb0145ddd5908f504bea1ed43e9c3ade3e53734b Mon Sep 17 00:00:00 2001 From: riley Date: Tue, 17 Oct 2023 17:40:26 -0400 Subject: [PATCH 8/8] Lil refactor --- luasrc/view/whoogle/status.htm | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/luasrc/view/whoogle/status.htm b/luasrc/view/whoogle/status.htm index 6380ddd..c60fcc4 100644 --- a/luasrc/view/whoogle/status.htm +++ b/luasrc/view/whoogle/status.htm @@ -2,22 +2,19 @@ local util = require "luci.util" local container_status = util.trim(util.exec("/usr/libexec/apps/whoogle/whoogle.sh status")) local container_running = string.match(string.lower(container_status), "^up%W") +local port = util.trim(util.exec("/usr/libexec/apps/whoogle/whoogle.sh port")) +if port == "" then + port="1880" +end -%> +
<% if container_running then %> - + + <% else %> - - <% end %> - <% if container_running then %> - <% - local port=util.trim(util.exec("/usr/libexec/apps/whoogle/whoogle.sh port")) - if port == "" then - port="1880" - end - -%> - + <% end %>
-- 2.38.4