36 lines
1.5 KiB
Bash
36 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
umask 077
|
|
config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/hermes-stack-maintenance"
|
|
runner="$(dirname -- "${BASH_SOURCE[0]}")/hermes-stack-llama-run"
|
|
|
|
case "${1:-list}" in
|
|
list)
|
|
printf '%-12s %8s %10s\n' Profil Kontext Fit-MiB \
|
|
baseline 65536 1536 balanced 49152 1536 vram-plus 49152 1280 compact 32768 1536
|
|
exit 0 ;;
|
|
baseline|balanced|vram-plus|compact) selected="$1" ;;
|
|
*) printf 'Aufruf: %s [list|baseline|balanced|vram-plus|compact]\n' "$0" >&2; exit 2 ;;
|
|
esac
|
|
[[ $# -eq 1 ]] || exit 2
|
|
# Profilwechsel nur für bewusst migrierte Konfigurationen erlauben.
|
|
# shellcheck disable=SC1090
|
|
source "$config_dir/llama.env"
|
|
[[ -n "${LLAMA_PROFILE:-}" ]] || {
|
|
printf 'Zuerst llama.env nach docs/WORKSTATION.md migrieren. Keine Änderung.\n' >&2; exit 1;
|
|
}
|
|
"$runner" --profile "$selected" --check
|
|
exec 9>"${XDG_RUNTIME_DIR:-/tmp}/hermes-stack-hermes-update.lock"
|
|
flock -n 9 || { printf 'Maintenance läuft. Später erneut versuchen.\n' >&2; exit 1; }
|
|
target="$config_dir/llama-profile.env"
|
|
if [[ -e "$target" ]]; then
|
|
backup="$(mktemp "$config_dir/llama-profile.backup.XXXXXX")"
|
|
cp -p -- "$target" "$backup"
|
|
printf 'Vorherige Profilwahl: %s\n' "$backup"
|
|
fi
|
|
candidate="$(mktemp "$config_dir/llama-profile.env.XXXXXX")"
|
|
printf 'LLAMA_PROFILE=%q\n' "$selected" >"$candidate"
|
|
mv -T -- "$candidate" "$target"
|
|
printf 'Profil %s gespeichert. Laufende Jobs bleiben unverändert.\n' "$selected"
|
|
printf 'Erst nach Jobende: hermes-stack-llama-restart (siehe docs/WORKSTATION.md).\n'
|