Shell scripts and Python utilities to automate a self-hosted local AI stack — pulling models, deploying Open WebUI in Docker, keeping Ollama updated via cron, and querying the API without babysitting.
Every time: pull the models, restart the service, re-wire the UI, poke the API to see if it's alive. None of it is hard, but it's all manual, and it piles up. One wrong docker run flag and the UI can't reach Ollama. Miss an Ollama update and you're running a stale model server.
Each script owns exactly one job. Run the one you need, skip the ones you don't. The update script runs on a cron schedule so Ollama stays current without you touching it. The Docker scripts wire Open WebUI and its pipelines container to your host Ollama instance with the right flags the first time. The Python utilities talk to the Open WebUI API directly for bulk file uploads and knowledge collection management.
# One-time setup — grants passwordless sudo for the update script only,
# then installs a cron job that runs Mon/Wed/Fri at 15:00
sudo src/update_ollama/setup_ollama_sudo.sh
# Watch the logs
journalctl -t "update_ollama" -fThe update script (update_ollama) installs the latest Ollama, ensures OLLAMA_HOST=0.0.0.0:11434 is set in the systemd service file, reloads the daemon, restarts the service, and verifies the API responds — all without storing any passwords.
# Fresh deploy: stops and removes any existing container, then re-runs
bash src/deploy_open_webui.sh
# Or run Open WebUI + Pipelines together from scratch
bash src/docker_run.shOpen WebUI will be available at http://localhost:3000.
# Pull all models currently listed in `ollama ls`
bash src/fetch_models_mac.sh
# Print the system prompt for every local model
bash src/ollama_model_info.sh# Set your API key, then send a chat completion request
export OPENWEBUI_API_KEY="your-key-here"
bash src/query_openwebui.shEdit API_URL and the model field in the script to match your deployment and desired model.
# Set HOST, PORT, and MODEL at the top of the script, then run
bash src/ollama_test.shTimes the response and prints wall-clock, user, and sys CPU time.
# Set token and directory_path in upload_files.py, then run
python src/upload_files.pyUploads every file in the target directory to the Open WebUI /api/v1/files/ endpoint.
# Set token, knowledge_id, and directory_path in collection.py, then run
python src/collection.pyReads filenames from the uploads directory, extracts the file ID from the filename prefix, and registers each file into the specified knowledge collection via the Open WebUI API.
# One-time setup — run once as yourself (not root)
sudo src/update_ollama/setup_ollama_sudo.shInstalls a scoped sudoers entry (only this script, no password) and a crontab entry that runs the update Mon/Wed/Fri at 15:00. Logs go to /var/log/update_ollama.log and syslog under the tag update_ollama.
- Ollama installed and running
- Docker (for Open WebUI scripts)
curl,bash- Python 3 +
requests(forupload_files.pyandcollection.py) - Linux with systemd (for
update_ollamaandsetup_ollama_sudo.sh)