nzbgetcom / nzbget

Efficient usenet downloader
https://nzbget.com
GNU General Public License v2.0
308 stars 16 forks source link

Better config locations #239

Open dnzbk opened 5 months ago

dnzbk commented 5 months ago

Is there already an issue for this request?

Platform

POSIX

Describe the enhancement you'd like

Needs to revise the default locations where nzbget.conf should be located. The documentation, CMake and autotools configurations should also be updated. The problem was raised by @Anuskuss in PR and thanks to him for that.

Extra information

No response

Anuskuss commented 5 months ago

Hopefully ~/.config/nzbget.conf makes it in time for v24.0.

Anuskuss commented 5 months ago

Hopefully ~/.config/nzbget.conf makes it in time for v24.0.

Well, guess not :shrug:

Anyway, I saw that you guys have a repo now but what's the deal with the systemd service?

[Unit]
Description=NZBGet Daemon
Documentation=http://nzbget.com/documentation/                                                 # no https?
After=network.target

[Service]
Type=simple                                                                                    # why not forking like it used to be?
User=nzbget
Group=nzbget
WorkingDirectory=/var/lib/nzbget
ExecStart=/usr/bin/nzbget -s -c /var/lib/nzbget/nzbget.conf -o OutputMode=log -o WriteLog=none # hardcoded config, defaults to server mode instead of daemon mode
ExecReload=/usr/bin/nzbget -O -c /var/lib/nzbget/nzbget.conf
ExecStop=/usr/bin/nzbget -Q -c /var/lib/nzbget/nzbget.conf
Restart=on-failure                                                                             # missing KillMode=process (maybe not needed?)

[Install]
WantedBy=multi-user.target

I guess /var/lib/nzbget is needed now that it's started as user nzbget but there's no reason to hardcode the config path (just add it to PossibleConfigLocations).

Personally I use the old community-created service with my own edits which looks like this:

### Editing /etc/systemd/system/nzbget.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file

[Unit]
RequiresMountsFor=/media/Downloads

[Service]
User=user
Group=user
Nice=+10

### Lines below this comment will be discarded

### /etc/systemd/system/nzbget.service
# [Unit]
# Description=NZBGet Daemon
# Documentation=http://nzbget.net/Documentation
# After=network.target
# 
# [Service]
# User=nzbget
# Group=nzbget
# Type=forking
# ExecStart=/usr/bin/nzbget -D
# ExecStop=/usr/bin/nzbget -Q
# ExecReload=/usr/bin/nzbget -O
# KillMode=process
# Restart=on-failure
# 
# [Install]
# WantedBy=multi-user.target

(I know that RequiredDir exists in nzbget.conf but the service option works better in my setup).

phnzb commented 5 months ago

@Anuskuss nzbget systemd unit is intended to be used with deb/rpm packages, which runs nzbget as a foreground service with internal nzbget logging disabled to forward all logs to journalctl. As for hardcoded config location - nzbget systemd service runs as separate user for security reasons and in my opinion adding /var/lib/nzbget to PossibleConfigLocations is a bad idea, because it can leads to running nzbget from another user and owner/permissions issues on /var/lib/nzbget homedir. In future, we can change this behavior to be more complex (add variables override from systemd defaults file or more options).