- --force erlaubt jetzt tatsächlich das Downgrade auf Stable/Beta (der Downgrade-Block war vorher unerreichbar) - test.sh: Tests für cmp_versions und die Update-Entscheidung (gefakete curl/ollama, kein Netz nötig) - --help: stdout + Exit 0; unbekannte Argumente werden benannt - tote Zeilen entfernt (nullglob, basename-Zeremonie) - README: Nummerierung und nullglob-Erwähnung korrigiert
72 lines
1.8 KiB
Markdown
72 lines
1.8 KiB
Markdown
# 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
|
|
|
|
# Force installation of older version (downgrade)
|
|
./ollama-update --force
|
|
./ollama-update -f
|
|
|
|
# Combine with beta channel
|
|
./ollama-update --beta --force
|
|
./ollama-update -b -f
|
|
|
|
# Show help
|
|
./ollama-update --help
|
|
./ollama-update -h
|
|
```
|
|
|
|
## 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, ~270 lines)
|
|
- `test.sh` — self-test for version compare and update decision (no network, no install)
|
|
- `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
|
|
|
|
```bash
|
|
# Unit + integration tests (fake curl/ollama, no network, no install)
|
|
./test.sh
|
|
```
|
|
|
|
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` — preserve this
|
|
- 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 |