diff --git a/plex_meta_manager/CHANGELOG.md b/plex_meta_manager/CHANGELOG.md new file mode 100644 index 000000000..68dde260e --- /dev/null +++ b/plex_meta_manager/CHANGELOG.md @@ -0,0 +1 @@ +- Initial build diff --git a/plex_meta_manager/Dockerfile b/plex_meta_manager/Dockerfile new file mode 100644 index 000000000..d57eec952 --- /dev/null +++ b/plex_meta_manager/Dockerfile @@ -0,0 +1,108 @@ +#============================# +# ALEXBELGIUM'S DOCKERFILE # +#============================# +# _.------. +# _.-` ('>.-`"""-. +# '.--'` _'` _ .--.) +# -' '-.-';` ` +# ' - _.' ``'--. +# '---` .-'""` +# /` +#=== Home Assistant Addon ===# + +################# +# 1 Build Image # +################# + +ARG BUILD_FROM +ARG BUILD_VERSION +FROM ${BUILD_FROM} + +################## +# 2 Modify Image # +################## + +ENV HOME=/config/addons_config/plex-data-manager + +RUN \ + # use /data instead of /config for hass.io environment + sed -i "s|/config|/config/addons_config/plex-meta-manager|g" /etc/services.d/*/run \ + && sed -i "s|/config|/config/addons_config/plex-meta-manager|g" /etc/cont-init.d/* \ + \ + # Allow UID and GID setting + && sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ + && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ + && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser \ + \ + # Add template config.yaml + && mkdir /templates \ + && curl -L -f -s -S "https://github.com/meisnate12/Plex-Meta-Manager/blob/master/config/config.yml.template" -o /templates/config.yaml + + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Modules +ARG MODULES="00-banner.sh 00-global_var.sh" + +# Automatic modules download +RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \ + && if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \ + && mkdir -p /etc/cont-init.d \ + && for scripts in $MODULES; do curl -L -f -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" || (echo "script failed to install $scripts" && exit 1); done \ + && chmod -R 755 /etc/cont-init.d + +# Manual apps +ENV PACKAGES="" + +# Automatic apps & bashio +RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \ + && if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \ + && curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \ + && chmod 777 /automatic_packages.sh \ + && eval /./automatic_packages.sh "${PACKAGES:-}" \ + && rm /automatic_packages.sh + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ + +ARG BUILD_ARCH +ARG BUILD_DATE +ARG BUILD_DESCRIPTION +ARG BUILD_NAME +ARG BUILD_REF +ARG BUILD_REPOSITORY +ARG BUILD_VERSION +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="alexbelgium (https://github.com/alexbelgium)" \ + org.opencontainers.image.title="${BUILD_NAME}" \ + org.opencontainers.image.description="${BUILD_DESCRIPTION}" \ + org.opencontainers.image.vendor="Home Assistant Add-ons" \ + org.opencontainers.image.authors="alexbelgium (https://github.com/alexbelgium)" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.url="https://github.com/alexbelgium" \ + 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/plex_meta_manager/README.md b/plex_meta_manager/README.md new file mode 100644 index 000000000..84b8ec96f --- /dev/null +++ b/plex_meta_manager/README.md @@ -0,0 +1,79 @@ +# Home assistant add-on: Plex-meta-manager + +[![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium) + +[donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-%23d32f2f?logo=buy-me-a-coffee&style=flat&logoColor=white + +![Supports + Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armv7 Architecture][armv7-shield] +![Supports smb mounts][smb-shield] + +_Thanks to everyone having starred my repo! To star it click on the image below, then it will be on top right. Thanks!_ + +[![Stargazers repo roster for @alexbelgium/hassio-addons](https://reporoster.com/stars/alexbelgium/hassio-addons)](https://github.com/alexbelgium/hassio-addons/stargazers) + +## About + +--- + +[Plex-meta-manager](https://plex-meta-manager.video/) is a Python 3 script that can be continuously run using YAML configuration files to update on a schedule the metadata of the movies, shows, and collections in your libraries as well as automatically build collections based on various methods all detailed in the wiki. + +This addon is based on the docker image https://github.com/linuxserver/docker-plex-meta-manager + +## Installation + +--- + +The installation of this add-on is pretty straightforward and not different in comparison to installing any other add-on. + +1. Add my add-ons repository to your home assistant instance (in supervisor addons store at top right, or click button below if you have configured my HA) + [![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Falexbelgium%2Fhassio-addons) +1. Install this add-on. +1. Click the `Save` button to store your configuration. +1. Set the add-on options to your preferences +1. Start the add-on. +1. Check the logs of the add-on to see if everything went well. +1. Open the webUI and adapt the software options + +## Configuration + +There is a [walkthrough](https://github.com/meisnate12/Plex-Meta-Manager/wiki/Docker-Walkthrough#setting-up-the-initial-config-file) available to help get you up and running. +For more information see the [official wiki](https://github.com/meisnate12/Plex-Meta-Manager/wiki). + +Options can be configured through two ways : + +- Addon options + +```yaml +CONFIG_LOCATION: location of the config.yaml # Sets the location of the config.yaml (see below) +PUID: 1000 #for UserID - see below for explanation +PGID: 1000 #for GroupID - see below for explanation +TZ: Europe/London #Specify a timezone to use EG Europe/London. +PMM_CONFIG: /config/addons_config/plex-data-manager/config/config.yml #Specify a custom config file to use. +PMM_TIME: 03:00 #Comma-separated list of times to update each day. Format: HH:MM. +PMM_RUN: False #Set to True to run without the scheduler. +PMM_TEST: False #Set to True to run in debug mode with only collections that have test: true. +PMM_NO_MISSING: False #Set to True to run without any of the missing movie/show functions. +``` + +- Config.yaml + +Additional variables can be set as ENV variables by adding them in the config.yaml in the location defined in your addon options + +The complete list of ENV variables can be seen here : https://github.com/meisnate12/Plex-Meta-Manager/wiki/Run-Commands-&-Environmental-Variables + +## Support + +Create an issue on github + +## Illustration + +--- + +![illustration](https://dausruddin.com/wp-content/uploads/2020/05/plex-meta-manager-v3-1024x515.png) + +[repository]: https://github.com/alexbelgium/hassio-addons +[smb-shield]: https://img.shields.io/badge/smb-yes-green.svg +[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg +[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg +[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg diff --git a/plex_meta_manager/apparmor.txt b/plex_meta_manager/apparmor.txt new file mode 100644 index 000000000..0ce1f85fb --- /dev/null +++ b/plex_meta_manager/apparmor.txt @@ -0,0 +1,56 @@ +#include + +profile plex-meta-manager_addon flags=(attach_disconnected,mediate_deleted) { + #include + + capability, + file, + signal, + mount, + umount, + remount, + network udp, + network tcp, + network dgram, + network stream, + network inet, + network inet6, + network netlink raw, + + capability setgid, + capability setuid, + capability sys_admin, + capability dac_read_search, + # capability dac_override, + # capability sys_rawio, + +# S6-Overlay + /bin/** ix, + /usr/bin/** ix, + /usr/lib/bashio/** ix, + /etc/s6/** rix, + /run/s6/** rix, + /etc/services.d/** rwix, + /etc/cont-init.d/** rwix, + /etc/cont-finish.d/** rwix, + /init rix, + /var/run/** mrwkl, + /var/run/ mrwkl, + /dev/i2c-1 mrwkl, + # Files required + /dev/sda1 mrwkl, + /dev/sdb1 mrwkl, + /dev/mmcblk0p1 mrwkl, + /dev/* mrwkl, + /tmp/** mrkwl, + + # Data access + /data/** rw, + + # suppress ptrace denials when using 'docker ps' or using 'ps' inside a container + ptrace (trace,read) peer=docker-default, + + # docker daemon confinement requires explict allow rule for signal + signal (receive) set=(kill,term) peer=/usr/bin/docker, + +} diff --git a/plex_meta_manager/build.json b/plex_meta_manager/build.json new file mode 100644 index 000000000..bae4f216e --- /dev/null +++ b/plex_meta_manager/build.json @@ -0,0 +1,7 @@ +{ + "build_from": { + "armv7": "linuxserver/plex-meta-manager:arm32v7-latest", + "aarch64": "linuxserver/plex-meta-manager:arm64v8-latest", + "amd64": "linuxserver/plex-meta-manager:amd64-latest" + } +} diff --git a/plex_meta_manager/config.json b/plex_meta_manager/config.json new file mode 100644 index 000000000..7f7c39a5b --- /dev/null +++ b/plex_meta_manager/config.json @@ -0,0 +1,32 @@ +{ + "name": "Plex meta manager", + "version": "1.0", + "slug": "plex-meta-manager", + "description": "Python script to update metadata information for movies, shows, and collections as well as automatically build collections", + "url": "https://github.com/alexbelgium/hassio-addons/tree/master/plex_meta_manager", + "apparmor": true, + "arch": ["aarch64", "amd64", "armv7"], + "boot": "auto", + "upstream": "1.0", + "devices": [], + "image": "ghcr.io/alexbelgium/plex-media-manager-{arch}", + "environment": {}, + "map": ["config:rw"], + "options": { + "PUID": 0, + "PGID": 0, + "HOME": "/config/addons_config/plex-data-manager" + }, + "privileged": ["SYS_ADMIN", "DAC_READ_SEARCH"], + "schema": { + "PUID": "bool", + "PGID": "bool", + "TZ": "str?", + "HOME": "str", + "PMM_CONFIG": "str?", + "PMM_TIME": "str?", + "PMM_RUN": "bool?", + "PMM_TEST": "bool?", + "PMM_NO_MISSING": "bool?" + } +} diff --git a/plex_meta_manager/icon.png b/plex_meta_manager/icon.png new file mode 100644 index 000000000..9caa607c0 Binary files /dev/null and b/plex_meta_manager/icon.png differ diff --git a/plex_meta_manager/logo.png b/plex_meta_manager/logo.png new file mode 100644 index 000000000..9caa607c0 Binary files /dev/null and b/plex_meta_manager/logo.png differ diff --git a/plex_meta_manager/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/plex_meta_manager/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..150053296 --- /dev/null +++ b/plex_meta_manager/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + echo "Executing modules script" + MODULES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \ + && if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \ + && mkdir -p /etc/cont-init.d \ + && for scripts in $MODULES; do curl -L -f -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" || (echo "script failed to install $scripts" && exit 1); done \ + && chmod -R 755 /etc/cont-init.d +fi + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \ + && if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \ + && curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \ + && chmod 777 /automatic_packages.sh \ + && eval /./automatic_packages.sh "${PACKAGES:-}" \ + && rm /automatic_packages.sh +fi diff --git a/plex_meta_manager/rootfs/etc/cont-init.d/20-configuration.sh b/plex_meta_manager/rootfs/etc/cont-init.d/20-configuration.sh new file mode 100644 index 000000000..fe1e0c221 --- /dev/null +++ b/plex_meta_manager/rootfs/etc/cont-init.d/20-configuration.sh @@ -0,0 +1,30 @@ +#!/usr/bin/with-contenv bashio + +################## +# Create folders # +################## + +PUID=$(bashio::config 'PUID') +GUID=$(bashio::config 'GUID') + +if [ ! -d /config/addons_config/plex-meta-manager ]; then + echo "Creating /config/addons_config/plex-meta-manager" + mkdir -p /config/addons_config/plex-meta-manager +fi + +chown -R "$PUID":"$GUID" /config/addons_config/plex-meta-manager + +################### +# Set config.yaml # +################### + +# Where is the config +CONFIGSOURCE=$(bashio::config "HOME") + +# Check if config file is there, or create one from template +if [ -f $CONFIGSOURCE/config.yml ]; then + echo "Using config file found in $CONFIGSOURCE" +else + echo "No config file, creating one from template" + cp /templates/config.yml "$(dirname "${CONFIGSOURCE}")" +fi