Update services/sabnzbd.nix
This commit is contained in:
parent
30d9d836e4
commit
955524f489
1 changed files with 5 additions and 16 deletions
|
|
@ -9,22 +9,11 @@ let
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${pkgs.python3}/bin/python3 - <<'EOF'
|
if ${pkgs.gnugrep}/bin/grep -q "^host_whitelist" "$CONFIG"; then
|
||||||
import configparser, os, sys
|
${pkgs.gnused}/bin/sed -i "s/^host_whitelist =.*/host_whitelist = $HOSTNAME/" "$CONFIG"
|
||||||
config_file = '/var/lib/sabnzbd/sabnzbd.ini'
|
else
|
||||||
hostname = 'sabnzbd.nordhammer.it'
|
${pkgs.gnused}/bin/sed -i "/^\[misc\]/a host_whitelist = $HOSTNAME" "$CONFIG"
|
||||||
c = configparser.RawConfigParser()
|
fi
|
||||||
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
|
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue