From d3cdb01992f3c7127e8a3aba5e2e8d43920aaf35 Mon Sep 17 00:00:00 2001 From: Zachary Knight Date: Sun, 27 Jun 2021 18:20:22 -0400 Subject: [PATCH] Added configuration base_url to fix outstanding issues with the interface of Grocy --- grocy/DOCS.md | 7 +++++++ grocy/config.json | 2 ++ grocy/rootfs/etc/cont-init.d/grocy.sh | 10 ++++++---- grocy/rootfs/etc/cont-init.d/php-fpm.sh | 3 ++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/grocy/DOCS.md b/grocy/DOCS.md index 84f5999..bb34f78 100644 --- a/grocy/DOCS.md +++ b/grocy/DOCS.md @@ -19,6 +19,7 @@ comparison to installing any other Home Assistant add-on. 1. Search for the "Grocy" add-on in the Supervisor add-on store. 1. Install the "Grocy" add-on. +1. Set the `base_url` in the configuration to your home assistant URL. 1. Start the "Grocy" add-on. 1. Check the logs of the "Grocy" add-on to see if everything went well. 1. Click on the "OPEN WEB UI" button to get into the interface of Grocy. @@ -32,6 +33,7 @@ comparison to installing any other Home Assistant add-on. Example add-on configuration: ```yaml +base_url: http://homeassistant.local:8123 culture: en currency: USD entry_page: stock @@ -61,6 +63,11 @@ keyfile: privkey.pem **Note**: _This is just an example, don't copy and paste it! Create your own!_ +### Option `base_url` +The `base_url` contains the URL of your home assistant's installation. This is required for your installation to function properly. + +Example: `http://homeassistant.local:8123` + ### Option: `log_level` The `log_level` option controls the level of log output by the addon and can diff --git a/grocy/config.json b/grocy/config.json index 4076b3b..2624ab4 100755 --- a/grocy/config.json +++ b/grocy/config.json @@ -15,6 +15,7 @@ "80/tcp": "Web interface (Not required for Ingress)" }, "options": { + "base_url": "http://homeassistant.local:8123", "culture": "en", "currency": "USD", "entry_page": "stock", @@ -43,6 +44,7 @@ "keyfile": "privkey.pem" }, "schema": { + "base_url": "str", "log_level": "list(trace|debug|info|notice|warning|error|fatal)?", "culture": "list(cs|da|de|el_GR|en|en_GB|es|fi|fr|he_IL|hu|it|ja|ko_KR|nl|no|pl|pt_BR|pt_PT|ru|sk_SK|sv_SE|ta|tr|zh_CN|zh_TW)", "currency": "match(^[A-Z]{3}$)", diff --git a/grocy/rootfs/etc/cont-init.d/grocy.sh b/grocy/rootfs/etc/cont-init.d/grocy.sh index f880f33..213e99d 100644 --- a/grocy/rootfs/etc/cont-init.d/grocy.sh +++ b/grocy/rootfs/etc/cont-init.d/grocy.sh @@ -24,7 +24,9 @@ bashio::log.debug 'Symlinking data directory to persistent storage location...' rm -f -r /var/www/grocy/data ln -s /data/grocy /var/www/grocy/data -# Patch current relative URL handling braindamage -bashio::log.info "Patching Grocy to fix relative URL handling..." -cd /var/www/grocy || bashio.exit.nok 'Failed cd' -patch -p1 < /patches/fix_braindamage.patch || true +if bashio::var.is_empty "$(bashio::config 'base_url')"; then + # Patch current relative URL handling braindamage + bashio::log.info "Patching Grocy to fix relative URL handling..." + cd /var/www/grocy || bashio.exit.nok 'Failed cd' + patch -p1 < /patches/fix_braindamage.patch || true +fi \ No newline at end of file diff --git a/grocy/rootfs/etc/cont-init.d/php-fpm.sh b/grocy/rootfs/etc/cont-init.d/php-fpm.sh index 48799b4..96dfa23 100644 --- a/grocy/rootfs/etc/cont-init.d/php-fpm.sh +++ b/grocy/rootfs/etc/cont-init.d/php-fpm.sh @@ -5,10 +5,11 @@ # ============================================================================== # Generate Ingress configuration +base_url="$(bashio::config 'base_url')$(bashio::addon.ingress_entry)" bashio::var.json \ name "ingress" \ port "^9002" \ - base "$(bashio::addon.ingress_entry)" \ + base "$base_url" \ | tempio \ -template /etc/php7/templates/php-fpm.gtpl \ -out /etc/php7/php-fpm.d/ingress.conf