nix/litten.brenise.dev/opt/open-webui/run-open-webui.sh

38 lines
1.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Exit on error, undefined variables, and print commands
set -e
# Default values (can be overridden by command-line arguments)
SESSION_NAME="${1:-textgen}"
LITELLM_PORT="${2:-8031}"
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
echo "Session '$SESSION_NAME' already exists. No action taken."
exit 0
fi
# Activate virtual environment
source .venv/bin/activate
# Source the password forr litellm
source .env
# Check if session already exists
if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
# Create new detached session
tmux new-session -d -s "$SESSION_NAME"
# Start the open-webui server
tmux send-keys -t "$SESSION_NAME" "open-webui serve" C-m
# Start litellm in a new pane
tmux split-window -v -t "$SESSION_NAME"
tmux send-keys -t "$SESSION_NAME" "source .env && litellm --telemetry False --config ./litellm.yaml --host 127.0.0.1 --port $LITELLM_PORT" C-m
echo "Session '$SESSION_NAME' created and configured. To connect, type: tmux att -t $SESSION_NAME"
else
echo "Session '$SESSION_NAME' already exists. Exiting."
exit 1
fi