fix(usenet): use host port 8085, read USENET_* env vars in configure_sabnzbd, and verify Docker E2E

This commit is contained in:
soulis-1256 2026-11-21 23:29:53 +02:00
parent 079c2df6b6
commit fe62acb79e
No known key found for this signature in database
2 changed files with 34 additions and 15 deletions

View file

@ -8,7 +8,7 @@ if [ -n "${_ASSEMBLRR_USENET_SOURCED:-}" ]; then
fi
readonly _ASSEMBLRR_USENET_SOURCED=1
SABNZBD_PORT="${SABNZBD_PORT:-8080}"
SABNZBD_PORT="${SABNZBD_PORT:-8085}"
sabnzbd_enabled() {
case "${USENET_ENABLED:-n}" in
@ -87,14 +87,14 @@ priority = 0
[[movies]]
name = movies
order = 1
dir = movies
dir = /data/usenet/complete/movies
pp = 3
script = Default
priority = -100
[[tv]]
name = tv
order = 2
dir = tv
dir = /data/usenet/complete/tv
pp = 3
script = Default
priority = -100
@ -122,7 +122,12 @@ _sab_set_category() {
local apikey="$1"
local name="$2"
local dir="$3"
http_request GET "http://${API_HOST}:${SABNZBD_PORT}/api?mode=set_config&section=categories&name=${name}&dir=${dir}&pp=3&output=json&apikey=${apikey}"
local enc_dir
case "$dir" in
/*) enc_dir=$(urlencode "$dir") ;;
*) enc_dir=$(urlencode "/data/usenet/complete/${dir}") ;;
esac
http_request GET "http://${API_HOST}:${SABNZBD_PORT}/api?mode=set_config&section=categories&name=${name}&dir=${enc_dir}&pp=3&output=json&apikey=${apikey}"
}
_sab_set_server() {
@ -132,12 +137,13 @@ _sab_set_server() {
local ssl="$4"
local user="$5"
local pass="$6"
local conn="${7:-8}"
local enc_host enc_user enc_pass
enc_host=$(urlencode "$host")
enc_user=$(urlencode "$user")
enc_pass=$(urlencode "$pass")
http_request GET \
"http://${API_HOST}:${SABNZBD_PORT}/api?mode=set_config&section=servers&name=${enc_host}&host=${enc_host}&port=${port}&ssl=${ssl}&username=${enc_user}&password=${enc_pass}&connections=8&enable=1&output=json&apikey=${apikey}"
"http://${API_HOST}:${SABNZBD_PORT}/api?mode=set_config&section=servers&name=${enc_host}&host=${enc_host}&port=${port}&ssl=${ssl}&username=${enc_user}&password=${enc_pass}&connections=${conn}&enable=1&output=json&apikey=${apikey}"
}
configure_sabnzbd() {
@ -163,16 +169,26 @@ configure_sabnzbd() {
_sab_set_category "$sab_key" "movies" "movies" || true
_sab_set_category "$sab_key" "tv" "tv" || true
# Optional Usenet NNTP server credentials stored in secrets/usenet_*.txt
local nntp_host="" nntp_port="563" nntp_ssl="1" nntp_user="" nntp_pass=""
[ -s "$INSTALL_DIR/secrets/usenet_host.txt" ] && nntp_host=$(tr -d '\r\n' < "$INSTALL_DIR/secrets/usenet_host.txt")
# Usenet NNTP server settings from .assemblrr-config env vars or secrets/usenet_*.txt
local nntp_host="${USENET_HOST:-}"
local nntp_port="${USENET_PORT:-563}"
local nntp_ssl="${USENET_SSL:-1}"
local nntp_user="${USENET_USERNAME:-}"
local nntp_pass="${USENET_PASSWORD:-}"
local nntp_conn="${USENET_CONNECTIONS:-8}"
[ -z "$nntp_host" ] && [ -s "$INSTALL_DIR/secrets/usenet_host.txt" ] && nntp_host=$(tr -d '\r\n' < "$INSTALL_DIR/secrets/usenet_host.txt")
[ -s "$INSTALL_DIR/secrets/usenet_port.txt" ] && nntp_port=$(tr -d '\r\n' < "$INSTALL_DIR/secrets/usenet_port.txt")
[ -s "$INSTALL_DIR/secrets/usenet_ssl.txt" ] && nntp_ssl=$(tr -d '\r\n' < "$INSTALL_DIR/secrets/usenet_ssl.txt")
[ -s "$INSTALL_DIR/secrets/usenet_user.txt" ] && nntp_user=$(tr -d '\r\n' < "$INSTALL_DIR/secrets/usenet_user.txt")
[ -s "$INSTALL_DIR/secrets/usenet_password.txt" ] && nntp_pass=$(tr -d '\r\n' < "$INSTALL_DIR/secrets/usenet_password.txt")
[ -z "$nntp_user" ] && [ -s "$INSTALL_DIR/secrets/usenet_user.txt" ] && nntp_user=$(tr -d '\r\n' < "$INSTALL_DIR/secrets/usenet_user.txt")
[ -z "$nntp_pass" ] && [ -s "$INSTALL_DIR/secrets/usenet_password.txt" ] && nntp_pass=$(tr -d '\r\n' < "$INSTALL_DIR/secrets/usenet_password.txt")
case "${nntp_ssl,,}" in
1|y|yes|true) nntp_ssl="1" ;;
*) nntp_ssl="0" ;;
esac
if [ -n "$nntp_host" ]; then
if _sab_set_server "$sab_key" "$nntp_host" "$nntp_port" "$nntp_ssl" "$nntp_user" "$nntp_pass"; then
if _sab_set_server "$sab_key" "$nntp_host" "$nntp_port" "$nntp_ssl" "$nntp_user" "$nntp_pass" "$nntp_conn"; then
log_step "SABnzbd: wired NNTP server (${nntp_host}:${nntp_port})"
else
log_step_fail "SABnzbd: failed to configure NNTP server (${nntp_host})"

View file

@ -28,7 +28,7 @@ cleanup() {
}
trap cleanup EXIT INT TERM
mkdir -p "$tmp/config" "$tmp/data/usenet/incomplete" "$tmp/data/usenet/complete/movies" "$tmp/data/usenet/complete/tv"
mkdir -p "$tmp/config/sabnzbd" "$tmp/data/usenet/incomplete" "$tmp/data/usenet/complete/movies" "$tmp/data/usenet/complete/tv"
python3 "$REPO_ROOT/tests/fixtures/mock_nntp.py" --host 0.0.0.0 --port 0 --user mockuser --password mockpass --port-file "$tmp/nntp.port" &
nntp_pid=$!
@ -45,7 +45,7 @@ echo "Started mock NNTP :${nntp_port} and mock Newznab :${newznab_port}"
cid=$(docker run -d --network host \
-e "PUID=$(id -u)" -e "PGID=$(id -g)" -e "TZ=UTC" \
-v "$tmp/config:/config" \
-v "$tmp/config/sabnzbd:/config" \
-v "$tmp/data:/data" \
lscr.io/linuxserver/sabnzbd:5.1.3)
@ -56,6 +56,9 @@ source "$REPO_ROOT/lib/api.sh"
# shellcheck source=/dev/null
source "$REPO_ROOT/lib/usenet.sh"
log_step() { echo " ✓ $1"; }
log_step_fail() { echo " ✗ $1" >&2; }
INSTALL_DIR="$tmp"
USENET_ENABLED="y"
USENET_HOST="127.0.0.1"
@ -94,7 +97,7 @@ for _ in $(seq 1 30); do
done
[ "$ok" -eq 1 ] || { echo "Mock NZB did not complete in SABnzbd" >&2; exit 1; }
found=$(find "$tmp/data/usenet/complete" -name "assemblrr-sample.txt" 2>/dev/null | head -1 || true)
found=$(find "$tmp/data/usenet/complete" -type f \( -name "assemblrr-sample.txt" -o -name "sample.txt" \) 2>/dev/null | head -1 || true)
[ -n "$found" ] || { echo "Decoded file missing under $tmp/data/usenet/complete" >&2; exit 1; }
grep -qx "assemblrr mock usenet payload ok" "$found"
echo "STATUS: OK (SABnzbd downloaded & yEnc-decoded mock NZB from mock_nntp.py)"
echo "STATUS: OK (SABnzbd downloaded & yEnc-decoded mock NZB from mock_nntp.py -> $found)"