From 71f335c153a789062d382f9ea66e8efe50394631 Mon Sep 17 00:00:00 2001 From: Will Anderson Date: Sat, 11 Apr 2026 01:36:13 -0500 Subject: [PATCH] =?UTF-8?q?seerr:=20fix=20init=20container=20=E2=80=94=20u?= =?UTF-8?q?se=20script=20file=20instead=20of=20inline=20shell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- servers/legion/k8s/media/overseerr.yaml | 43 +++++++++++-------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/servers/legion/k8s/media/overseerr.yaml b/servers/legion/k8s/media/overseerr.yaml index 126c091..f583b71 100644 --- a/servers/legion/k8s/media/overseerr.yaml +++ b/servers/legion/k8s/media/overseerr.yaml @@ -21,6 +21,22 @@ data: "serverId": "87e202a4e9ad49d1bf73927f714fbce6", "apiKey": "35e87cb67e3a4b908678ba9a257d2571" } + restore.js: | + const fs = require('fs'); + const SETTINGS = '/app/config/settings.json'; + const DEFAULTS = '/defaults/jellyfin.json'; + let settings = {}; + if (fs.existsSync(SETTINGS)) { + try { settings = JSON.parse(fs.readFileSync(SETTINGS, 'utf8')); } catch(e) {} + } + if (!settings.jellyfin || !settings.jellyfin.apiKey) { + console.log('Jellyfin apiKey missing — restoring from defaults'); + settings.jellyfin = JSON.parse(fs.readFileSync(DEFAULTS, 'utf8')); + fs.writeFileSync(SETTINGS, JSON.stringify(settings, null, 2)); + console.log('Restored Jellyfin config'); + } else { + console.log('Jellyfin config present, skipping restore'); + } --- apiVersion: apps/v1 kind: Deployment @@ -46,31 +62,8 @@ spec: - name: restore-jellyfin-config image: node:22-alpine command: - - sh - - -c - - | - SETTINGS=/app/config/settings.json - DEFAULTS=/defaults/jellyfin.json - - if [ ! -f "$SETTINGS" ]; then - echo "No settings.json — creating with Jellyfin defaults" - echo "{\"jellyfin\": $(cat $DEFAULTS)}" > $SETTINGS - exit 0 - fi - - KEY=$(node -e "try{const d=require('fs').readFileSync('$SETTINGS','utf8'); console.log(JSON.parse(d).jellyfin?.apiKey||'')}catch(e){console.log('')}") - if [ -z "$KEY" ]; then - echo "Jellyfin apiKey missing — restoring from defaults" - node -e " - const fs=require('fs'); - const s=JSON.parse(fs.readFileSync('$SETTINGS','utf8')); - s.jellyfin=JSON.parse(fs.readFileSync('$DEFAULTS','utf8')); - fs.writeFileSync('$SETTINGS', JSON.stringify(s,null,2)); - console.log('Restored Jellyfin config'); - " - else - echo "Jellyfin config present, skipping restore" - fi + - node + - /defaults/restore.js volumeMounts: - name: config mountPath: /app/config