nzbget service: fix preStart script and add more options to module
This commit is contained in:
parent
bbf5f02584
commit
44e1aabd02
|
@ -16,6 +16,20 @@ in {
|
||||||
description = "The NZBGet package to use";
|
description = "The NZBGet package to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dataDir = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "/var/lib/nzbget";
|
||||||
|
description = "The directory where NZBGet stores its configuration files.";
|
||||||
|
};
|
||||||
|
|
||||||
|
openFirewall = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Open ports in the firewall for the NZBGet web interface
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
user = mkOption {
|
user = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "nzbget";
|
default = "nzbget";
|
||||||
|
@ -40,7 +54,8 @@ in {
|
||||||
p7zip
|
p7zip
|
||||||
];
|
];
|
||||||
preStart = ''
|
preStart = ''
|
||||||
datadir=/var/lib/nzbget
|
datadir=${cfg.dataDir}
|
||||||
|
configfile=${cfg.dataDir}/nzbget.conf
|
||||||
cfgtemplate=${cfg.package}/share/nzbget/nzbget.conf
|
cfgtemplate=${cfg.package}/share/nzbget/nzbget.conf
|
||||||
test -d $datadir || {
|
test -d $datadir || {
|
||||||
echo "Creating nzbget data directory in $datadir"
|
echo "Creating nzbget data directory in $datadir"
|
||||||
|
@ -60,7 +75,7 @@ in {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
configfile=/var/lib/nzbget/nzbget.conf
|
configfile=${cfg.dataDir}/nzbget.conf
|
||||||
args="--daemon --configfile $configfile"
|
args="--daemon --configfile $configfile"
|
||||||
# The script in preStart (above) copies nzbget's config template to datadir on first run, containing paths that point to the nzbget derivation installed at the time.
|
# The script in preStart (above) copies nzbget's config template to datadir on first run, containing paths that point to the nzbget derivation installed at the time.
|
||||||
# These paths break when nzbget is upgraded & the original derivation is garbage collected. If such broken paths are found in the config file, override them to point to
|
# These paths break when nzbget is upgraded & the original derivation is garbage collected. If such broken paths are found in the config file, override them to point to
|
||||||
|
@ -86,6 +101,10 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
networking.firewall = mkIf cfg.openFirewall {
|
||||||
|
allowedTCPPorts = [ 8989 ];
|
||||||
|
};
|
||||||
|
|
||||||
users.users = mkIf (cfg.user == "nzbget") {
|
users.users = mkIf (cfg.user == "nzbget") {
|
||||||
nzbget = {
|
nzbget = {
|
||||||
group = cfg.group;
|
group = cfg.group;
|
||||||
|
|
Loading…
Reference in New Issue