[PR #1318] [MERGED] systemd units for the client, management & signal services #13495

Closed
opened 2026-08-05 02:08:36 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/1318
Author: @hg
Created: 11/17/2023
Status: Merged
Merged: 11/23/2023
Merged by: @mlsmaycon

Base: mainHead: main


📝 Commits (1)

📊 Changes

4 files changed (+126 additions, -0 deletions)

View changed files

release_files/systemd/env (+3 -0)
release_files/systemd/netbird-management.service (+41 -0)
release_files/systemd/netbird-signal.service (+41 -0)
release_files/systemd/netbird@.service (+41 -0)

📄 Description

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

Continuing from #1316.

install & upgrade

I did not change install.sh yet as this PR uses a templated systemd unit for the client, and thus install.sh will need a bit of work to make it safely migrate old clients. I'd like to know first if you want this at all.

logging

Logs get written to the console where they get picked up by journald, since this is where you would typically expect to see them on a systemd-based Linux distribution. Users get automatic compression and log rotation for free.

It's trivial to make each client use a separate log file if you'd rather keep using text logs, though.

sanbox

Sandbox flags are quite conservative: they mostly deny access to home directories and things netbird shouldn't have to worry about (like changing mount points).

It isn't difficult to make all daemons appear to work with a non-root user and somewhat limited privileges (with CAP_NET_ADMIN), but I am not sure that it doesn't introduce some subtle breakage somewhere. It would probably make a bad default for now.

customization

env should be copied into /etc/default/netbird{,-management,-signal} and is the same for all three. It's there to allow the user to pass additional configuration flags without overriding the unit.

directories

These directives:

RuntimeDirectory=netbird
StateDirectory=netbird
LogDirectory=netbird
ConfigurationDirectory=netbird

create /etc/netbird and /var/{log,lib,run}/netbird (if necessary), make sure the daemon can access them, and only then start the daemon. This will prevent problems such as #1079 for those users who prefer and configure text logs. If someday netbird is made to run under a restricted user, you won't have to chown -R them in upgrade scripts since systemd will do it for you.

What do you think?


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/1318 **Author:** [@hg](https://github.com/hg) **Created:** 11/17/2023 **Status:** ✅ Merged **Merged:** 11/23/2023 **Merged by:** [@mlsmaycon](https://github.com/mlsmaycon) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`dd1df3e`](https://github.com/netbirdio/netbird/commit/dd1df3efcc8d7be69968c77254ef4517c46f016d) Add systemd .service files (#1316) ### 📊 Changes **4 files changed** (+126 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `release_files/systemd/env` (+3 -0) ➕ `release_files/systemd/netbird-management.service` (+41 -0) ➕ `release_files/systemd/netbird-signal.service` (+41 -0) ➕ `release_files/systemd/netbird@.service` (+41 -0) </details> ### 📄 Description ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary --- Continuing from #1316. ### install & upgrade I did not change `install.sh` yet as this PR uses a templated systemd unit for the client, and thus `install.sh` will need a bit of work to make it safely migrate old clients. I'd like to know first if you want this at all. ### logging Logs get written to the console where they get picked up by journald, since this is where you would typically expect to see them on a systemd-based Linux distribution. Users get automatic compression and log rotation for free. It's trivial to make each client use a separate log file if you'd rather keep using text logs, though. ### sanbox Sandbox flags are quite conservative: they mostly deny access to home directories and things netbird shouldn't have to worry about (like changing mount points). It isn't difficult to make all daemons *appear* to work with a non-root user and somewhat limited privileges (with `CAP_NET_ADMIN`), but I am not sure that it doesn't introduce some subtle breakage somewhere. It would probably make a bad default for now. ### customization `env` should be copied into `/etc/default/netbird{,-management,-signal}` and is the same for all three. It's there to allow the user to pass additional configuration flags without overriding the unit. ### directories These directives: ```ini RuntimeDirectory=netbird StateDirectory=netbird LogDirectory=netbird ConfigurationDirectory=netbird ``` create `/etc/netbird` and `/var/{log,lib,run}/netbird` (if necessary), make sure the daemon can access them, and only then start the daemon. This will prevent problems such as #1079 for those users who prefer and configure text logs. If someday netbird is made to run under a restricted user, you won't have to `chown -R` them in upgrade scripts since systemd will do it for you. What do you think? --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 02:08:36 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#13495