From 0ce9525e165c4d5af119d16295e97dc094286623 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 27 Apr 2024 12:04:07 +0100 Subject: [PATCH] Add support for running on an exposed port (#16) * Only tweak if using ingress * Only change paths if using ingress --- DOCS.md | 3 +++ rootfs/etc/services.d/ghostfolio/run | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/DOCS.md b/DOCS.md index 3cc3733..1cf5dd1 100644 --- a/DOCS.md +++ b/DOCS.md @@ -35,6 +35,8 @@ The configuration is self-explanatory, but essentially we need details about acc Remember to restart the add-on when the configuration is changed. +To use this add-on with a reverse proxy, like [Nginx Proxy Manager][rev-proxy], you will need to enable "Show disabled ports" in the Network section of the add-on configuration and set a port. + ## Changelog & Releases This repository keeps a change log using [GitHub's releases][releases] functionality. @@ -56,3 +58,4 @@ To destroy this data, you'll need to either uninstall the PostgreSQL add-on or c [postgres]: https://github.com/matt-FFFFFF/hassio-addon-postgres [releases]: https://github.com/lildude/ha-addon-ghostfolio/releases [semver]: https://semver.org/spec/v2.0.0.html +[rev-proxy]: https://github.com/hassio-addons/addon-nginx-proxy-manager diff --git a/rootfs/etc/services.d/ghostfolio/run b/rootfs/etc/services.d/ghostfolio/run index 07827d9..15186c3 100644 --- a/rootfs/etc/services.d/ghostfolio/run +++ b/rootfs/etc/services.d/ghostfolio/run @@ -51,9 +51,15 @@ ingress_entry=$(curl -X GET \ -s http://supervisor/addons/self/info | \ jq -r '.data.ingress_entry') -if [[ $(grep hassio_ingress /ghostfolio/apps/client/en/main.*.js) -eq 0 ]]; then - sed -Ei "s^(\`|\")/api^\1${ingress_entry}/api^g" /ghostfolio/apps/client/*/*.js - sed -Ei "s^\(/assets^\(${ingress_entry}/assets^g" /ghostfolio/apps/client/*/*.js +if bashio::var.is_empty "$(bashio::addon.port 3333)"; then + if [[ $(grep hassio_ingress /ghostfolio/apps/client/en/main.*.js) -eq 0 ]]; then + sed -Ei.direct "s^(\`|\")/api^\1${ingress_entry}/api^g" /ghostfolio/apps/client/*/*.js + sed -Ei.direct "s^\(/assets^\(${ingress_entry}/assets^g" /ghostfolio/apps/client/*/*.js + fi +else + if [[ $(find "/ghostfolio/apps/client/en/*.js.direct" 2> /dev/null | wc -l) -gt 0 ]]; then + find /ghostfolio/apps/ -name '*.direct' -exec sh -c 'echo "$0" "${0%.direct}"' {} \; + fi fi bashio::log.info "Starting Ghostfolio"