From 26391945013bbcb647568da54be967e156f89032 Mon Sep 17 00:00:00 2001 From: NeonXP Date: Sun, 19 Feb 2023 00:27:14 +0300 Subject: initial --- minidlna/Dockerfile | 13 +++++++++++ minidlna/entrypoint.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 minidlna/Dockerfile create mode 100755 minidlna/entrypoint.sh (limited to 'minidlna') diff --git a/minidlna/Dockerfile b/minidlna/Dockerfile new file mode 100644 index 0000000..d8d4332 --- /dev/null +++ b/minidlna/Dockerfile @@ -0,0 +1,13 @@ +FROM alpine:3.17.2 +LABEL maintainer "Alexander Kiryukhin i@neonxp.dev" + +# Install +RUN apk --no-cache add bash curl minidlna tini shadow su-exec alpine-conf inotify-tools + +# Entrypoint +COPY entrypoint.sh / +RUN chmod +x /entrypoint.sh + +EXPOSE 8200 + +ENTRYPOINT ["/sbin/tini", "--", "/entrypoint.sh"] \ No newline at end of file diff --git a/minidlna/entrypoint.sh b/minidlna/entrypoint.sh new file mode 100755 index 0000000..5b77916 --- /dev/null +++ b/minidlna/entrypoint.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# Bash strict mode +set -euo pipefail +IFS=$'\n\t' + +# DEBUG +[ -z "${DEBUG:-}" ] || set -x + +# VARs +export TZ="${TZ:-}" +export PUID="${PUID:-100}" +export PGID="${PGID:-101}" +export PIDFILE='/minidlna/minidlna.pid' +export FORCE_SCAN="${FORCE_SCAN:-false}" +export FORCE_REBUILD="${FORCE_REBUILD:-false}" + +# Remove old pid if it exists +[ -f "$PIDFILE" ] && rm -f "$PIDFILE" + +echo '=== Set user and group identifier' +groupmod --non-unique --gid "$PGID" minidlna +usermod --non-unique --uid "$PUID" minidlna + +if [[ -n "$TZ" ]]; then + echo '=== Set timezone' + setup-timezone -z "$TZ" +fi + +echo '=== Set standard configuration' +export MINIDLNA_DB_DIR="${MINIDLNA_DB_DIR:-/minidlna/cache}" +export MINIDLNA_LOG_DIR="${MINIDLNA_LOG_DIR:-/minidlna}" +export MINIDLNA_INOTIFY="${MINIDLNA_INOTIFY:-yes}" + +echo '=== Set configuration from environment variables' +: > /etc/minidlna.conf +for VAR in $(env); do + if [[ "$VAR" =~ ^MINIDLNA_ ]]; then + if [[ "$VAR" =~ ^MINIDLNA_MEDIA_DIR ]]; then + minidlna_name='media_dir' + else + minidlna_name=$(echo "$VAR" | sed -r "s/MINIDLNA_(.*)=.*/\\1/g" | tr '[:upper:]' '[:lower:]') + fi + minidlna_value=$(echo "$VAR" | sed -r "s/.*=(.*)/\\1/g") + echo "${minidlna_name}=${minidlna_value}" >> /etc/minidlna.conf + fi +done + +echo '=== Set permissions' +mkdir -p /minidlna/ "${MINIDLNA_DB_DIR}" "${MINIDLNA_LOG_DIR}" +chown -R "${PUID}:${PGID}" /minidlna/ "${MINIDLNA_DB_DIR}" "${MINIDLNA_LOG_DIR}" + +echo '=== Generate scan/rebuild flags' +if [[ "$FORCE_SCAN" == true ]]; then + set -- -r "$@" +fi +if [[ "$FORCE_REBUILD" == true ]]; then + set -- -R "$@" +fi + +echo '=== Start daemon' +exec su-exec minidlna /usr/sbin/minidlnad -P "$PIDFILE" -S "$@" \ No newline at end of file -- cgit v1.2.3