test sabnzd

This commit is contained in:
CanbiZ
2025-06-05 14:10:08 +02:00
parent 9e84828e3e
commit 7ebfebce74
3 changed files with 55 additions and 24 deletions

View File

@ -22,7 +22,7 @@ $STD apt-get install -y \
nginx
msg_ok "Installed Dependencies"
PYTHON_VERSION="3.12" setup_uv
setup_uv
msg_info "Installing Babybuddy"
RELEASE=$(curl -fsSL https://api.github.com/repos/babybuddy/babybuddy/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
@ -31,6 +31,8 @@ mkdir -p /opt/{babybuddy,data}
curl -fsSL "https://github.com/babybuddy/babybuddy/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
tar zxf "$temp_file" --strip-components=1 -C /opt/babybuddy
cd /opt/babybuddy
setup_uv
$STD uv venv /opt/babybuddy/.venv
$STD /opt/babybuddy/.venv/bin/python -m ensurepip --upgrade
$STD /opt/babybuddy/.venv/bin/python -m pip install --upgrade pip

View File

@ -19,8 +19,6 @@ $STD apt-get install -y \
p7zip-full
msg_ok "Installed Dependencies"
PYTHON_VERSION="3.12" setup_uv
msg_info "Setup Unrar"
cat <<EOF >/etc/apt/sources.list.d/non-free.list
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
@ -37,10 +35,8 @@ cd /opt/sabnzbd
temp_file=$(mktemp)
curl -fsSL "https://github.com/sabnzbd/sabnzbd/releases/download/${RELEASE}/SABnzbd-${RELEASE}-src.tar.gz" -o "$temp_file"
tar -xzf "$temp_file" -C /opt/sabnzbd --strip-components=1
$STD uv venv /opt/sabnzbd/.venv
$STD /opt/sabnzbd/.venv/bin/python -m ensurepip --upgrade
$STD /opt/sabnzbd/.venv/bin/python -m pip install --upgrade pip
$STD /opt/sabnzbd/.venv/bin/python -m pip install -r requirements.txt
setup_uv VENV_FOLDER="/opt/sabnzbd/.venv" REQUIREMENTS_FILE="requirements.txt" PYTHON_VERSION="3.12" setup_uv_venv
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
msg_ok "Installed SABnzbd"

View File

@ -1081,31 +1081,64 @@ function setup_uv() {
rm -rf "$TMP_DIR"
ensure_usr_local_bin_persist
msg_ok "uv $LATEST_VERSION installed"
}
# Optional: install specific Python version
if [[ -n "${PYTHON_VERSION:-}" ]]; then
$STD msg_info "Ensuring Python $PYTHON_VERSION is available via uv..."
# ------------------------------------------------------------------------------
# Creates a uv-based venv with optional Python version and installs dependencies
# ------------------------------------------------------------------------------
local VERSION_MATCH
VERSION_MATCH=$(uv python list --only-downloads |
grep -E "^cpython-${PYTHON_VERSION//./\\.}\.[0-9]+-linux" |
cut -d'-' -f2 | sort -V | tail -n1)
function setup_uv_venv() {
local VENV_FOLDER="${VENV_FOLDER:-/opt/app/.venv}"
local REQUIREMENTS_FILE="${REQUIREMENTS_FILE:-requirements.txt}"
local ENABLE_PIP_UPGRADE="${ENABLE_PIP_UPGRADE:-1}"
local ENABLE_ENSUREPIP="${ENABLE_ENSUREPIP:-1}"
if [[ -z "$VERSION_MATCH" ]]; then
msg_error "No matching Python $PYTHON_VERSION.x version found via uv"
# Fallback auf globale PYTHON_VERSION
local PYTHON_VERSION="${PYTHON_VERSION:-}"
setup_uv || return 1
# Wenn PYTHON_VERSION gesetzt, installiere gezielt
if [[ -n "$PYTHON_VERSION" ]]; then
export PYTHON_VERSION="$PYTHON_VERSION"
setup_uv || return 1
fi
$STD msg_info "Creating uv venv in $VENV_FOLDER"
if ! $STD uv venv "$VENV_FOLDER"; then
msg_error "Failed to create uv venv"
return 1
fi
local PYTHON="$VENV_FOLDER/bin/python"
if [[ "$ENABLE_ENSUREPIP" == "1" ]]; then
$STD msg_info "Running ensurepip"
if ! $STD "$PYTHON" -m ensurepip --upgrade; then
msg_error "ensurepip failed"
return 1
fi
fi
if uv python list | grep -q "cpython-${VERSION_MATCH}-linux.*uv/python"; then
$STD msg_ok "Python $VERSION_MATCH already installed via uv"
else
if ! $STD uv python install "$VERSION_MATCH"; then
msg_error "Failed to install Python $VERSION_MATCH via uv"
return 1
fi
msg_ok "Installed Python $VERSION_MATCH"
if [[ "$ENABLE_PIP_UPGRADE" == "1" ]]; then
$STD msg_info "Upgrading pip"
if ! $STD "$PYTHON" -m pip install --upgrade pip; then
msg_error "pip upgrade failed"
return 1
fi
fi
if [[ -f "$REQUIREMENTS_FILE" ]]; then
$STD msg_info "Installing requirements from $REQUIREMENTS_FILE"
if ! $STD "$PYTHON" -m pip install -r "$REQUIREMENTS_FILE"; then
msg_error "Failed to install requirements"
return 1
fi
else
msg_info "No requirements file found at $REQUIREMENTS_FILE skipping"
fi
msg_ok "uv venv setup complete in $VENV_FOLDER"
}
# ------------------------------------------------------------------------------