From 47a4b052529b8c4e3f8cb4d68cf48e72cdf2e637 Mon Sep 17 00:00:00 2001 From: Austin Burdine Date: Mon, 31 Aug 2026 15:16:33 -0400 Subject: [PATCH] Fixed broken symlinks in 6 => 6-next mount no ref - moving the volume mount from a 6 => 6-next image would result in broken symlinks due to the way the default themes are shipped in the image - automatically cleanup broken symlinks instead of copying files through them --- 6-next/alpine3.23/docker-entrypoint.sh | 10 +++++++++- 6-next/bookworm/docker-entrypoint.sh | 10 +++++++++- docker-entrypoint-next.sh | 10 +++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/6-next/alpine3.23/docker-entrypoint.sh b/6-next/alpine3.23/docker-entrypoint.sh index bafa8d6b..34396373 100755 --- a/6-next/alpine3.23/docker-entrypoint.sh +++ b/6-next/alpine3.23/docker-entrypoint.sh @@ -77,7 +77,9 @@ fi # allow the container to be started with `--user` if [ -n "$isGhost" ] && [ "$(id -u)" = '0' ]; then - find "$GHOST_CONTENT" \! -user ghost -exec chown ghost '{}' + + # -h: ghost:6 seeded its bundled themes as symlinks into /var/lib/ghost, which does not + # exist here. Without it chown follows them, fails on the missing target, and set -e aborts. + find "$GHOST_CONTENT" \! -user ghost -exec chown -h ghost '{}' + exec gosu ghost "$0" "$@" fi @@ -87,6 +89,12 @@ if [ -n "$isGhost" ]; then src="${src%/}" target="$GHOST_CONTENT/${src#$baseDir/}" mkdir -p "$(dirname "$target")" + # those same dangling theme symlinks are not "-e", so the seed below would run and tar + # would extract *through* the symlink instead of replacing it. Drop them first. Guarded on + # broken-only so a user's own valid symlinked theme is left alone. + if [ -L "$target" ] && [ ! -e "$target" ]; then + rm -f "$target" + fi if [ ! -e "$target" ]; then tar -cC "$(dirname "$src")" "$(basename "$src")" | tar -xC "$(dirname "$target")" fi diff --git a/6-next/bookworm/docker-entrypoint.sh b/6-next/bookworm/docker-entrypoint.sh index bafa8d6b..34396373 100755 --- a/6-next/bookworm/docker-entrypoint.sh +++ b/6-next/bookworm/docker-entrypoint.sh @@ -77,7 +77,9 @@ fi # allow the container to be started with `--user` if [ -n "$isGhost" ] && [ "$(id -u)" = '0' ]; then - find "$GHOST_CONTENT" \! -user ghost -exec chown ghost '{}' + + # -h: ghost:6 seeded its bundled themes as symlinks into /var/lib/ghost, which does not + # exist here. Without it chown follows them, fails on the missing target, and set -e aborts. + find "$GHOST_CONTENT" \! -user ghost -exec chown -h ghost '{}' + exec gosu ghost "$0" "$@" fi @@ -87,6 +89,12 @@ if [ -n "$isGhost" ]; then src="${src%/}" target="$GHOST_CONTENT/${src#$baseDir/}" mkdir -p "$(dirname "$target")" + # those same dangling theme symlinks are not "-e", so the seed below would run and tar + # would extract *through* the symlink instead of replacing it. Drop them first. Guarded on + # broken-only so a user's own valid symlinked theme is left alone. + if [ -L "$target" ] && [ ! -e "$target" ]; then + rm -f "$target" + fi if [ ! -e "$target" ]; then tar -cC "$(dirname "$src")" "$(basename "$src")" | tar -xC "$(dirname "$target")" fi diff --git a/docker-entrypoint-next.sh b/docker-entrypoint-next.sh index bafa8d6b..34396373 100755 --- a/docker-entrypoint-next.sh +++ b/docker-entrypoint-next.sh @@ -77,7 +77,9 @@ fi # allow the container to be started with `--user` if [ -n "$isGhost" ] && [ "$(id -u)" = '0' ]; then - find "$GHOST_CONTENT" \! -user ghost -exec chown ghost '{}' + + # -h: ghost:6 seeded its bundled themes as symlinks into /var/lib/ghost, which does not + # exist here. Without it chown follows them, fails on the missing target, and set -e aborts. + find "$GHOST_CONTENT" \! -user ghost -exec chown -h ghost '{}' + exec gosu ghost "$0" "$@" fi @@ -87,6 +89,12 @@ if [ -n "$isGhost" ]; then src="${src%/}" target="$GHOST_CONTENT/${src#$baseDir/}" mkdir -p "$(dirname "$target")" + # those same dangling theme symlinks are not "-e", so the seed below would run and tar + # would extract *through* the symlink instead of replacing it. Drop them first. Guarded on + # broken-only so a user's own valid symlinked theme is left alone. + if [ -L "$target" ] && [ ! -e "$target" ]; then + rm -f "$target" + fi if [ ! -e "$target" ]; then tar -cC "$(dirname "$src")" "$(basename "$src")" | tar -xC "$(dirname "$target")" fi