testing uv
This commit is contained in:
parent
1501c3a514
commit
7c34f953ab
80
ct/sabnzbd.sh
Normal file
80
ct/sabnzbd.sh
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
|
||||||
|
# Copyright (c) 2021-2025 tteck
|
||||||
|
# Author: tteck (tteckster)
|
||||||
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
|
# Source: https://sabnzbd.org/
|
||||||
|
|
||||||
|
APP="SABnzbd"
|
||||||
|
var_tags="${var_tags:-downloader}"
|
||||||
|
var_cpu="${var_cpu:-2}"
|
||||||
|
var_ram="${var_ram:-4096}"
|
||||||
|
var_disk="${var_disk:-8}"
|
||||||
|
var_os="${var_os:-debian}"
|
||||||
|
var_version="${var_version:-12}"
|
||||||
|
var_unprivileged="${var_unprivileged:-1}"
|
||||||
|
|
||||||
|
header_info "$APP"
|
||||||
|
variables
|
||||||
|
color
|
||||||
|
catch_errors
|
||||||
|
|
||||||
|
function update_script() {
|
||||||
|
header_info
|
||||||
|
check_container_storage
|
||||||
|
check_container_resources
|
||||||
|
|
||||||
|
if [[ ! -d /opt/sabnzbd ]]; then
|
||||||
|
msg_error "No ${APP} Installation Found!"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
RELEASE=$(curl -fsSL https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
||||||
|
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" = "$(cat /opt/${APP}_version.txt)" ]]; then
|
||||||
|
msg_ok "No update required. ${APP} is already at ${RELEASE}"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
msg_info "Updating $APP to ${RELEASE}"
|
||||||
|
systemctl stop sabnzbd
|
||||||
|
cp -r /opt/sabnzbd /opt/sabnzbd_backup_$(date +%s)
|
||||||
|
|
||||||
|
tmpdir=$(mktemp -d)
|
||||||
|
curl -fsSL "https://github.com/sabnzbd/sabnzbd/releases/download/${RELEASE}/SABnzbd-${RELEASE}-src.tar.gz" | tar -xz -C "$tmpdir"
|
||||||
|
cp -rf "${tmpdir}/SABnzbd-${RELEASE}/"* /opt/sabnzbd/
|
||||||
|
rm -rf "$tmpdir"
|
||||||
|
|
||||||
|
if [[ ! -d /opt/sabnzbd/venv ]]; then
|
||||||
|
msg_info "Migrating SABnzbd to venv installation"
|
||||||
|
$STD python3 -m venv /opt/sabnzbd/venv
|
||||||
|
source /opt/sabnzbd/venv/bin/activate
|
||||||
|
$STD pip install --upgrade pip
|
||||||
|
if [[ -f /opt/sabnzbd/requirements.txt ]]; then
|
||||||
|
$STD pip install -r /opt/sabnzbd/requirements.txt
|
||||||
|
fi
|
||||||
|
deactivate
|
||||||
|
|
||||||
|
if grep -q "ExecStart=python3 SABnzbd.py" /etc/systemd/system/sabnzbd.service; then
|
||||||
|
sed -i "s|ExecStart=python3 SABnzbd.py|ExecStart=/opt/sabnzbd/venv/bin/python SABnzbd.py|" /etc/systemd/system/sabnzbd.service
|
||||||
|
systemctl daemon-reload
|
||||||
|
msg_ok "Migrated SABnzbd to venv installation and updated Service"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
source /opt/sabnzbd/venv/bin/activate
|
||||||
|
$STD pip install --upgrade pip
|
||||||
|
$STD pip install -r /opt/sabnzbd/requirements.txt
|
||||||
|
deactivate
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||||
|
systemctl start sabnzbd
|
||||||
|
msg_ok "Updated ${APP} to ${RELEASE}"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
start
|
||||||
|
build_container
|
||||||
|
description
|
||||||
|
|
||||||
|
msg_ok "Completed Successfully!\n"
|
||||||
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||||
|
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
||||||
|
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:7777${CL}"
|
82
install/sabnzbd-install.sh
Normal file
82
install/sabnzbd-install.sh
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright (c) 2021-2025 tteck
|
||||||
|
# Author: tteck (tteckster)
|
||||||
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
|
# Source: https://sabnzbd.org/
|
||||||
|
|
||||||
|
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
||||||
|
color
|
||||||
|
verb_ip6
|
||||||
|
catch_errors
|
||||||
|
setting_up_container
|
||||||
|
network_check
|
||||||
|
update_os
|
||||||
|
|
||||||
|
msg_info "Installing Dependencies"
|
||||||
|
$STD apt-get install -y \
|
||||||
|
par2 \
|
||||||
|
p7zip-full
|
||||||
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
|
msg_info "Setup Python3"
|
||||||
|
$STD apt-get install -y \
|
||||||
|
python3-dev \
|
||||||
|
python3-pip \
|
||||||
|
python3-venv \
|
||||||
|
python3-setuptools
|
||||||
|
msg_ok "Setup Python3"
|
||||||
|
|
||||||
|
msg_info "Setup uv"
|
||||||
|
setup_uv
|
||||||
|
msg_ok "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
|
||||||
|
EOF
|
||||||
|
$STD apt-get update
|
||||||
|
$STD apt-get install -y unrar
|
||||||
|
rm /etc/apt/sources.list.d/non-free.list
|
||||||
|
msg_ok "Setup Unrar"
|
||||||
|
|
||||||
|
msg_info "Installing SABnzbd"
|
||||||
|
RELEASE=$(curl -fsSL https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
||||||
|
$STD tar zxvf <(curl -fsSL https://github.com/sabnzbd/sabnzbd/releases/download/$RELEASE/SABnzbd-${RELEASE}-src.tar.gz)
|
||||||
|
mv SABnzbd-${RELEASE} /opt/sabnzbd
|
||||||
|
uv venv /opt/sabnzbd
|
||||||
|
uv pip install -r /opt/sabnzbd/requirements.txt
|
||||||
|
# $STD python3 -m venv /opt/sabnzbd/venv
|
||||||
|
# source /opt/sabnzbd/venv/bin/activate
|
||||||
|
# $STD pip install --upgrade pip
|
||||||
|
# $STD pip install -r /opt/sabnzbd/requirements.txt
|
||||||
|
# deactivate
|
||||||
|
|
||||||
|
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
|
||||||
|
msg_ok "Installed SABnzbd"
|
||||||
|
|
||||||
|
msg_info "Creating Service"
|
||||||
|
cat <<EOF >/etc/systemd/system/sabnzbd.service
|
||||||
|
[Unit]
|
||||||
|
Description=SABnzbd
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
WorkingDirectory=/opt/sabnzbd
|
||||||
|
ExecStart=/opt/sabnzbd/venv/bin/python SABnzbd.py -s 0.0.0.0:7777
|
||||||
|
Restart=always
|
||||||
|
User=root
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
systemctl enable -q --now sabnzbd
|
||||||
|
msg_ok "Created Service"
|
||||||
|
|
||||||
|
motd_ssh
|
||||||
|
customize
|
||||||
|
|
||||||
|
msg_info "Cleaning up"
|
||||||
|
$STD apt-get -y autoremove
|
||||||
|
$STD apt-get -y autoclean
|
||||||
|
msg_ok "Cleaned"
|
@ -784,3 +784,51 @@ function download_with_progress() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setup_uv() {
|
||||||
|
msg_info "Checking uv installation..."
|
||||||
|
|
||||||
|
UV_BIN="/usr/local/bin/uv"
|
||||||
|
TMP_DIR=$(mktemp -d)
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
|
||||||
|
if [[ "$ARCH" == "x86_64" ]]; then
|
||||||
|
UV_TAR="uv-x86_64-unknown-linux-gnu.tar.gz"
|
||||||
|
elif [[ "$ARCH" == "aarch64" ]]; then
|
||||||
|
UV_TAR="uv-aarch64-unknown-linux-gnu.tar.gz"
|
||||||
|
else
|
||||||
|
msg_error "Unsupported architecture: $ARCH"
|
||||||
|
rm -rf "$TMP_DIR"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get current github version
|
||||||
|
LATEST_VERSION=$(curl -s https://api.github.com/repos/astral-sh/uv/releases/latest | grep '"tag_name":' | cut -d '"' -f4 | sed 's/^v//')
|
||||||
|
if [[ -z "$LATEST_VERSION" ]]; then
|
||||||
|
msg_error "Could not fetch latest uv version from GitHub."
|
||||||
|
rm -rf "$TMP_DIR"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if uv exists
|
||||||
|
if [[ -x "$UV_BIN" ]]; then
|
||||||
|
INSTALLED_VERSION=$($UV_BIN -V | awk '{print $2}')
|
||||||
|
if [[ "$INSTALLED_VERSION" == "$LATEST_VERSION" ]]; then
|
||||||
|
msg_ok "uv is already at the latest version ($INSTALLED_VERSION)"
|
||||||
|
rm -rf "$TMP_DIR"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
msg_info "Updating uv from $INSTALLED_VERSION to $LATEST_VERSION"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
msg_info "uv not found. Installing version $LATEST_VERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# install or update uv
|
||||||
|
curl -fsSL "https://github.com/astral-sh/uv/releases/latest/download/${UV_TAR}" -o "$TMP_DIR/uv.tar.gz"
|
||||||
|
tar -xzf "$TMP_DIR/uv.tar.gz" -C "$TMP_DIR"
|
||||||
|
install -m 755 "$TMP_DIR"/*/uv "$UV_BIN"
|
||||||
|
rm -rf "$TMP_DIR"
|
||||||
|
|
||||||
|
msg_ok "uv installed/updated to $LATEST_VERSION"
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user