- Multi-stage Dockerfile: discover patterns from PMS binary (capstone), compile .so with zig (musl), layer onto lscr.io/linuxserver/plex - Uses LD_PRELOAD instead of patchelf (which corrupts Plex's musl loader) - Auto-discovery: broad structural patterns with string-anchored fallback (//feature) and relationship-based fallback (BITSET_REF within BS_INIT) - hook.cpp uses __has_include for generated patterns with hardcoded fallbacks - Custom wrapper.sh (no traffic_logger preload) - Vendored Freeloader source (github.com/authrequest/Freeloader, AGPL-3.0) - Removed stale plexmediaserver_crack.so binary - Supports Plex 1.43.3+ (verified against 1.43.2 and 1.43.3)
37 lines
1.7 KiB
Bash
37 lines
1.7 KiB
Bash
#!/bin/sh
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
#
|
|
# In-container launcher for Plex Media Server. Used by the patched
|
|
# plexinc/pms-docker and lscr.io/linuxserver/plex images; both Dockerfiles
|
|
# replace the upstream s6 service run file so it execs this script.
|
|
#
|
|
# Mirrors scripts/plex-crack-wrapper.sh from the native systemd install, with
|
|
# one key invariant:
|
|
#
|
|
# LD_PRELOAD is exported *last*, immediately before `exec`, so the glibc
|
|
# shell helpers spawned for the PLEX_MEDIA_SERVER_INFO_* assignments
|
|
# (grep/awk/uname/tr) are NOT preloaded. The .so's constructor
|
|
# (src/main.cpp) calls unsetenv("LD_PRELOAD") when it loads into the
|
|
# (musl) PMS process, so PMS's glibc helper children (Tuner Service,
|
|
# Script Host, transcoders) are unaffected as well.
|
|
#
|
|
# `exec` is mandatory so s6-supervise sees PMS as the supervised process
|
|
# (no fork). "$@" preserves any args the upstream invocation might add.
|
|
|
|
set -eu
|
|
|
|
# 1. Platform strings PMS echoes in /identity. Mirrors upstream start.sh.
|
|
export PLEX_MEDIA_SERVER_INFO_VENDOR="$(grep ^NAME= /etc/os-release | awk -F= '{print $2}' | tr -d '"')"
|
|
export PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)"
|
|
export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="$(grep ^VERSION= /etc/os-release | awk -F= '{print $2}' | tr -d '"')"
|
|
|
|
# 2. Set LD_PRELOAD only now. The .so paths match where the Dockerfiles
|
|
# copy them. Do NOT change this without updating both Dockerfiles.
|
|
PRELOADS=""
|
|
PRELOADS="${PRELOADS}:/usr/lib/plexmediaserver/lib/plexmediaserver_crack.so"
|
|
PRELOADS="${PRELOADS}:/usr/lib/plexmediaserver/lib/plexmediaserver_traffic_logger.so"
|
|
export LD_PRELOAD="${PRELOADS#:}"
|
|
|
|
# 3. Hand off to PMS.
|
|
exec "/usr/lib/plexmediaserver/Plex Media Server" "$@"
|