From f430e2264de5a9f1ec49f68135802fa3cb828ba7 Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 31 Oct 2026 09:50:22 -0700 Subject: [PATCH] docs(plex): the scan recipe kept its own promise about the token MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The block said the token rides stdin and never argv, then handed it to curl as `-H "X-Plex-Token: $T"` — world-readable in /proc//cmdline. It now writes a mode-600 curl config inside the container, which is also how the overnight rescan was actually issued (five sections, all accepted). Two truths the old block got wrong are stated: a section answers 200 with a Directory body when Accept: application/json is sent, and a backslash-newline inside a quoted printf format is literal, so the config builder writes two printfs. --- serverAppConfigs-docs/Dankserver/Plex.md | 35 +++++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/serverAppConfigs-docs/Dankserver/Plex.md b/serverAppConfigs-docs/Dankserver/Plex.md index ab24a5e..9cc843e 100644 --- a/serverAppConfigs-docs/Dankserver/Plex.md +++ b/serverAppConfigs-docs/Dankserver/Plex.md @@ -102,15 +102,30 @@ rides stdin, never argv, where any process on the host could read it out of umask 077 podman exec plex sh -c "sed -n 's/.*PlexOnlineToken=\"\\([^\"]*\\)\".*/\\1/p' \ '/config/Library/Application Support/Plex Media Server/Preferences.xml'" >/tmp/px.tok -podman exec -i plex sh -c 'read -r T - for k in $(curl -s -H "X-Plex-Token: $T" -H "Accept: application/json" \ - http://127.0.0.1:32400/library/sections | grep -o "\"key\":\"[0-9]*\"" | cut -d\" -f4); do - curl -s -o /dev/null -w "plex section $k: %{http_code}\n" -X POST \ - -H "X-Plex-Token: $T" "http://127.0.0.1:32400/library/sections/$k/refresh" - done' /tmp/pxscan.sh <<'EOS' +read -r T +cfg=$(mktemp) +mk() { { printf 'header = "X-Plex-Token: %s"\nheader = "Accept: application/json"\n' "$T" + printf 'url = "%s"\n' "$1"; } > "$cfg"; } +mk "http://127.0.0.1:32400/library/sections" +for k in $(curl -s -K "$cfg" | grep -o '"key":"[0-9]*"' | cut -d\" -f4); do + mk "http://127.0.0.1:32400/library/sections/$k/refresh" + printf 'request = "POST"\n' >> "$cfg" + echo "plex section $k: $(curl -s -o /dev/null -w '%{http_code}' -K "$cfg")" +done +shred -u "$cfg" +EOS +podman cp /tmp/pxscan.sh plex:/tmp/pxscan.sh +podman exec -i plex sh /tmp/pxscan.sh