diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..6f32f79 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,57 @@ +# AGENTS.md — Ollama-Updater + +Single-file Bash script (`ollama-update`) that updates Ollama to latest stable or beta. + +## Commands + +```bash +# Run script (stable channel) +./ollama-update + +# Run script (beta channel) +./ollama-update --beta +./ollama-update -b + +# Show help +./ollama-update --help +``` + +## Lint / Check + +```bash +# ShellCheck (recommended) +shellcheck ollama-update + +# Run with bash strict mode (what the script uses) +bash -euo pipefail ollama-update --help +``` + +## Structure + +- `ollama-update` — main script (executable, bash, ~240 lines) +- `README.md` — usage docs + +## Key behaviors + +- Uses GitHub API (`api.github.com/repos/ollama/ollama/releases`) to fetch versions +- Downloads and runs official `ollama.com/install.sh` via `OLLAMA_VERSION` env var for version pinning +- SemVer comparison with suffix support (`cmp_versions` function) +- Requires: `curl`, `grep`, `sed`, `sort`, `mktemp`, `chmod` +- Runs without root for version checks; install may need root (systemd service) + +## Testing + +No formal test suite. Manual verification: + +```bash +# Dry-run version checks (no install) +./ollama-update # shows local/stable/beta versions +./ollama-update --beta # shows beta comparison +``` + +## Gotchas + +- Script uses `set -euo pipefail` and `nullglob` — preserve these +- GitHub API rate limits: unauthenticated = 60 req/hr +- Beta channel compares against stable; only updates if beta > stable AND beta > local +- Temp install script cleaned via `trap` on EXIT \ No newline at end of file diff --git a/ollama-update b/ollama-update index b92967b..3b7ef26 100755 --- a/ollama-update +++ b/ollama-update @@ -157,6 +157,12 @@ install_ollama() { # Skript ausführbar machen und ausführen. chmod +x "$tmp_script" || die "Konnte Installations-Skript nicht ausführbar machen." "$tmp_script" || die "Installation von Ollama ist fehlgeschlagen." + + # Erfolg: temporäre Datei löschen und Trap entfernen, damit er beim + # späteren Script-Exit nicht auf eine nicht mehr existierende lokale + # Variable zugreift (sonst Fehler wegen 'set -u'). + trap - EXIT + rm -f "$tmp_script" } main() {