From 955524f4892ccff4e7495ef38afee4f60812b013 Mon Sep 17 00:00:00 2001 From: rope Date: Mon, 4 May 2026 02:40:44 -0700 Subject: [PATCH] Update services/sabnzbd.nix --- services/sabnzbd.nix | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/services/sabnzbd.nix b/services/sabnzbd.nix index 084643f..cb173a3 100644 --- a/services/sabnzbd.nix +++ b/services/sabnzbd.nix @@ -9,22 +9,11 @@ let exit 0 fi - ${pkgs.python3}/bin/python3 - <<'EOF' -import configparser, os, sys -config_file = '/var/lib/sabnzbd/sabnzbd.ini' -hostname = 'sabnzbd.nordhammer.it' -c = configparser.RawConfigParser() -c.read(config_file) -if not c.has_section('misc'): - c.add_section('misc') -wl = c.get('misc', 'host_whitelist', fallback="") -entries = [h.strip() for h in wl.split(',') if h.strip()] -if hostname not in entries: - entries.append(hostname) - c.set('misc', 'host_whitelist', ','.join(entries)) - with open(config_file, 'w') as f: - c.write(f) -EOF + if ${pkgs.gnugrep}/bin/grep -q "^host_whitelist" "$CONFIG"; then + ${pkgs.gnused}/bin/sed -i "s/^host_whitelist =.*/host_whitelist = $HOSTNAME/" "$CONFIG" + else + ${pkgs.gnused}/bin/sed -i "/^\[misc\]/a host_whitelist = $HOSTNAME" "$CONFIG" + fi ''; in {