Merge pull request 'WIP-General Cleanup' (#1) from riley/luci-app-btcpayserver:main into main

Reviewed-on: #1
main
jason 1 year ago
commit 516e01b2ec

@ -6,6 +6,8 @@ include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for btcpayserver LUCI_TITLE:=LuCI support for btcpayserver
LUCI_PKGARCH:=all LUCI_PKGARCH:=all
LUCI_DEPENDS:=+lsblk +docker +luci-lib-taskd LUCI_DEPENDS:=+lsblk +docker +luci-lib-taskd
PKG_VERSION=1.0.1
PKG_RELEASE:=1
define Package/luci-app-btcpayserver/conffiles define Package/luci-app-btcpayserver/conffiles
/etc/config/btcpayserver /etc/config/btcpayserver

@ -8,7 +8,7 @@ local m, s, o
m = taskd.docker_map("btcpayserver", "btcpayserver", "/usr/libexec/apps/btcpayserver/btcpayserver.sh", m = taskd.docker_map("btcpayserver", "btcpayserver", "/usr/libexec/apps/btcpayserver/btcpayserver.sh",
translate("btcpayserver"), translate("btcpayserver"),
translate("Get Virtual Desktops of all flavors, Alpine, Ubuntu, Fedora, and Arch based containers containing full desktop environments in officially supported versions accessible via any modern web browser.") translate("BTCPay Server is a self-hosted, open-source cryptocurrency payment processor. It's secure, private, censorship-resistant and free.")
.. translate("Official website:") .. ' <a href=\"https://docs.linuxserver.io/images/docker-btcpayserver\" target=\"_blank\">hhttps://docs.linuxserver.io/images/docker-btcpayserver/</a>') .. translate("Official website:") .. ' <a href=\"https://docs.linuxserver.io/images/docker-btcpayserver\" target=\"_blank\">hhttps://docs.linuxserver.io/images/docker-btcpayserver/</a>')
s = m:section(SimpleSection, translate("Service Status"), translate("btcpayserver status:")) s = m:section(SimpleSection, translate("Service Status"), translate("btcpayserver status:"))

@ -1,19 +1,20 @@
<% <%
local util = require "luci.util" local util = require "luci.util"
local container_status = util.trim(util.exec("/usr/libexec/apps/btcpayserver/btcpayserver.sh status")) local container_status = util.trim(util.exec("/usr/libexec/apps/btcpayserver/btcpayserver.sh status"))
local container_install = (string.len(container_status) > 0) local container_running = string.match(string.lower(container_status), "^up%W")
local container_running = container_status == "running"
-%> -%>
<div class="cbi-value"> <div class="cbi-value">
<label class="cbi-value-title"><%:Status%></label> <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"><%:btcpayserver is running%></button> <button class="cbi-button cbi-button-success" disabled="true"><%= container_status %></button>
<% else %> <% else %>
<button class="cbi-button cbi-button-negative" disabled="true"><%:btcpayserver is not running%></button> <button class="cbi-button cbi-button-negative" disabled="true"><%= container_status %></button>
<% end %> <% end %>
</div> </div>
</div> </div>
<% <%
if container_running then if container_running then
local port = util.trim(util.exec("/usr/libexec/apps/btcpayserver/btcpayserver.sh port")) local port = util.trim(util.exec("/usr/libexec/apps/btcpayserver/btcpayserver.sh port"))
@ -24,7 +25,6 @@ if container_running then
<div class="cbi-value cbi-value-last"> <div class="cbi-value cbi-value-last">
<label class="cbi-value-title">&nbsp;</label> <label class="cbi-value-title">&nbsp;</label>
<div class="cbi-value-field"> <div class="cbi-value-field">
<input type="button" class="btn cbi-button cbi-button-apply" name="start" value="<%:Open btcpayserver%>" onclick="window.open('http://'+location.hostname+':<%=port%>/', '_blank')"> <input type="button" class="btn cbi-button cbi-button-apply" name="start" value="<%:Open btcpayserver%>" onclick="window.open('http://'+location.hostname+':<%=port%>/', '_blank')">
</div> </div>
</div> </div>

@ -5,6 +5,8 @@ APP_NAME="btcpayserver"
ACTION="${1}" ACTION="${1}"
shift 1 shift 1
mkdir -p /usr/local/bin
get_image() { get_image() {
do_install_detail do_install_detail
} }
@ -76,29 +78,36 @@ case "${ACTION}" in
do_install_detail do_install_detail
;; ;;
"rm") "rm")
IMAGE_NAME=$(uci get btcpayserver.@btcpayserver[0].image_name 2>/dev/null)
[ -z "$IMAGE_NAME" ] && IMAGE_NAME="btcpayserver"
CONTAINER_IDS=$(docker ps -a --filter "ancestor=${IMAGE_NAME}" --format '{{.ID}}')
echo "Stopping and removing containers..." echo "Stopping and removing containers..."
CONTAINER_IDS=$(docker ps -a | grep 'btcpayserver\|generated_' | awk '{print $1}')
for ID in $CONTAINER_IDS; do for ID in $CONTAINER_IDS; do
docker stop "$ID" docker stop "$ID"
docker rm "$ID" docker rm "$ID"
done done
docker rmi -f "$IMAGE_NAME" IMAGE_IDS=$(docker images | grep 'btcpayserver' | awk '{print $3}')
if [ -n "$IMAGE_IDS" ]; then
docker rmi -f $IMAGE_IDS
fi
rm -r /opt/docker2/compose/btcpayserver 2>/dev/null rm -r /opt/docker2/compose/btcpayserver 2>/dev/null
rm -rf /opt/docker2/compose/btcpayserver/btcpayserver-docker 2>/dev/null # Removing the btcpayserver-docker directory
;; ;;
"start" | "stop" | "restart") "start" | "stop" | "restart")
APP_NAME="btcpayserver" APP_NAME="btcpayserver"
CONTAINER_IDS=$(docker ps -a --filter "ancestor=${APP_NAME}" --format '{{.ID}}') CONTAINER_IDS=$(docker ps -a | grep 'btcpayserver\|generated_' | awk '{print $1}')
for ID in $CONTAINER_IDS; do for ID in $CONTAINER_IDS; do
docker "${ACTION}" "${ID}" docker "${ACTION}" "${ID}"
done done
;; ;;
"status") "status")
APP_NAME="btcpayserver" CONTAINER_NAME="generated_btcpayserver_1"
CONTAINER_NAMES=$(docker ps -a --filter "name=${APP_NAME}" --format '{{.Names}}') CONTAINER_STATUS=$(docker ps --all --filter "name=${CONTAINER_NAME}" --format '{{.Status}}' | awk '/^Up/ { print "up " substr($0, 4) } !/^Up/ && /.+/ { print "down" }')
docker ps --all -f "name=${CONTAINER_NAMES}" --format '{{.Status}}' if [ -z "$CONTAINER_STATUS" ]; then
echo "${APP_NAME} is not installed"
else
echo "${CONTAINER_STATUS}"
fi
;; ;;
"port") "port")
APP_NAME="btcpayserver" APP_NAME="btcpayserver"
CONTAINER_NAMES=$(docker ps -a --filter "ancestor=${APP_NAME}" --format '{{.Names}}') CONTAINER_NAMES=$(docker ps -a --filter "ancestor=${APP_NAME}" --format '{{.Names}}')

Loading…
Cancel
Save