From 0f768da93035c63e9e16f0dc1a200b5b8c6e5812 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Fri, 10 Jun 2022 16:27:25 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8Rewrite=20of=20add-on=20(#214)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ⬆️ Upgrades add-on base image to 12.0.0 * :hammer: Rewrite add-on * :books: Docs adjustments * Tweak * Remove now obsolete pyopenssl * :lock: Sign add-on with Codenotary Community Attestation Service (CAS) * Add build deps --- .github/workflows/deploy.yaml | 1 + LICENSE.md | 3 +- README.md | 6 +- tautulli/DOCS.md | 72 +++---------------- tautulli/Dockerfile | 52 +++++++------- tautulli/build.yaml | 13 ++-- tautulli/config.yaml | 16 +---- tautulli/requirements.txt | 4 +- tautulli/rootfs/etc/cont-init.d/tautulli.sh | 56 ++------------- .../rootfs/etc/services.d/tautulli/finish | 10 +-- tautulli/rootfs/etc/services.d/tautulli/run | 2 +- tautulli/rootfs/patches/support | 17 ----- 12 files changed, 68 insertions(+), 184 deletions(-) mode change 100644 => 100755 tautulli/rootfs/etc/cont-init.d/tautulli.sh mode change 100644 => 100755 tautulli/rootfs/etc/services.d/tautulli/finish mode change 100644 => 100755 tautulli/rootfs/etc/services.d/tautulli/run delete mode 100644 tautulli/rootfs/patches/support diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 21b20da..9b224a5 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -16,4 +16,5 @@ jobs: workflows: uses: hassio-addons/workflows/.github/workflows/addon-deploy.yaml@main secrets: + CAS_API_KEY: ${{ secrets.CAS_API_KEY }} DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }} diff --git a/LICENSE.md b/LICENSE.md index 909924b..c0aec85 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,7 @@ # MIT License -Copyright (c) 2018-2021 Joakim Sørensen +Copyright (c) 2018-2019 Joakim Sørensen +Copyright (c) 2019-2022 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 diff --git a/README.md b/README.md index 6e68908..7e0b383 100644 --- a/README.md +++ b/README.md @@ -76,8 +76,8 @@ our [GitHub Repository][repository]. MIT License -Copyright (c) 2018-2019 Joakim Sørensen -Copyright (c) 2019-2022 Franck Nijhof +- Copyright (c) 2018-2019 Joakim Sørensen +- Copyright (c) 2019-2022 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 @@ -116,7 +116,7 @@ SOFTWARE. [issue]: https://github.com/hassio-addons/addon-tautulli/issues [license-shield]: https://img.shields.io/github/license/hassio-addons/addon-tautulli.svg [ludeeus]: https://github.com/ludeeus -[maintenance-shield]: https://img.shields.io/maintenance/yes/2021.svg +[maintenance-shield]: https://img.shields.io/maintenance/yes/2022.svg [project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg [reddit]: https://reddit.com/r/homeassistant [releases-shield]: https://img.shields.io/github/release/hassio-addons/addon-tautulli.svg diff --git a/tautulli/DOCS.md b/tautulli/DOCS.md index bf1e487..0d85e3a 100644 --- a/tautulli/DOCS.md +++ b/tautulli/DOCS.md @@ -13,8 +13,12 @@ which makes it easy to brag about your server to everyone else. The installation of this add-on is pretty straightforward and not different in comparison to installing any other Home Assistant add-on. -1. Search for the "Tautulli" add-on in the Supervisor add-on store - and install it. +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 "Tautulli" add-on 1. Check the logs of the "Tautulli" add-on to see if everything went well. 1. Click "OPEN WEB UI" to open the Tautulli website and follow the wizard. @@ -30,15 +34,8 @@ Example add-on configuration: ```yaml log_level: info -username: MarryPoppins -password: Supercalifragilisticexpialidocious -ssl: true -certfile: fullchain.pem -keyfile: privkey.pem ``` -**Note**: _This is just an example, don't copy and past it! Create your own!_ - ### Option: `log_level` The `log_level` option controls the level of log output by the addon and can @@ -57,46 +54,6 @@ 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: `username` - -Username for authenticating with the Tautulli interface. - -Setting a username/password can be added as an extra line of defense, -to prevent users from using your installation for themselves. - -This option is HIGHLY recommended in case you expose this add-on to the outside -world. - -### Option: `password` - -Password for authenticating with Tautulli interface. - -### Option: `ssl` - -Enables/Disables SSL (HTTPS) on the web interface of Tautulli. Set it `true` -to enable it, `false` otherwise. - -### Option: `certfile` - -The certificate file to use for SSL. - -**Note**: _The file MUST be stored in `/ssl/`, which is the default_ - -### Option: `keyfile` - -The private key file to use for SSL. - -**Note**: _The file MUST be stored in `/ssl/`, which is the default_ - -### Option: `leave_front_door_open` - -Adding this option to the add-on configuration allows you to disable -authentication on the add-on by setting it to `true` and leaving the -username and password empty. - -**Note**: _We STRONGLY suggest, not to use this, even if this add-on is -only exposed to your internal network. USE AT YOUR OWN RISK!_ - ## Embedding into Home Assistant It is possible to embed Tautulli directly into Home Assistant, allowing you to @@ -114,17 +71,6 @@ panel_iframe: url: http://addres.to.your.home.assistant:8181 ``` -## Use an existing database - -**NB!: This is considered advanced usage.** - -If you want to import an existing Tautulli database to this addon, you first -need to extract the `tautulli.db` file from your existing installation. -Place this file in this directory `/share/tautulli`, you can use samba, -Cloud9 or any other method to move it there. -You need to restart the add-on for it to start using this database. -_if the directory `/share/tautulli` does not exist you need to create it._ - ## Changelog & Releases This repository keeps a change log using [GitHub's releases][releases] @@ -164,8 +110,8 @@ check [the contributor's page][contributors]. MIT License -Copyright (c) 2018-2019 Joakim Sørensen -Copyright (c) 2019-2022 Franck Nijhof +- Copyright (c) 2018-2019 Joakim Sørensen +- Copyright (c) 2019-2022 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 @@ -185,6 +131,8 @@ 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_tautulli&repository_url=https%3A%2F%2Fgithub.com%2Fhassio-addons%2Frepository [contributors]: https://github.com/hassio-addons/addon-tautulli/graphs/contributors [discord-ha]: https://discord.gg/c5DvZ4e [discord]: https://discord.me/hassioaddons diff --git a/tautulli/Dockerfile b/tautulli/Dockerfile index b50c546..d47d93a 100644 --- a/tautulli/Dockerfile +++ b/tautulli/Dockerfile @@ -1,4 +1,4 @@ -ARG BUILD_FROM=ghcr.io/hassio-addons/base/amd64:11.0.0 +ARG BUILD_FROM=ghcr.io/hassio-addons/debian-base/amd64:6.0.0 # hadolint ignore=DL3006 FROM ${BUILD_FROM} @@ -17,39 +17,39 @@ COPY requirements.txt /tmp/ # Setup base ARG BUILD_ARCH=amd64 RUN \ - apk add --no-cache --virtual .build-dependencies \ - g++=10.3.1_git20211027-r0 \ - gcc=10.3.1_git20211027-r0 \ - libffi-dev=3.4.2-r1 \ - openssl-dev=1.1.1l-r7 \ - make=4.3-r0 \ - python3-dev=3.9.7-r4 \ - \ - && apk add --no-cache \ - git=2.34.1-r0 \ - openssl=1.1.1l-r7 \ - patch=2.7.6-r7 \ - py3-cryptography=3.3.2-r3 \ - py3-pip=20.3.4-r1 \ - python3=3.9.7-r4 \ - wget=1.21.2-r2 \ + apt-get update \ + && apt-get install -y --no-install-recommends \ + build-essential=12.9 \ + git=1:2.30.2-1 \ + python3-dev=3.9.2-3 \ + python3-pip=20.3.4-4+deb11u1 \ + python3=3.9.2-3\ \ && pip install \ - --no-cache-dir \ - --prefer-binary \ - --find-links "https://wheels.home-assistant.io/alpine-3.15/${BUILD_ARCH}/" \ - -r /tmp/requirements.txt \ + --no-cache-dir \ + --prefer-binary \ + --extra-index-url "https://www.piwheels.org/simple" \ + -r /tmp/requirements.txt \ \ && git clone --branch "${TAUTULLI_VERSION}" --depth=1 \ https://github.com/Tautulli/Tautulli.git /opt \ \ && find /usr/local \ - \( -type d -a -name test -o -name tests -o -name '__pycache__' \) \ - -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ - -exec rm -rf '{}' + \ + \( -type d -a -name test -o -name tests -o -name '__pycache__' \) \ + -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ + -exec rm -rf '{}' + \ \ - && apk del --no-cache --purge .build-dependencies \ - && rm -f -r /tmp/* + && apt-get purge -y --auto-remove \ + build-essential \ + git \ + python3-dev \ + python3-pip \ + \ + && rm -fr \ + /opt/{.git,.github,init-scripts} \ + /tmp/* \ + /var/{cache,log}/* \ + /var/lib/apt/lists/* # Copy root filesystem COPY rootfs / diff --git a/tautulli/build.yaml b/tautulli/build.yaml index ef8af69..0475c14 100644 --- a/tautulli/build.yaml +++ b/tautulli/build.yaml @@ -1,7 +1,10 @@ --- build_from: - aarch64: ghcr.io/hassio-addons/base/aarch64:11.0.0 - amd64: ghcr.io/hassio-addons/base/amd64:11.0.0 - armhf: ghcr.io/hassio-addons/base/armhf:11.0.0 - armv7: ghcr.io/hassio-addons/base/armv7:11.0.0 - i386: ghcr.io/hassio-addons/base/i386:11.0.0 + aarch64: ghcr.io/hassio-addons/debian-base/aarch64:6.0.0 + amd64: ghcr.io/hassio-addons/debian-base/amd64:6.0.0 + armhf: ghcr.io/hassio-addons/debian-base/armhf:6.0.0 + armv7: ghcr.io/hassio-addons/debian-base/armv7:6.0.0 + i386: ghcr.io/hassio-addons/debian-base/i386:6.0.0 +codenotary: + base_image: codenotary@frenck.dev + signer: codenotary@frenck.dev diff --git a/tautulli/config.yaml b/tautulli/config.yaml index 43f42e6..80952b8 100644 --- a/tautulli/config.yaml +++ b/tautulli/config.yaml @@ -4,6 +4,7 @@ version: dev slug: tautulli description: Monitoring and tracking tool for Plex Media Server url: https://github.com/hassio-addons/addon-tautulli/tree/main/README.md +codenotary: codenotary@frenck.dev webui: "[PROTO:ssl]://[HOST]:[PORT:8181]" arch: - aarch64 @@ -11,25 +12,14 @@ arch: - armhf - armv7 - i386 +init: false hassio_api: true ports: 8181/tcp: 8181 ports_description: 8181/tcp: Tautulli web interface map: - - ssl - share:rw -options: - username: "" - password: "" - ssl: true - certfile: fullchain.pem - keyfile: privkey.pem + - backup:rw schema: log_level: list(trace|debug|info|notice|warning|error|fatal)? - username: str - password: password - ssl: bool - certfile: str - keyfile: str - leave_front_door_open: bool? diff --git a/tautulli/requirements.txt b/tautulli/requirements.txt index 585e7f9..90c2cb6 100644 --- a/tautulli/requirements.txt +++ b/tautulli/requirements.txt @@ -1,4 +1,4 @@ +crudini==0.9.3 plexapi==4.11.2 pycryptodomex==3.14.1 -crudini==0.9.3 -pyOpenSSL==22.0.0 +setuptools==62.3.3 diff --git a/tautulli/rootfs/etc/cont-init.d/tautulli.sh b/tautulli/rootfs/etc/cont-init.d/tautulli.sh old mode 100644 new mode 100755 index 96e4ca7..3911eee --- a/tautulli/rootfs/etc/cont-init.d/tautulli.sh +++ b/tautulli/rootfs/etc/cont-init.d/tautulli.sh @@ -1,18 +1,10 @@ -#!/usr/bin/with-contenv bashio +#!/command/with-contenv bashio # ============================================================================== # Home Assistant Community Add-on: Tautulli # Preparing configuration for Tautulli # ============================================================================== readonly ADDON=/data/addon.ini readonly CONFIG=/data/config.ini -readonly DATABASE=/share/tautulli/tautulli.db -readonly SHARE=/share/tautulli - -# Require username / password -if ! bashio::config.true 'leave_front_door_open'; then - bashio::config.require.username; - bashio::config.require.password; -fi # Check SSL cerrificate bashio::config.require.ssl @@ -20,12 +12,16 @@ bashio::config.require.ssl # If config.ini does not exist, create it. if ! bashio::fs.file_exists "$CONFIG"; then bashio::log.info "Creating default configuration..." + crudini --set "$CONFIG" Advanced system_analytics 0 + crudini --set "$CONFIG" General backup_dir "/backup/tautulli" crudini --set "$CONFIG" General first_run_complete 0 crudini --set "$CONFIG" General update_show_changelog 0 - crudini --set "$CONFIG" Advanced system_analytics 0 crudini --set "$ADDON" Addon version "$TAUTULLI_VERSION" fi +# Create backup directory +mkdir -p /backup/tautulli + bashio::log.info "Updating running configuration..." # Temporrary changing config.ini to be valid during additions @@ -50,46 +46,6 @@ crudini --set "$ADDON" Addon version "$TAUTULLI_VERSION" crudini --set "$CONFIG" General check_github 0 crudini --set "$CONFIG" General check_github_on_startup 0 -# Update SSL info in configuration -if bashio::config.true 'ssl'; then - bashio::log.info "Ensure SSL is active in the configuration..." - crudini --set "$CONFIG" General enable_https 1 - crudini --set "$CONFIG" General https_cert_chain "\"/ssl/$(bashio::config 'certfile')\"" - crudini --set "$CONFIG" General https_cert "\"/ssl/$(bashio::config 'certfile')\"" - crudini --set "$CONFIG" General https_key "\"/ssl/$(bashio::config 'keyfile')\"" -else - bashio::log.info "Ensure SSL is not active in the configuration..." - crudini --set "$CONFIG" General enable_https 0 - crudini --set "$CONFIG" General https_cert_chain "\"\"" - crudini --set "$CONFIG" General https_cert "\"\"" - crudini --set "$CONFIG" General https_key "\"\"" -fi - -# Update username and password in configuration -if bashio::config.has_value 'username' && bashio::config.has_value 'password'; then - bashio::log.info "Ensure authentication is enabled in the configuration..." - crudini --set "$CONFIG" General http_username "\"$(bashio::config 'username')\"" - crudini --set "$CONFIG" General http_password "\"$(bashio::config 'password')\"" -else - bashio::log.info "Ensure authentication is not enabled in the configuration..." - crudini --set "$CONFIG" General http_username "\"\"" - crudini --set "$CONFIG" General http_password "\"\"" -fi - # Changing config.ini back. ## This has to be done because Tautulli added a ini header with [[header]] sed -i "s/\\[get_file_sizes_hold\\]/\\[\\[get_file_sizes_hold\\]\\]/" "$CONFIG" - -# Create /share/tautulli if it does not exist. -if ! bashio::fs.directory_exists "$SHARE"; then - mkdir "$SHARE" -fi - -# Use databasefile from /share/tautulli if it exist. -if bashio::fs.file_exists "$DATABASE"; then - bashio::log.info "Using database from $DATABASE" - ln -sf "$DATABASE" /data/tautulli.db -fi - -# Adds add-on support information in the settings of Tautulli -patch /opt/data/interfaces/default/configuration_table.html /patches/support diff --git a/tautulli/rootfs/etc/services.d/tautulli/finish b/tautulli/rootfs/etc/services.d/tautulli/finish old mode 100644 new mode 100755 index 5ae950a..5763845 --- a/tautulli/rootfs/etc/services.d/tautulli/finish +++ b/tautulli/rootfs/etc/services.d/tautulli/finish @@ -1,9 +1,11 @@ -#!/usr/bin/execlineb -S0 +#!/command/with-contenv bashio # ============================================================================== # Home Assistant Community Add-on: Tautulli # Take down the S6 supervision tree when Tautulli fails # ============================================================================== -if -n { s6-test $# -ne 0 } -if -n { s6-test ${1} -eq 256 } +if [[ "${1}" -ne 0 ]] && [[ "${1}" -ne 256 ]]; then + bashio::log.warning "Tautulli crashed, halting add-on" + /run/s6/basedir/bin/halt +fi -s6-svscanctl -t /var/run/s6/services +bashio::log.info "Tautulli stopped, restarting..." diff --git a/tautulli/rootfs/etc/services.d/tautulli/run b/tautulli/rootfs/etc/services.d/tautulli/run old mode 100644 new mode 100755 index ac57170..5a37722 --- a/tautulli/rootfs/etc/services.d/tautulli/run +++ b/tautulli/rootfs/etc/services.d/tautulli/run @@ -1,4 +1,4 @@ -#!/usr/bin/with-contenv bashio +#!/command/with-contenv bashio # ============================================================================== # Home Assistant Community Add-on: Tautulli # Runs Tautulli diff --git a/tautulli/rootfs/patches/support b/tautulli/rootfs/patches/support deleted file mode 100644 index 758a588..0000000 --- a/tautulli/rootfs/patches/support +++ /dev/null @@ -1,17 +0,0 @@ ---- /opt/data/interfaces/default/configuration_table.html -+++ /opt/data/interfaces/default/configuration_table.html -@@ -93,6 +79,14 @@ - Plex Forums - - -+ -+ Add-on Support: -+ -+ Home Assistant Community Add-ons Discord Server | -+ GitHub issues for this add-on | -+ Home Assistant forum -+ -+ - - -