feat: drop-in support for custom templates
User templates can now be added without rebuilding: drop a script into ~/.config/motd-assist/templates/ and reference it from a preset via "install": "<filename>". Same-name files override built-ins; new files are picked up by the running TUI via 'r'. `motd-assist templates` lists known templates and creates the drop-in directory. Apply plans now embed the resolved template content (Plan.ResolveContents) so the sudo/root process never needs to read user config; snapshots store installed script content so restore works under sudo as well. Validation rejects plans with unresolved content.
This commit is contained in:
parent
d56659e21a
commit
303c49b484
10 changed files with 375 additions and 48 deletions
|
|
@ -45,6 +45,40 @@ echo
|
|||
echo "=== list (nach restore) ==="
|
||||
MOTD_ASSIST_ROOT=$R /tmp/motd-assist list
|
||||
|
||||
echo
|
||||
echo "=== Drop-in-Vorlage anlegen (XDG) ==="
|
||||
export XDG_CONFIG_HOME=/tmp/xdg-motd
|
||||
rm -rf "$XDG_CONFIG_HOME"
|
||||
mkdir -p "$XDG_CONFIG_HOME/motd-assist/templates" "$XDG_CONFIG_HOME/motd-assist/presets"
|
||||
printf '#!/bin/sh\necho "== Mein eigenes Template =="\nuname -s\n' > "$XDG_CONFIG_HOME/motd-assist/templates/mein-header"
|
||||
cat > "$XDG_CONFIG_HOME/motd-assist/presets/custom.json" <<'EOF'
|
||||
{
|
||||
"name": "custom",
|
||||
"description": "Drop-in-Preset mit eigener Vorlage",
|
||||
"scripts": [
|
||||
{ "name": "00-header", "enabled": false },
|
||||
{ "name": "10-mein-header", "enabled": true, "install": "mein-header" }
|
||||
]
|
||||
}
|
||||
EOF
|
||||
|
||||
echo
|
||||
echo "=== templates (Drop-in muss auftauchen) ==="
|
||||
MOTD_ASSIST_ROOT=$R /tmp/motd-assist templates
|
||||
|
||||
echo
|
||||
echo "=== apply custom (User-Vorlage via eingebetteten Plan-Inhalt) ==="
|
||||
MOTD_ASSIST_ROOT=$R /tmp/motd-assist apply custom
|
||||
|
||||
echo
|
||||
echo "=== preview mit Drop-in-Template ==="
|
||||
MOTD_ASSIST_ROOT=$R /tmp/motd-assist preview -w 50
|
||||
|
||||
echo
|
||||
echo "=== restore (Drop-in-Script muss weg) ==="
|
||||
MOTD_ASSIST_ROOT=$R /tmp/motd-assist restore
|
||||
MOTD_ASSIST_ROOT=$R /tmp/motd-assist list
|
||||
|
||||
echo
|
||||
echo "=== ls update-motd.d ==="
|
||||
ls -la "$R/etc/update-motd.d"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue