seerr: fix init container — use script file instead of inline shell
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user