commit f9665e3e3705e815e5fd024d5fd22eb1dd45c69a0da1051f48a912bf80dc98fe Author: wbg Date: Wed Apr 1 11:27:14 2026 +0200 Initial commit with scripts and .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..28dca0e --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +# Backup files +*~ +*.bak +*.swp +*.orig + +# OS specific +.DS_Store +Thumbs.db + +# Log files +*.log diff --git a/create_pod_openwebui.sh b/create_pod_openwebui.sh new file mode 100755 index 0000000..8bca379 --- /dev/null +++ b/create_pod_openwebui.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# To be run by user wbg to create the pod and container with +# Open WebUI and to create the systemd service +# Open WebUI releases: https://github.com/open-webui/open-webui/releases + +# Environment variables +POD_NAME='openwebui_pod' +CTR_NAME='openwebui_ctr' +IMAGE='ghcr.io/open-webui/open-webui:v0.8.12-cuda' +# IMAGE='ghcr.io/open-webui/open-webui:git-9ae06a3' +HOST_LOCAL_IP='127.0.0.1' +openwebui_pod_HOST_PORT='8080' +AIGPU_HOST_PORT='8081' +NET_OPTS='slirp4netns:allow_host_loopback=true' +BIND_DIR="$HOME/.local/share/$POD_NAME" +BACKEND_DIR="$BIND_DIR/backend_data" +USER_SYSTEMD_DIR="$HOME/.config/systemd/user" + +# Prepare directories +mkdir -p "$BACKEND_DIR" "$USER_SYSTEMD_DIR" + +# Create pod if not yet existing +if ! podman pod exists "$POD_NAME"; then + podman pod create -n "$POD_NAME" \ + --network "$NET_OPTS" \ + -p ${HOST_LOCAL_IP}:${openwebui_pod_HOST_PORT}:${openwebui_pod_HOST_PORT} + echo "Pod '$POD_NAME' created (rc=$?)" +else + echo "Pod '$POD_NAME' already exists." +fi + +# Open WebUI container +# Remove old container +podman rm -f "$CTR_NAME" +# New container +podman run -d --name "$CTR_NAME" --pod "$POD_NAME" \ + -e OLLAMA_BASE_URL=10.0.2.2:"$AIGPU_HOST_PORT" \ + -v "$BACKEND_DIR":/app/backend/data \ + "$IMAGE" +echo "Started $CTR_NAME container (rc=$?)" + +# Generate systemd service files +cd "$USER_SYSTEMD_DIR" +podman generate systemd --files --new --name "$POD_NAME" +echo "Generated systemd service files (rc=$?)" + +# Stop & remove live pod and containers +podman pod stop --ignore --time 15 "$POD_NAME" +podman pod rm -f --ignore "$POD_NAME" +if podman pod exists "$POD_NAME"; then + echo "ERROR: Pod $POD_NAME still exists." + exit 1 +else + echo "Stopped & removed live pod $POD_NAME and containers" +fi + +# Enable systemd service +systemctl --user daemon-reload +systemctl --user enable --now "pod-${POD_NAME}.service" +echo "Enabled systemd service pod-${POD_NAME}.service (rc=$?)" +echo "Status: systemctl --user status pod-${POD_NAME}.service" +echo "View logs: journalctl --user -u pod-${POD_NAME}.service -f" +systemctl --user enable --now "container-${CTR_NAME}.service" +echo "Enabled systemd service container-${CTR_NAME}.service (rc=$?)" +echo "Status: systemctl --user status container-${CTR_NAME}.service" +echo "View logs: journalctl --user -u container-${CTR_NAME}.service -f" diff --git a/remove_pod_systemd_services.sh b/remove_pod_systemd_services.sh new file mode 100755 index 0000000..609c995 --- /dev/null +++ b/remove_pod_systemd_services.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Remove pod and containers systemd services + +# Environment variables +POD_NAME='aiui' +CTR_NAME='openwebui' + +systemctl --user stop pod-"$POD_NAME".service +systemctl --user disable pod-"$POD_NAME".service +systemctl --user stop container-"$CTR_NAME".service +systemctl --user disable container-"$CTR_NAME".service + +systemctl --user reset-failed +rm -f ~/.config/systemd/user/pod-"$POD_NAME".service +rm -f ~/.config/systemd/user/container-"$CTR_NAME".service +systemctl --user daemon-reload +systemctl --user list-unit-files | grep -E 'pod-|container-' || echo "No pod/container units found"