Merge pull request #281000 from cablespaghetti/master
sabnzbd: Add configurability of state directory owner and firewall
This commit is contained in:
commit
d1e2847664
1 changed files with 23 additions and 11 deletions
|
@ -36,6 +36,14 @@ in
|
||||||
default = "sabnzbd";
|
default = "sabnzbd";
|
||||||
description = lib.mdDoc "Group to run the service as";
|
description = lib.mdDoc "Group to run the service as";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
openFirewall = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Open ports in the firewall for the sabnzbd web interface
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,17 +51,16 @@ in
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
users.users = mkIf (cfg.user == "sabnzbd") {
|
||||||
users.users.sabnzbd = {
|
sabnzbd = {
|
||||||
uid = config.ids.uids.sabnzbd;
|
uid = config.ids.uids.sabnzbd;
|
||||||
group = "sabnzbd";
|
group = cfg.group;
|
||||||
description = "sabnzbd user";
|
description = "sabnzbd user";
|
||||||
home = "/var/lib/sabnzbd/";
|
};
|
||||||
createHome = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
users.groups.sabnzbd = {
|
users.groups = mkIf (cfg.group == "sabnzbd") {
|
||||||
gid = config.ids.gids.sabnzbd;
|
sabnzbd.gid = config.ids.gids.sabnzbd;
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.sabnzbd = {
|
systemd.services.sabnzbd = {
|
||||||
|
@ -63,10 +70,15 @@ in
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "forking";
|
Type = "forking";
|
||||||
GuessMainPID = "no";
|
GuessMainPID = "no";
|
||||||
User = "${cfg.user}";
|
User = cfg.user;
|
||||||
Group = "${cfg.group}";
|
Group = cfg.group;
|
||||||
|
StateDirectory = "sabnzbd";
|
||||||
ExecStart = "${lib.getBin cfg.package}/bin/sabnzbd -d -f ${cfg.configFile}";
|
ExecStart = "${lib.getBin cfg.package}/bin/sabnzbd -d -f ${cfg.configFile}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
networking.firewall = mkIf cfg.openFirewall {
|
||||||
|
allowedTCPPorts = [ 8080 ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue