From e23c27ff48277b19f7b14891cd92ea1cde103c68 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 31 Jul 2025 09:36:26 +0200 Subject: [PATCH] Revert code and implement skip permissions --- .../rootfs/etc/cont-init.d/90-create_links.sh | 53 ++++++++----------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/plex/rootfs/etc/cont-init.d/90-create_links.sh b/plex/rootfs/etc/cont-init.d/90-create_links.sh index 6700431d7..5361f18e8 100755 --- a/plex/rootfs/etc/cont-init.d/90-create_links.sh +++ b/plex/rootfs/etc/cont-init.d/90-create_links.sh @@ -1,38 +1,29 @@ -#!/usr/bin/with-contenv bashio -set -euo pipefail +#!/usr/bin/env bashio -PUID="$(bashio::config 'PUID' || echo 0)" -PGID="$(bashio::config 'PGID' || echo 0)" +################## +# SYMLINK CONFIG # +################## -bashio::log.info "Ensuring Plex library location and symlink ..." - -# 1) Ensure base dir exists -install -d -m 0775 /share/plex || mkdir -p /share/plex - -# 2) Migrate once if needed -if [ -d /config/Library ] && [ ! -L /config/Library ] && [ ! -e /share/plex/Library ]; then - bashio::log.info "Migrating /config/Library to /share/plex/Library" - mv /config/Library /share/plex/ +if [ ! -d /share/plex ]; then + echo "Creating /share/plex" + mkdir -p /share/plex fi -# 3) Ensure target exists -install -d -m 0775 /share/plex/Library || mkdir -p /share/plex/Library - -# 4) Ensure symlink /config/Library -> /share/plex/Library -if [ ! -L /config/Library ] || [ "$(readlink -f /config/Library || true)" != "/share/plex/Library" ]; then - if [ -e /config/Library ] && [ ! -L /config/Library ]; then - mv /config/Library "/config/Library.bak-$(date +%s)" - else - rm -f /config/Library || true - fi - ln -sfn /share/plex/Library /config/Library +if [ ! -d /share/plex/Library ]; then + echo "moving Library folder" + mv /config/Library /share/plex + ln -s /share/plex/Library /config + echo "links done" +else + rm -r /config/Library + ln -s /share/plex/Library /config + echo "Using existing config" fi -# 5) Fix ownership and permissions **recursively** so Plex can write its DB -if [ "$PUID" != "0" ] || [ "$PGID" != "0" ]; then - chown -R "$PUID:$PGID" /share/plex/Library - chmod -R u+rwX,g+rwX /share/plex/Library - chmod g+s /share/plex/Library -fi +PUID="$(bashio::config 'PUID')" +PGID="$(bashio::config 'PGID')" -bashio::log.info "Plex library directory and symlink are ready." +if ! bashio::config.true "skip_permissions_check" && [ "${PUID:-0}" != "0" ] && [ "${PGID:-0}" != "0" ]; then + chown -R "${PUID}:${PGID}" /share/plex + chmod -R 777 /share/plex +fi