commit cde15848b4206b60e81927849db0844b0a3f09b3 Author: john Date: Thu Feb 19 21:26:09 2026 +0100 copy from official addon diff --git a/.mdlrc b/.mdlrc new file mode 100644 index 0000000..2b0128d --- /dev/null +++ b/.mdlrc @@ -0,0 +1 @@ +rules "~MD024" \ No newline at end of file diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..f4bc5a4 --- /dev/null +++ b/.yamllint @@ -0,0 +1,66 @@ +--- +rules: + braces: + level: error + min-spaces-inside: 0 + max-spaces-inside: 1 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + brackets: + level: error + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + colons: + level: error + max-spaces-before: 0 + max-spaces-after: 1 + commas: + level: error + max-spaces-before: 0 + min-spaces-after: 1 + max-spaces-after: 1 + comments: + level: error + require-starting-space: true + min-spaces-from-content: 2 + comments-indentation: + level: error + document-end: + level: error + present: false + document-start: + level: error + present: true + empty-lines: + level: error + max: 1 + max-start: 0 + max-end: 1 + hyphens: + level: error + max-spaces-after: 1 + indentation: + level: error + spaces: 2 + indent-sequences: true + check-multi-line-strings: false + key-duplicates: + level: error + line-length: + ignore: | + .github/support.yml + level: warning + max: 120 + allow-non-breakable-words: true + allow-non-breakable-inline-mappings: true + new-line-at-end-of-file: + level: error + new-lines: + level: error + type: unix + trailing-spaces: + level: error + truthy: + level: error diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..e8ae5c9 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) 2018-2025 Franck Nijhof + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..301628e --- /dev/null +++ b/README.md @@ -0,0 +1,127 @@ +# Home Assistant Community Add-on: Grafana + +[![GitHub Release][releases-shield]][releases] +![Project Stage][project-stage-shield] +[![License][license-shield]](LICENSE.md) + +![Supports aarch64 Architecture][aarch64-shield] +![Supports amd64 Architecture][amd64-shield] + +[![Github Actions][github-actions-shield]][github-actions] +![Project Maintenance][maintenance-shield] +[![GitHub Activity][commits-shield]][commits] + +[![Discord][discord-shield]][discord] +[![Community Forum][forum-shield]][forum] + +[![Sponsor Frenck via GitHub Sponsors][github-sponsors-shield]][github-sponsors] + +[![Support Frenck on Patreon][patreon-shield]][patreon] + +The open platform for beautiful analytics and monitoring. + +![Grafana in the Home Assistant Frontend](images/screenshot.png) + +## About + +The analytics platform for all your metrics. + +Grafana allows you to query, visualize, alert on and understand your metrics +no matter where they are stored. Create, explore, and share dashboards. Learn +about your Home Automation system using sexy and compelling graphs, and other +data visualizations. + +Combine this add-on with the InfluxDB add-on to get insanely powerful +insights to your home. + +[:books: Read the full add-on documentation][docs] + +## Support + +Got questions? + +You have several options to get them answered: + +- The [Home Assistant Community Add-ons Discord chat server][discord] for add-on + support and feature requests. +- The [Home Assistant Discord chat server][discord-ha] for general Home + Assistant discussions and questions. +- The Home Assistant [Community Forum][forum]. +- Join the [Reddit subreddit][reddit] in [/r/homeassistant][reddit] + +You could also [open an issue here][issue] GitHub. + +## Contributing + +This is an active open-source project. We are always open to people who want to +use the code or contribute to it. + +We have set up a separate document containing our +[contribution guidelines](.github/CONTRIBUTING.md). + +Thank you for being involved! :heart_eyes: + +## Authors & contributors + +The original setup of this repository is by [Franck Nijhof][frenck]. + +For a full list of all authors and contributors, +check [the contributor's page][contributors]. + +## We have got some Home Assistant add-ons for you + +Want some more functionality to your Home Assistant instance? + +We have created multiple add-ons for Home Assistant. For a full list, check out +our [GitHub Repository][repository]. + +## License + +MIT License + +Copyright (c) 2018-2025 Franck Nijhof + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg +[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg +[commits-shield]: https://img.shields.io/github/commit-activity/y/hassio-addons/addon-grafana.svg +[commits]: https://github.com/hassio-addons/addon-grafana/commits/main +[contributors]: https://github.com/hassio-addons/addon-grafana/graphs/contributors +[discord-ha]: https://discord.gg/c5DvZ4e +[discord-shield]: https://img.shields.io/discord/478094546522079232.svg +[discord]: https://discord.me/hassioaddons +[docs]: https://github.com/hassio-addons/addon-grafana/blob/main/grafana/DOCS.md +[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg +[forum]: https://community.home-assistant.io/t/home-assistant-community-add-on-grafana/54674?u=frenck +[frenck]: https://github.com/frenck +[github-actions-shield]: https://github.com/hassio-addons/addon-grafana/workflows/CI/badge.svg +[github-actions]: https://github.com/hassio-addons/addon-grafana/actions +[github-sponsors-shield]: https://frenck.dev/wp-content/uploads/2019/12/github_sponsor.png +[github-sponsors]: https://github.com/sponsors/frenck +[issue]: https://github.com/hassio-addons/addon-grafana/issues +[license-shield]: https://img.shields.io/github/license/hassio-addons/addon-grafana.svg +[maintenance-shield]: https://img.shields.io/maintenance/yes/2025.svg +[patreon-shield]: https://frenck.dev/wp-content/uploads/2019/12/patreon.png +[patreon]: https://www.patreon.com/frenck +[project-stage-shield]: https://img.shields.io/badge/project%20stage-production%20ready-brightgreen.svg +[reddit]: https://reddit.com/r/homeassistant +[releases-shield]: https://img.shields.io/github/release/hassio-addons/addon-grafana.svg +[releases]: https://github.com/hassio-addons/addon-grafana/releases +[repository]: https://github.com/hassio-addons/repository diff --git a/grafana/.README.j2 b/grafana/.README.j2 new file mode 100644 index 0000000..d41cde6 --- /dev/null +++ b/grafana/.README.j2 @@ -0,0 +1,78 @@ +# Home Assistant Community Add-on: Grafana + +[![Release][release-shield]][release] ![Project Stage][project-stage-shield] ![Project Maintenance][maintenance-shield] + +[![Discord][discord-shield]][discord] [![Community Forum][forum-shield]][forum] + +[![Sponsor Frenck via GitHub Sponsors][github-sponsors-shield]][github-sponsors] + +[![Support Frenck on Patreon][patreon-shield]][patreon] + +The open platform for beautiful analytics and monitoring. + +## About + +The analytics platform for all your metrics. + +Grafana allows you to query, visualize, alert on and understand your metrics +no matter where they are stored. Create, explore, and share dashboards. Learn +about your Home Automation system using sexy and compelling graphs, and other +data visualizations. + +Combine this add-on with the InfluxDB add-on to get insanely powerful +insights to your home. + +![Grafana in the Home Assistant Frontend][screenshot] + +{% if channel == "edge" %} +## WARNING! THIS IS AN EDGE VERSION! + +This Home Assistant Add-ons repository contains edge builds of add-ons. +Edge builds add-ons are based upon the latest development version. + +- They may not work at all. +- They might stop working at any time. +- They could have a negative impact on your system. + +This repository was created for: + +- Anybody willing to test. +- Anybody interested in trying out upcoming add-ons or add-on features. +- Developers. + +If you are more interested in stable releases of our add-ons: + + + +{% endif %} +{% if channel == "beta" %} +## WARNING! THIS IS A BETA VERSION! + +This Home Assistant Add-ons repository contains beta releases of add-ons. + +- They might stop working at any time. +- They could have a negative impact on your system. + +This repository was created for: + +- Anybody willing to test. +- Anybody interested in trying out upcoming add-ons or add-on features. + +If you are more interested in stable releases of our add-ons: + + + +{% endif %} +[discord-shield]: https://img.shields.io/discord/478094546522079232.svg +[discord]: https://discord.me/hassioaddons +[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg +[forum]: https://community.home-assistant.io/t/home-assistant-community-add-on-grafana/54674?u=frenck +[github-sponsors-shield]: https://frenck.dev/wp-content/uploads/2019/12/github_sponsor.png +[github-sponsors]: https://github.com/sponsors/frenck +[maintenance-shield]: https://img.shields.io/maintenance/yes/2025.svg +[patreon-shield]: https://frenck.dev/wp-content/uploads/2019/12/patreon.png +[patreon]: https://www.patreon.com/frenck +[project-stage-shield]: https://img.shields.io/badge/project%20stage-production%20ready-brightgreen.svg +[release-shield]: https://img.shields.io/badge/version-{{ version }}-blue.svg +[release]: {{ repo }}/tree/{{ version }} +[screenshot]: https://github.com/hassio-addons/addon-grafana/raw/main/images/screenshot.png diff --git a/grafana/DOCS.md b/grafana/DOCS.md new file mode 100644 index 0000000..ea9a6f4 --- /dev/null +++ b/grafana/DOCS.md @@ -0,0 +1,234 @@ +# Home Assistant Community Add-on: Grafana + +The analytics platform for all your metrics. + +Grafana allows you to query, visualize, alert on and understand your metrics +no matter where they are stored. Create, explore, and share dashboards. Learn +about your Home Automation system using sexy and compelling graphs, and other +data visualizations. + +Combine this add-on with the InfluxDB add-on to get insanely powerful +insights to your home. + +## Installation + +The installation of this add-on is pretty straightforward and not different in +comparison to installing any other Home Assistant add-on. + +1. Click the Home Assistant My button below to open the add-on on your Home + Assistant instance. + + [![Open this add-on in your Home Assistant instance.][addon-badge]][addon] + +1. Click the "Install" button to install the add-on. +1. Start the "Grafana" add-on. +1. Check the logs of the "Grafana" to see if everything went well. +1. Open the Web UI. + +**Note**: As the addon now supports both Ingress and direct access, the default +`admin` user has a password of `hassio`. **Due to the implementation the +password cannot be changed, however you can delete and create a new user, if so +please ensure to update the `grafana_ingress_user` option.** + +## Configuration + +**Note**: _Remember to restart the add-on when the configuration is changed._ + +Example add-on configuration: + +```yaml +log_level: info +grafana_ingress_user: frenck +plugins: + - ayoungprogrammer-finance-datasource + - grafana-clock-panel +env_vars: + - name: GF_DEFAULT_INSTANCE_NAME + value: Hassio +``` + +**Note**: _This is just an example, don't copy and paste it! Create your own!_ + +### Option: `log_level` + +The `log_level` option controls the level of log output by the addon and can +be changed to be more or less verbose, which might be useful when you are +dealing with an unknown issue. Possible values are: + +- `trace`: Show every detail, like all called internal functions. +- `debug`: Shows detailed debug information. +- `info`: Normal (usually) interesting events. +- `warning`: Exceptional occurrences that are not errors. +- `error`: Runtime errors that do not require immediate action. +- `fatal`: Something went terribly wrong. Add-on becomes unusable. + +Please note that each level automatically includes log messages from a +more severe level, e.g., `debug` also shows `info` messages. By default, +the `log_level` is set to `info`, which is the recommended setting unless +you are troubleshooting. + +### Option: `grafana_ingress_user` + +When using Ingress grafana will automatically log in by default with a username +of `admin`. If a different user is required this option can be set. + +### Option: `plugins` + +Allows you to specify additional Grafana plugins to be installed to your +Grafana setup. For a list of available plugins, see: + + + +**Note**: _Adding plugins will result in a longer start-up for the add-on._ + +### Option: `custom_plugins` + +Allows you to specify additional Grafana custom plugins to be installed to your +Grafana setup from an URL. +You must specify the property `url` to the plugin configuration. + +If you want to install unsigned plugins, you must also set the `unsigned` property to `true`: + +```yaml +custom_plugins: + - name: my-plugin-name + url: https://github.com/my-repo/my-plugin-name/releases/download/0.1.0/my-plugin-name-0.1.0.zip + unsigned: true +``` + +### Option: `env_vars` + +This option allows you to tweak every aspect of Grafana by setting +configuration options using environment variables. See the example at the +start of this chapter to get an idea of how the configuration looks. + +For more information about using these variables, see the official Grafana +documentation: + + + +**Note**: _Only environment variables starting with `GF_` are accepted.\_ + +## Using it with the InfluxDB Community add-on + +Grafana does not come out of the box pre-configured, but letting it interact +with the community [InfluxDB add-on][influxdb-addon] is pretty easy. Please, +follow the instructions from the on how to [create a database][create-db] +for Home Assistant. + +1. Create a new user for Grafana on InfluxDB + (InfluxDB Admin -> Users and "+ Create User") +1. Login into Grafana +1. Create a new datasource: + +- Name: Anything you want, e.g., Home Assistant +- Type: InfluxDB +- HTTP > URL: `http://a0d7b954-influxdb:8086` +- HTTP > Access: Server (Default) +- Auth: (leave them all disabled) +- InfluxDB Details > Database: _Your Home Assistant InfluxDB database_, + e.g., `homeassistant` +- InfluxDB Details > User: _Grafana InfluxDB username defined in step 1_ +- InfluxDB Details > Password: _Grafana InfluxDB user password defined_ + _in step 1_ + +1. Hit Save & Test + +## Anonymous Access + +Anonymous access on a local network is possible by exposing the port in the +add-on configuration, along with setting the following environment variables: + +```yaml +env_vars: + - name: GF_AUTH_ANONYMOUS_ENABLED + value: "true" + - name: GF_AUTH_ANONYMOUS_ORG_NAME + value: "Main Org." + - name: GF_AUTH_ANONYMOUS_ORG_ROLE + value: "Viewer" +``` + +It is not possible to enable anonymous or non-administrator access with Home +Assistant Cloud. This includes embedding Grafana resources with an iframe or +rendered image inside of a dashboard. For more details see +[Anonymous login not working, Grafana add-on 3.0.0 #55](https://github.com/hassio-addons/addon-grafana/issues/55). + +## Known issues and limitations + +- `To render a panel image, you must install the Grafana Image Renderer plugin.` + This message is shown on ARM devices, like a Raspberry Pi. The Grafana Image + Renderer plugin is not available for these devices. + +## Changelog & Releases + +This repository keeps a change log using [GitHub's releases][releases] +functionality. + +Releases are based on [Semantic Versioning][semver], and use the format +of `MAJOR.MINOR.PATCH`. In a nutshell, the version will be incremented +based on the following: + +- `MAJOR`: Incompatible or major changes. +- `MINOR`: Backwards-compatible new features and enhancements. +- `PATCH`: Backwards-compatible bugfixes and package updates. + +## Support + +Got questions? + +You have several options to get them answered: + +- The [Home Assistant Community Add-ons Discord chat server][discord] for add-on + support and feature requests. +- The [Home Assistant Discord chat server][discord-ha] for general Home + Assistant discussions and questions. +- The Home Assistant [Community Forum][forum]. +- Join the [Reddit subreddit][reddit] in [/r/homeassistant][reddit] + +You could also [open an issue here][issue] GitHub. + +## Authors & contributors + +The original setup of this repository is by [Franck Nijhof][frenck]. + +For a full list of all authors and contributors, +check [the contributor's page][contributors]. + +## License + +MIT License + +Copyright (c) 2018-2025 Franck Nijhof + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +[addon-badge]: https://my.home-assistant.io/badges/supervisor_addon.svg +[addon]: https://my.home-assistant.io/redirect/supervisor_addon/?addon=a0d7b954_grafana&repository_url=https%3A%2F%2Fgithub.com%2Fhassio-addons%2Frepository +[contributors]: https://github.com/hassio-addons/addon-grafana/graphs/contributors +[create-db]: https://github.com/hassio-addons/addon-influxdb/blob/main/influxdb/DOCS.md#integrating-into-home-assistant +[discord-ha]: https://discord.gg/c5DvZ4e +[discord]: https://discord.me/hassioaddons +[forum]: https://community.home-assistant.io/t/home-assistant-community-add-on-grafana/54674?u=frenck +[frenck]: https://github.com/frenck +[influxdb-addon]: https://github.com/hassio-addons/addon-influxdb +[issue]: https://github.com/hassio-addons/addon-grafana/issues +[reddit]: https://reddit.com/r/homeassistant +[releases]: https://github.com/hassio-addons/addon-grafana/releases +[semver]: https://semver.org/spec/v2.0.0.html diff --git a/grafana/Dockerfile b/grafana/Dockerfile new file mode 100644 index 0000000..c9510c0 --- /dev/null +++ b/grafana/Dockerfile @@ -0,0 +1,99 @@ +ARG BUILD_FROM=ghcr.io/hassio-addons/debian-base/amd64:9.1.0 +# hadolint ignore=DL3006 +FROM ${BUILD_FROM} + +# Set shell +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# Setup base system +ARG BUILD_ARCH=amd64 +ARG GRAFANA_VERSION="v12.3.1" +ARG GRAFANA_IMAGE_RENDERER_VERSION="v4.1.5" +RUN \ + ARCH="${BUILD_ARCH}" \ + && if [ "${BUILD_ARCH}" = "aarch64" ]; then ARCH="arm64"; fi \ + \ + && curl -J -L -o /tmp/grafana.deb \ + "https://dl.grafana.com/oss/release/grafana_${GRAFANA_VERSION#v}_${ARCH}.deb" \ + \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + fonts-noto-cjk=1:20240730+repack1-1 \ + libfontconfig1=2.15.0-2.3 \ + memcached=1.6.38-1 \ + musl=1.2.5-3 \ + nginx=1.26.3-3+deb13u1 \ + \ + && dpkg --install /tmp/grafana.deb \ + \ + && if [ "${BUILD_ARCH}" = "amd64" ]; then \ + apt-get install -y --no-install-recommends \ + libasound2t64=1.2.14-1 \ + libcups2t64=2.4.10-3+deb13u1 \ + libdbus-1-3=1.16.2-2 \ + libdrm-amdgpu1=2.4.124-2 \ + libgbm1=25.0.7-2 \ + libglib2.0-0t64=2.84.4-3~deb13u1 \ + libgtk-4-1=4.18.6+ds-2 \ + libnss3=2:3.110-1 \ + libx11-6=2:1.8.12-1 \ + libx11-xcb1=2:1.8.12-1 \ + libxcb-dri3-0=1.17.0-2+b1 \ + libxcomposite1=1:0.4.6-1 \ + libxcursor1=1:1.2.3-1 \ + libxdamage1=1:1.1.6-1+b2 \ + libxext6=2:1.3.4-1+b3 \ + libxfixes3=1:6.0.0-2+b4 \ + libxi6=2:1.8.2-1 \ + libxrandr2=2:1.5.4-1+b3 \ + libxrender1=1:0.9.12-1 \ + libxshmfence1=1.3.3-1 \ + libxss1=1:1.2.3-1+b3 \ + libxtst6=2:1.2.5-1 \ + && grafana-cli plugins install "grafana-image-renderer" "${GRAFANA_IMAGE_RENDERER_VERSION#v}"; \ + fi \ + \ + && rm -fr \ + /tmp/* \ + /var/{cache,log}/* \ + /var/lib/apt/lists/* \ + /etc/nginx \ + \ + && mkdir -p /var/log/nginx \ + && touch /var/log/nginx/error.log + +# Copy root filesystem +COPY rootfs / + +# Health check +HEALTHCHECK \ + CMD curl --fail http://127.0.0.1:1337/api/health || exit 1 + +# Build arguments +ARG BUILD_ARCH +ARG BUILD_DATE +ARG BUILD_DESCRIPTION +ARG BUILD_NAME +ARG BUILD_REF +ARG BUILD_REPOSITORY +ARG BUILD_VERSION + +# Labels +LABEL \ + io.hass.name="${BUILD_NAME}" \ + io.hass.description="${BUILD_DESCRIPTION}" \ + io.hass.arch="${BUILD_ARCH}" \ + io.hass.type="addon" \ + io.hass.version=${BUILD_VERSION} \ + maintainer="Franck Nijhof " \ + io.hass.name="${BUILD_NAME}" \ + io.hass.description="${BUILD_DESCRIPTION}" \ + org.opencontainers.image.vendor="Home Assistant Community Add-ons" \ + org.opencontainers.image.authors="Franck Nijhof " \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.url="https://addons.community" \ + org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \ + org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \ + org.opencontainers.image.created=${BUILD_DATE} \ + org.opencontainers.image.revision=${BUILD_REF} \ + org.opencontainers.image.version=${BUILD_VERSION} diff --git a/grafana/build.yaml b/grafana/build.yaml new file mode 100644 index 0000000..e98db94 --- /dev/null +++ b/grafana/build.yaml @@ -0,0 +1,4 @@ +--- +build_from: + aarch64: ghcr.io/hassio-addons/debian-base/aarch64:9.1.0 + amd64: ghcr.io/hassio-addons/debian-base/amd64:9.1.0 diff --git a/grafana/config.yaml b/grafana/config.yaml new file mode 100644 index 0000000..957afd7 --- /dev/null +++ b/grafana/config.yaml @@ -0,0 +1,46 @@ +--- +name: Grafana +version: dev +slug: grafana +description: The open platform for beautiful analytics and monitoring +url: https://github.com/hassio-addons/addon-grafana +startup: services +ingress: true +ingress_port: 1337 +ingress_stream: true +init: false +panel_icon: mdi:chart-timeline +panel_title: Grafana +arch: + - aarch64 + - amd64 +map: + - homeassistant_config + - share + - ssl +options: + plugins: [] + custom_plugins: [] + env_vars: [] + ssl: true + certfile: fullchain.pem + keyfile: privkey.pem +ports: + 80/tcp: null +ports_description: + 80/tcp: Not required for Ingress +schema: + log_level: list(trace|debug|info|notice|warning|error|fatal)? + plugins: + - str + custom_plugins: + - name: str + url: str + unsigned: bool? + certfile: str + keyfile: str + ssl: bool + grafana_ingress_user: str? + env_vars: + - name: match(^GF_([A-Z0-9_])+$) + value: str diff --git a/grafana/icon.png b/grafana/icon.png new file mode 100644 index 0000000..e9dff3b Binary files /dev/null and b/grafana/icon.png differ diff --git a/grafana/logo.png b/grafana/logo.png new file mode 100644 index 0000000..081dfb3 Binary files /dev/null and b/grafana/logo.png differ diff --git a/grafana/rootfs/etc/grafana/grafana.ini b/grafana/rootfs/etc/grafana/grafana.ini new file mode 100644 index 0000000..3ec496d --- /dev/null +++ b/grafana/rootfs/etc/grafana/grafana.ini @@ -0,0 +1,332 @@ +##################### Grafana Configuration Defaults ##################### +# +# Do not modify this file in grafana installs +# + +# possible values : production, development +app_mode = production + +instance_name = Home Assistant + +#################################### Paths #################################### +[paths] +# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used) +# +data = /data +# +# Directory where grafana can store logs +# +logs = /var/logs/grafana +# +# Directory where grafana will automatically scan and look for plugins +# +plugins = /var/lib/grafana/plugins + +#################################### Plugins #################################### +[plugins] +allow_loading_unsigned_plugins = + +#################################### Server #################################### +[server] +# Protocol (http or https) +protocol = http + +# The ip address to bind to, empty will bind to all interfaces +http_addr = + +# The http port to use +http_port = 3000 + +# The public facing domain name used to access grafana from a browser +domain = localhost + +# Redirect to correct domain if host header does not match domain +# Prevents DNS rebinding attacks +enforce_domain = false + +# The full public facing url +root_url = %(protocol)s://%(domain)s:%(http_port)s%%ingress_entry%% + +# Log web requests +router_logging = false + +# the path relative working path +static_root_path = public + +# enable gzip +enable_gzip = true + +# https certs & key file +cert_file = false +cert_key = false + +#################################### Database #################################### +[database] +# Either "mysql", "postgres" or "sqlite3", it's your choice +type = sqlite3 +host = 127.0.0.1:3306 +name = grafana +user = root +password = + +# For "postgres", use either "disable", "require" or "verify-full" +# For "mysql", use either "true", "false", or "skip-verify". +ssl_mode = disable + +ca_cert_path = +client_key_path = +client_cert_path = +server_cert_name = + +# For "sqlite3" only, path relative to data_path setting +path = grafana.db + +################################# Remote Cache #################################### +[remote_cache] +type = memcached +connstr = 127.0.0.1:11211 + +#################################### Analytics #################################### +[analytics] +# Server reporting, sends usage counters to stats.grafana.org every 24 hours. +# No ip addresses are being tracked, only simple counters to track +# running instances, dashboard and error counts. It is very helpful to us. +# Change this option to false to disable reporting. +reporting_enabled = true + +# Set to false to disable all checks to https://grafana.net +# for new vesions (grafana itself and plugins), check is used +# in some UI views to notify that grafana or plugin update exists +# This option does not cause any auto updates, nor send any information +# only a GET request to http://grafana.net to get latest versions +check_for_updates = true + +# Google Analytics universal tracking code, only enabled if you specify an id here +google_analytics_ua_id = + +# Google Tag Manager ID, only enabled if you specify an id here +google_tag_manager_id = + +#################################### Security #################################### +[security] +# default admin user, created on startup +admin_user = admin + +# default admin password, can be changed before first start of grafana, or in profile settings +admin_password = hassio + +# used for signing +secret_key = SW2YcwTIb9zpOOhoPsMm + +# Auto-login remember days +login_remember_days = 7 +cookie_username = grafana_user +cookie_remember_name = grafana_remember + +# disable gravatar profile images +disable_gravatar = false + +# data source proxy whitelist (ip_or_domain:port seperated by spaces) +data_source_proxy_whitelist = + +# allow Grafana interface to be embeded, since this is done a lot +# with Home Assistant, this is on by default. +allow_embedding = true + +[snapshots] +# snapshot sharing options +external_enabled = true +external_snapshot_url = https://snapshots-origin.raintank.io +external_snapshot_name = Publish to snapshot.raintank.io + +#################################### Users #################################### +[users] +# disable user signup / registration +allow_sign_up = false + +# Allow non admin users to create organizations +allow_org_create = false + +# Set to true to automatically assign new users to the default organization (id 1) +auto_assign_org = true + +# Default role new users will be automatically assigned (if auto_assign_org above is set to true) +auto_assign_org_role = Admin + +# Require email validation before sign up completes +verify_email_enabled = false + +# Background text for the user field on the login page +login_hint = email or username + +#################################### Anonymous Auth ########################## +[auth.anonymous] +# enable anonymous access +enabled = false + +# specify organization name that should be used for unauthenticated users +org_name = Main Org. + +# specify role for unauthenticated users +org_role = Viewer + +#################################### Github Auth ########################## +[auth.github] +enabled = false +allow_sign_up = false +client_id = some_id +client_secret = some_secret +scopes = user:email +auth_url = https://github.com/login/oauth/authorize +token_url = https://github.com/login/oauth/access_token +api_url = https://api.github.com/user +team_ids = +allowed_organizations = + +#################################### Google Auth ########################## +[auth.google] +enabled = false +allow_sign_up = false +client_id = some_client_id +client_secret = some_client_secret +scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email +auth_url = https://accounts.google.com/o/oauth2/auth +token_url = https://accounts.google.com/o/oauth2/token +allowed_domains = + +#################################### Basic Auth ########################## +[auth.basic] +enabled = true + +#################################### Auth Proxy ########################## +[auth.proxy] +enabled = true +header_name = X-WEBAUTH-USER +header_property = username +auto_sign_up = true +whitelist = 127.0.0.1 + +#################################### Auth LDAP ########################## +[auth.ldap] +enabled = false +config_file = /etc/grafana/ldap.toml + +#################################### SMTP / Emailing ########################## +[smtp] +enabled = false +host = localhost:25 +user = +password = +cert_file = +key_file = +skip_verify = false +from_address = admin@grafana.localhost + +[emails] +welcome_email_on_sign_up = false +templates_pattern = emails/*.html + +#################################### Logging ########################## +[log] +# Either "console", "file", "syslog". Default is console and file +# Use comma to separate multiple modes, e.g. "console, file" +mode = console + +# Buffer length of channel, keep it as it is if you don't know what it is. +buffer_len = 10000 + +# Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Info" +level = Info + +# For "console" mode only +[log.console] +level = +# Set formatting to "false" to disable color formatting of console logs +formatting = false + +# For "file" mode only +[log.file] +level = +# This enables automated log rotate(switch of following options), default is true +log_rotate = true + +# Max line number of single file, default is 1000000 +max_lines = 1000000 + +# Max size shift of single file, default is 28 means 1 << 28, 256MB +max_lines_shift = 28 + +# Segment log daily, default is true +daily_rotate = true + +# Expired days of log file(delete after max days), default is 7 +max_days = 7 + +[log.syslog] +level = +# Syslog network type and address. This can be udp, tcp, or unix. If left blank, the default unix endpoints will be used. +network = +address = + +# Syslog facility. user, daemon and local0 through local7 are valid. +facility = + +# Syslog tag. By default, the process' argv[0] is used. +tag = + +#################################### AMPQ Event Publisher ########################## +[event_publisher] +enabled = false +rabbitmq_url = amqp://localhost/ +exchange = grafana_events + +#################################### Dashboard JSON files ########################## +[dashboards.json] +enabled = false +path = /var/lib/grafana/dashboards + +#################################### Usage Quotas ########################## +[quota] +enabled = false + +#### set quotas to -1 to make unlimited. #### +# limit number of users per Org. +org_user = 10 + +# limit number of dashboards per Org. +org_dashboard = 100 + +# limit number of data_sources per Org. +org_data_source = 10 + +# limit number of api_keys per Org. +org_api_key = 10 + +# limit number of orgs a user can create. +user_org = 10 + +# Global limit of users. +global_user = -1 + +# global limit of orgs. +global_org = -1 + +# global limit of dashboards +global_dashboard = -1 + +# global limit of api_keys +global_api_key = -1 + +# global limit on number of logged in users. +global_session = -1 + +#################################### Grafana Live ########################## +[live] +max_connections = 0 + +#################################### Alerting ########################## +[unified_alerting] +enabled = true + +[alerting] +enabled = false diff --git a/grafana/rootfs/etc/nginx/includes/mime.types b/grafana/rootfs/etc/nginx/includes/mime.types new file mode 100644 index 0000000..7c7cdef --- /dev/null +++ b/grafana/rootfs/etc/nginx/includes/mime.types @@ -0,0 +1,96 @@ +types { + text/html html htm shtml; + text/css css; + text/xml xml; + image/gif gif; + image/jpeg jpeg jpg; + application/javascript js; + application/atom+xml atom; + application/rss+xml rss; + + text/mathml mml; + text/plain txt; + text/vnd.sun.j2me.app-descriptor jad; + text/vnd.wap.wml wml; + text/x-component htc; + + image/png png; + image/svg+xml svg svgz; + image/tiff tif tiff; + image/vnd.wap.wbmp wbmp; + image/webp webp; + image/x-icon ico; + image/x-jng jng; + image/x-ms-bmp bmp; + + font/woff woff; + font/woff2 woff2; + + application/java-archive jar war ear; + application/json json; + application/mac-binhex40 hqx; + application/msword doc; + application/pdf pdf; + application/postscript ps eps ai; + application/rtf rtf; + application/vnd.apple.mpegurl m3u8; + application/vnd.google-earth.kml+xml kml; + application/vnd.google-earth.kmz kmz; + application/vnd.ms-excel xls; + application/vnd.ms-fontobject eot; + application/vnd.ms-powerpoint ppt; + application/vnd.oasis.opendocument.graphics odg; + application/vnd.oasis.opendocument.presentation odp; + application/vnd.oasis.opendocument.spreadsheet ods; + application/vnd.oasis.opendocument.text odt; + application/vnd.openxmlformats-officedocument.presentationml.presentation + pptx; + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet + xlsx; + application/vnd.openxmlformats-officedocument.wordprocessingml.document + docx; + application/vnd.wap.wmlc wmlc; + application/x-7z-compressed 7z; + application/x-cocoa cco; + application/x-java-archive-diff jardiff; + application/x-java-jnlp-file jnlp; + application/x-makeself run; + application/x-perl pl pm; + application/x-pilot prc pdb; + application/x-rar-compressed rar; + application/x-redhat-package-manager rpm; + application/x-sea sea; + application/x-shockwave-flash swf; + application/x-stuffit sit; + application/x-tcl tcl tk; + application/x-x509-ca-cert der pem crt; + application/x-xpinstall xpi; + application/xhtml+xml xhtml; + application/xspf+xml xspf; + application/zip zip; + + application/octet-stream bin exe dll; + application/octet-stream deb; + application/octet-stream dmg; + application/octet-stream iso img; + application/octet-stream msi msp msm; + + audio/midi mid midi kar; + audio/mpeg mp3; + audio/ogg ogg; + audio/x-m4a m4a; + audio/x-realaudio ra; + + video/3gpp 3gpp 3gp; + video/mp2t ts; + video/mp4 mp4; + video/mpeg mpeg mpg; + video/quicktime mov; + video/webm webm; + video/x-flv flv; + video/x-m4v m4v; + video/x-mng mng; + video/x-ms-asf asx asf; + video/x-ms-wmv wmv; + video/x-msvideo avi; +} diff --git a/grafana/rootfs/etc/nginx/includes/proxy_params.conf b/grafana/rootfs/etc/nginx/includes/proxy_params.conf new file mode 100644 index 0000000..5641e3c --- /dev/null +++ b/grafana/rootfs/etc/nginx/includes/proxy_params.conf @@ -0,0 +1,16 @@ +proxy_http_version 1.1; +proxy_ignore_client_abort off; +proxy_read_timeout 86400s; +proxy_redirect off; +proxy_send_timeout 86400s; +proxy_max_temp_file_size 0; + +proxy_set_header Accept-Encoding ""; +proxy_set_header Connection $connection_upgrade; +proxy_set_header Host $http_host; +proxy_set_header Upgrade $http_upgrade; +proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; +proxy_set_header X-Forwarded-Proto $scheme; +proxy_set_header X-NginX-Proxy true; +proxy_set_header X-Real-IP $remote_addr; +proxy_set_header X-WEBAUTH-USER ""; diff --git a/grafana/rootfs/etc/nginx/includes/server_params.conf b/grafana/rootfs/etc/nginx/includes/server_params.conf new file mode 100644 index 0000000..09c0654 --- /dev/null +++ b/grafana/rootfs/etc/nginx/includes/server_params.conf @@ -0,0 +1,6 @@ +root /dev/null; +server_name $hostname; + +add_header X-Content-Type-Options nosniff; +add_header X-XSS-Protection "1; mode=block"; +add_header X-Robots-Tag none; diff --git a/grafana/rootfs/etc/nginx/includes/ssl_params.conf b/grafana/rootfs/etc/nginx/includes/ssl_params.conf new file mode 100644 index 0000000..e6789cb --- /dev/null +++ b/grafana/rootfs/etc/nginx/includes/ssl_params.conf @@ -0,0 +1,8 @@ +ssl_protocols TLSv1.2 TLSv1.3; +ssl_prefer_server_ciphers off; +ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; +ssl_session_timeout 10m; +ssl_session_cache shared:SSL:10m; +ssl_session_tickets off; +ssl_stapling on; +ssl_stapling_verify on; diff --git a/grafana/rootfs/etc/nginx/includes/upstream.conf b/grafana/rootfs/etc/nginx/includes/upstream.conf new file mode 100644 index 0000000..e98b0e6 --- /dev/null +++ b/grafana/rootfs/etc/nginx/includes/upstream.conf @@ -0,0 +1,3 @@ +upstream backend { + server 127.0.0.1:3000; +} diff --git a/grafana/rootfs/etc/nginx/nginx.conf b/grafana/rootfs/etc/nginx/nginx.conf new file mode 100644 index 0000000..886e407 --- /dev/null +++ b/grafana/rootfs/etc/nginx/nginx.conf @@ -0,0 +1,48 @@ +# Run nginx in foreground. +daemon off; + +# This is run inside Docker. +user root; + +# Pid storage location. +pid /var/run/nginx.pid; + +# Set number of worker processes. +worker_processes 1; + +# Enables the use of JIT for regular expressions to speed-up their processing. +pcre_jit on; + +# Write error log to the add-on log. +error_log /proc/1/fd/1 error; + +# Load dynamic modules. +include /etc/nginx/modules/*.conf; + +# Max num of simultaneous connections by a worker process. +events { + worker_connections 512; +} + +http { + include /etc/nginx/includes/mime.types; + + access_log off; + client_max_body_size 4G; + default_type application/octet-stream; + gzip on; + keepalive_timeout 65; + sendfile on; + server_tokens off; + tcp_nodelay on; + tcp_nopush on; + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + include /etc/nginx/includes/upstream.conf; + + include /etc/nginx/servers/*.conf; +} diff --git a/grafana/rootfs/etc/nginx/servers/direct-ssl.disabled b/grafana/rootfs/etc/nginx/servers/direct-ssl.disabled new file mode 100644 index 0000000..8bbcce8 --- /dev/null +++ b/grafana/rootfs/etc/nginx/servers/direct-ssl.disabled @@ -0,0 +1,20 @@ +server { + listen 80 default_server ssl; + + include /etc/nginx/includes/server_params.conf; + include /etc/nginx/includes/ssl_params.conf; + include /etc/nginx/includes/proxy_params.conf; + + ssl_certificate /ssl/%%certfile%%; + ssl_certificate_key /ssl/%%keyfile%%; + + location / { + return 302 $scheme://$http_host%%ingress_entry%%/; + } + location %%ingress_entry%% { + rewrite ^%%ingress_entry%%/(.*) /$1 break; + proxy_set_header X-WEBAUTH-USER ""; + proxy_pass http://backend/; + } + +} diff --git a/grafana/rootfs/etc/nginx/servers/direct.disabled b/grafana/rootfs/etc/nginx/servers/direct.disabled new file mode 100644 index 0000000..768c895 --- /dev/null +++ b/grafana/rootfs/etc/nginx/servers/direct.disabled @@ -0,0 +1,15 @@ +server { + listen 80 default_server; + + include /etc/nginx/includes/server_params.conf; + include /etc/nginx/includes/proxy_params.conf; + + location / { + return 302 $scheme://$http_host%%ingress_entry%%/; + } + location %%ingress_entry%% { + rewrite ^%%ingress_entry%%/(.*) /$1 break; + proxy_set_header X-WEBAUTH-USER ""; + proxy_pass http://backend/; + } +} diff --git a/grafana/rootfs/etc/nginx/servers/ingress.conf b/grafana/rootfs/etc/nginx/servers/ingress.conf new file mode 100644 index 0000000..404c587 --- /dev/null +++ b/grafana/rootfs/etc/nginx/servers/ingress.conf @@ -0,0 +1,14 @@ +server { + listen 1337 default_server; + + include /etc/nginx/includes/server_params.conf; + include /etc/nginx/includes/proxy_params.conf; + + location / { + allow 127.0.0.1; + allow 172.30.32.2; + deny all; + proxy_set_header X-WEBAUTH-USER %%grafana_user%%; + proxy_pass http://backend; + } +} \ No newline at end of file diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/grafana/dependencies.d/init-grafana b/grafana/rootfs/etc/s6-overlay/s6-rc.d/grafana/dependencies.d/init-grafana new file mode 100644 index 0000000..e69de29 diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/grafana/dependencies.d/memcached b/grafana/rootfs/etc/s6-overlay/s6-rc.d/grafana/dependencies.d/memcached new file mode 100644 index 0000000..e69de29 diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/grafana/finish b/grafana/rootfs/etc/s6-overlay/s6-rc.d/grafana/finish new file mode 100755 index 0000000..4a0cabd --- /dev/null +++ b/grafana/rootfs/etc/s6-overlay/s6-rc.d/grafana/finish @@ -0,0 +1,27 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== +# Home Assistant Community Add-on: Grafana +# Take down the S6 supervision tree when Grafana fails +# ============================================================================== +declare exit_code +readonly exit_code_container=$( /run/s6-linux-init-container-results/exitcode + fi + [[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt +elif [[ "${exit_code_service}" -ne 0 ]]; then + if [[ "${exit_code_container}" -eq 0 ]]; then + echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode + fi + exec /run/s6/basedir/bin/halt +fi diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/grafana/run b/grafana/rootfs/etc/s6-overlay/s6-rc.d/grafana/run new file mode 100755 index 0000000..120e87b --- /dev/null +++ b/grafana/rootfs/etc/s6-overlay/s6-rc.d/grafana/run @@ -0,0 +1,41 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== +# Home Assistant Community Add-on: Grafana +# Runs the Grafana Server +# ============================================================================== +declare -a options +declare -a unsigned_plugins +declare name +declare value + +# Wait for Memcached to become available +bashio::net.wait_for 11211 + +bashio::log.info 'Starting Grafana...' + +options+=(--config="/etc/grafana/grafana.ini") +options+=(--homepath="/usr/share/grafana") + +# Load custom environment variables +for var in $(bashio::config 'env_vars|keys'); do + name=$(bashio::config "env_vars[${var}].name") + value=$(bashio::config "env_vars[${var}].value") + bashio::log.info "Setting ${name} to ${value}" + export "${name}=${value}" +done + +# Verify if we have unsigned custom plugins to load +if bashio::config.has_value 'custom_plugins'; then + for plugin in $(bashio::config 'custom_plugins|keys'); do + name=$(bashio::config "custom_plugins[${plugin}].name") + if bashio::config.true "custom_plugins[${plugin}].unsigned"; then + unsigned_plugins+="${name}," + fi + done + export "GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=${unsigned_plugins}" +fi + + +# Run Grafana +exec grafana-server "${options[@]}" diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/grafana/type b/grafana/rootfs/etc/s6-overlay/s6-rc.d/grafana/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/grafana/rootfs/etc/s6-overlay/s6-rc.d/grafana/type @@ -0,0 +1 @@ +longrun diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/init-grafana/dependencies.d/base b/grafana/rootfs/etc/s6-overlay/s6-rc.d/init-grafana/dependencies.d/base new file mode 100644 index 0000000..e69de29 diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/init-grafana/run b/grafana/rootfs/etc/s6-overlay/s6-rc.d/init-grafana/run new file mode 100755 index 0000000..97799c5 --- /dev/null +++ b/grafana/rootfs/etc/s6-overlay/s6-rc.d/init-grafana/run @@ -0,0 +1,69 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== +# Home Assistant Community Add-on: Grafana +# Configures Grafana +# ============================================================================== +readonly CONFIG="/etc/grafana/grafana.ini" +declare ingress_entry +declare log_level + +# Symlink the new style config directory to the old one. People might have +# configurations for Grafana that access the database via the old path. +ln -s "/homeassistant" "/config" \ + || bashio::log.warning "Failed linking Home Assistant configuration alias" + +# Configures Grafana with the add-on log level +log_level="Info" +if bashio::config.exists 'log_level'; then + case "$(bashio::string.lower "$(bashio::config 'log_level')")" in + all|trace) + log_level="Trace" + ;; + debug) + log_level="Debug" + ;; + info|notice) + log_level="Info" + ;; + warning) + log_level="Warn" + ;; + error) + log_level="Error" + ;; + fatal|off) + log_level="Critical" + ;; + esac +fi +sed -i "s/level = Info/level = ${log_level}/g" "${CONFIG}" + +# Sets unique secret key used for signing cookies. +if ! bashio::fs.file_exists "/data/secret"; then + echo "${SUPERVISOR_TOKEN}" > /data/secret +fi +secret=$( /run/s6-linux-init-container-results/exitcode + fi + [[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt +elif [[ "${exit_code_service}" -ne 0 ]]; then + if [[ "${exit_code_container}" -eq 0 ]]; then + echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode + fi + exec /run/s6/basedir/bin/halt +fi diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/memcached/run b/grafana/rootfs/etc/s6-overlay/s6-rc.d/memcached/run new file mode 100755 index 0000000..8c4cd5f --- /dev/null +++ b/grafana/rootfs/etc/s6-overlay/s6-rc.d/memcached/run @@ -0,0 +1,15 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== +# Home Assistant Community Add-on: Grafana +# Runs the memcached Server +# ============================================================================== +declare -a options + +bashio::log.info 'Starting Memcached...' + +options+=(-l 127.0.0.1) +options+=(-m 32) + +# Run Memcached +exec s6-setuidgid memcache /usr/bin/memcached "${options[@]}" diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/memcached/type b/grafana/rootfs/etc/s6-overlay/s6-rc.d/memcached/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/grafana/rootfs/etc/s6-overlay/s6-rc.d/memcached/type @@ -0,0 +1 @@ +longrun diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/nginx/dependencies.d/grafana b/grafana/rootfs/etc/s6-overlay/s6-rc.d/nginx/dependencies.d/grafana new file mode 100644 index 0000000..e69de29 diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/nginx/dependencies.d/init-nginx b/grafana/rootfs/etc/s6-overlay/s6-rc.d/nginx/dependencies.d/init-nginx new file mode 100644 index 0000000..e69de29 diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish b/grafana/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish new file mode 100755 index 0000000..88e2175 --- /dev/null +++ b/grafana/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish @@ -0,0 +1,26 @@ +#!/command/with-contenv bashio +# ============================================================================== +# Home Assistant Community Add-on: grafana +# Take down the S6 supervision tree when NGINX fails +# ============================================================================== +declare exit_code +readonly exit_code_container=$( /run/s6-linux-init-container-results/exitcode + fi + [[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt +elif [[ "${exit_code_service}" -ne 0 ]]; then + if [[ "${exit_code_container}" -eq 0 ]]; then + echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode + fi + exec /run/s6/basedir/bin/halt +fi diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/nginx/run b/grafana/rootfs/etc/s6-overlay/s6-rc.d/nginx/run new file mode 100755 index 0000000..f4780ea --- /dev/null +++ b/grafana/rootfs/etc/s6-overlay/s6-rc.d/nginx/run @@ -0,0 +1,12 @@ +#!/command/with-contenv bashio +# ============================================================================== +# Home Assistant Community Add-on: grafana +# Runs the Nginx daemon +# ============================================================================== + +# Wait for grafana to become available +bashio::net.wait_for 3000 + +bashio::log.info "Starting NGINX..." + +exec nginx diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/nginx/type b/grafana/rootfs/etc/s6-overlay/s6-rc.d/nginx/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/grafana/rootfs/etc/s6-overlay/s6-rc.d/nginx/type @@ -0,0 +1 @@ +longrun diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/grafana b/grafana/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/grafana new file mode 100644 index 0000000..e69de29 diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-grafana b/grafana/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-grafana new file mode 100644 index 0000000..e69de29 diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-nginx b/grafana/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-nginx new file mode 100644 index 0000000..e69de29 diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/memcached b/grafana/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/memcached new file mode 100644 index 0000000..e69de29 diff --git a/grafana/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/nginx b/grafana/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/nginx new file mode 100644 index 0000000..e69de29 diff --git a/images/screenshot.png b/images/screenshot.png new file mode 100644 index 0000000..1a09cb3 Binary files /dev/null and b/images/screenshot.png differ