From 1637b4f3a978d6be74d82702c589d99d531ad902 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sat, 13 Dec 2025 20:05:11 +0100 Subject: [PATCH 1/4] Handle existing transcode symlink --- jellyfin/rootfs/etc/cont-init.d/90-data_location.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jellyfin/rootfs/etc/cont-init.d/90-data_location.sh b/jellyfin/rootfs/etc/cont-init.d/90-data_location.sh index e0c35c212..ae4154b62 100755 --- a/jellyfin/rootfs/etc/cont-init.d/90-data_location.sh +++ b/jellyfin/rootfs/etc/cont-init.d/90-data_location.sh @@ -27,11 +27,13 @@ sed -i "s|/usr/share/jellyfin|$LOCATION|g" /etc/nginx/servers/ingress.conf # Custom transcode location mkdir -p /data/transcodes -if [ -d "$LOCATION"/data/transcodes ]; then +if [ -L "$LOCATION"/data/transcodes ]; then + rm "$LOCATION"/data/transcodes +elif [ -d "$LOCATION"/data/transcodes ]; then cp -rT "$LOCATION"/data/transcodes /data/transcodes || true rm -r "$LOCATION"/data/transcodes fi -ln -s /data/transcodes "$LOCATION"/data/transcodes +ln -sfn /data/transcodes "$LOCATION"/data/transcodes chown -R "$PUID":"$PGID" /data/transcodes # Permissions From 795b30c78e68bffa4ca0ebfc72c760698f86edd9 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sat, 13 Dec 2025 20:08:45 +0100 Subject: [PATCH 2/4] Handle existing Jellyfin symlinks --- jellyfin/rootfs/etc/cont-init.d/20-folders.sh | 73 +++++++++---------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/jellyfin/rootfs/etc/cont-init.d/20-folders.sh b/jellyfin/rootfs/etc/cont-init.d/20-folders.sh index 628e592db..04abafc7d 100755 --- a/jellyfin/rootfs/etc/cont-init.d/20-folders.sh +++ b/jellyfin/rootfs/etc/cont-init.d/20-folders.sh @@ -3,6 +3,28 @@ set -e LOCATION=$(bashio::config 'data_location') +PUID=$(bashio::config "PUID") +PGID=$(bashio::config "PGID") + +create_link() { + local target_dir="$1" + local link_path="$2" + + mkdir -p "$target_dir" + mkdir -p "$(dirname "$link_path")" + + if [ -L "$link_path" ]; then + rm "$link_path" + elif [ -d "$link_path" ]; then + cp -a "$link_path/." "$target_dir/" || true + rm -r "$link_path" + elif [ -e "$link_path" ]; then + rm "$link_path" + fi + + ln -sfn "$target_dir" "$link_path" + chown -R "$PUID:$PGID" "$target_dir" +} # Check if config is located in an acceptable location LOCATIONOK="" @@ -45,50 +67,25 @@ fi # links -if [ ! -d /jellyfin/cache ]; then - echo "Creating link for /jellyfin/cache" - mkdir -p "$LOCATION"/cache - chown -R "$PUID:$PGID" "$LOCATION"/cache - ln -s "$LOCATION"/cache /jellyfin/cache -fi +echo "Creating link for /jellyfin/cache" +create_link "$LOCATION/cache" /jellyfin/cache -if [ ! -d /jellyfin/data ]; then - echo "Creating link for /jellyfin/data" - mkdir -p "$LOCATION"/data - chown -R "$PUID:$PGID" "$LOCATION"/data - ln -s "$LOCATION"/data /jellyfin/data -fi +echo "Creating link for /jellyfin/data" +create_link "$LOCATION/data" /jellyfin/data -if [ ! -d /jellyfin/log ]; then - echo "Creating link for /jellyfin/log" - mkdir -p "$LOCATION"/log - chown -R "$PUID:$PGID" "$LOCATION"/log - ln -s "$LOCATION"/log /jellyfin/log -fi +echo "Creating link for /jellyfin/log" +create_link "$LOCATION/log" /jellyfin/log -if [ ! -d /jellyfin/metadata ]; then - echo "Creating link for /jellyfin/metadata" - mkdir -p "$LOCATION"/metadata - chown -R "$PUID:$PGID" "$LOCATION"/metadata - ln -s "$LOCATION"/metadata /jellyfin/metadata -fi +echo "Creating link for /jellyfin/metadata" +create_link "$LOCATION/metadata" /jellyfin/metadata -if [ ! -d /jellyfin/plugins ]; then - echo "Creating link for /jellyfin/plugins" - mkdir -p "$LOCATION"/plugins - chown -R "$PUID:$PGID" "$LOCATION"/plugins - ln -s "$LOCATION"/plugins /jellyfin/plugins -fi +echo "Creating link for /jellyfin/plugins" +create_link "$LOCATION/plugins" /jellyfin/plugins -if [ ! -d /jellyfin/root ]; then - echo "Creating link for /jellyfin/root" - mkdir -p "$LOCATION"/root - chown -R "$PUID:$PGID" "$LOCATION"/root - ln -s "$LOCATION"/root /jellyfin/root -fi +echo "Creating link for /jellyfin/root" +create_link "$LOCATION/root" /jellyfin/root # Legacy mode echo "Enable legacy mode" -mkdir -p /config/addons_config -ln -sf "$LOCATION" /config/addons_config/jellyfin +create_link "$LOCATION" /config/addons_config/jellyfin chown -R "$PUID:$PGID" "$LOCATION" From c89cf5bf636bb225b7f6d0aa41b8eb9e2b3d3aab Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sat, 13 Dec 2025 20:13:04 +0100 Subject: [PATCH 3/4] Fix Jellyfin legacy symlink handling --- jellyfin/CHANGELOG.md | 3 +++ jellyfin/config.yaml | 2 +- jellyfin/rootfs/etc/cont-init.d/20-folders.sh | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/jellyfin/CHANGELOG.md b/jellyfin/CHANGELOG.md index edcac676e..c9b4b2c6e 100644 --- a/jellyfin/CHANGELOG.md +++ b/jellyfin/CHANGELOG.md @@ -1,3 +1,6 @@ +## 10.11.4-1 (07-12-2025) +- Avoid deleting the configured data directory when it matches the legacy path while rebuilding symlinks. + ## breaking_versions: 10.11.4 (06-12-2025) - Minor bugs fixed diff --git a/jellyfin/config.yaml b/jellyfin/config.yaml index a34650271..bca57f6c5 100644 --- a/jellyfin/config.yaml +++ b/jellyfin/config.yaml @@ -125,5 +125,5 @@ schema: slug: jellyfin udev: true url: https://github.com/alexbelgium/hassio-addons -version: "10.11.4" +version: "10.11.4-1" video: true diff --git a/jellyfin/rootfs/etc/cont-init.d/20-folders.sh b/jellyfin/rootfs/etc/cont-init.d/20-folders.sh index 04abafc7d..d3e68357f 100755 --- a/jellyfin/rootfs/etc/cont-init.d/20-folders.sh +++ b/jellyfin/rootfs/etc/cont-init.d/20-folders.sh @@ -10,9 +10,21 @@ create_link() { local target_dir="$1" local link_path="$2" + local target_real + local link_real + + target_real=$(realpath -m "$target_dir") + link_real=$(realpath -m "$link_path") + mkdir -p "$target_dir" mkdir -p "$(dirname "$link_path")" + # If the link path is the same as the target, just ensure ownership and exit + if [ "$target_real" = "$link_real" ]; then + chown -R "$PUID:$PGID" "$target_dir" + return + fi + if [ -L "$link_path" ]; then rm "$link_path" elif [ -d "$link_path" ]; then From 4a76b61d4e7cb6db3ee0441c8ea475a2a3c7c5c5 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sat, 13 Dec 2025 20:13:28 +0100 Subject: [PATCH 4/4] Update jellyfin/rootfs/etc/cont-init.d/90-data_location.sh Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- jellyfin/rootfs/etc/cont-init.d/90-data_location.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jellyfin/rootfs/etc/cont-init.d/90-data_location.sh b/jellyfin/rootfs/etc/cont-init.d/90-data_location.sh index ae4154b62..346bb7fb6 100755 --- a/jellyfin/rootfs/etc/cont-init.d/90-data_location.sh +++ b/jellyfin/rootfs/etc/cont-init.d/90-data_location.sh @@ -27,11 +27,11 @@ sed -i "s|/usr/share/jellyfin|$LOCATION|g" /etc/nginx/servers/ingress.conf # Custom transcode location mkdir -p /data/transcodes -if [ -L "$LOCATION"/data/transcodes ]; then - rm "$LOCATION"/data/transcodes -elif [ -d "$LOCATION"/data/transcodes ]; then +if [ -d "$LOCATION"/data/transcodes ]; then cp -rT "$LOCATION"/data/transcodes /data/transcodes || true rm -r "$LOCATION"/data/transcodes +elif [ -L "$LOCATION"/data/transcodes ]; then + rm "$LOCATION"/data/transcodes fi ln -sfn /data/transcodes "$LOCATION"/data/transcodes chown -R "$PUID":"$PGID" /data/transcodes