2

I have a unit file and I want to modify some of the properties. I've been able to extend all the properties using the /etc/systemd/system/unitname.service.d/ directory but cannot get the WantedBy property to be extended.

Original Unit File (deluged.service)

[Unit]
Description=Deluge Bittorrent Client Daemon
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=media
Group=media
ExecStart=/usr/local/bin/deluged -d -u 0.0.0.0

[Install]
WantedBy=multi-user.target

/etc/systemd/system/deluged.service.d/override.conf

[Unit]
BindTo=sys-subsystem-net-devices-tun0.device
After=sys-subsystem-net-devices-tun0.device

[Service]
ExecStart=
ExecStart=/usr/local/bin/deluged -d -i 10.10.10.1 -u 0.0.0.0

[Install]
WantedBy=
WantedBy=sys-subsystem-net-devices-tun0.device

Everything appears to work correctly except for WantedBy when I run systemctl enable deluged it still created the symlink in multi-user and no link is created in the new location.

I've searched for documentation on extending/overriding and I haven't seen anything talking about WantedBy so I have no idea if it's even possible to extend it. Am I doing something wrong or is it just not possible?

vane
  • 155
  • 1
  • 2
  • 9

2 Answers2

2

Older systemd releases don't support overriding the [Install] section with drop-in files. With those you need to create a replacement file for this service, instead.

Similarly, the Conflicts= key in the [Unit] section can't be overridden in a drop-in file, either.


Systemd removed that limitation in the end of 2017, thus, versions released after that aren't affected.

maxschlepzig
  • 895
  • 7
  • 16
2

I'm currently using Systemd 237 and it seems take into account [install] section overrides.

At least links are created according to my drop-in file.

/usr/lib/systemd/user/syncthing.service

[Unit]
Description=Syncthing - Open Source Continuous File Synchronization
Documentation=man:syncthing(1)

[Service]
ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0
Restart=on-failure
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

# Hardening
SystemCallArchitectures=native
MemoryDenyWriteExecute=true
NoNewPrivileges=true

[Install]
WantedBy=default.target

/home/abe/.config/systemd/user/syncthing.service.d/override.conf

[Install]
WantedBy=
WantedBy=multi-user.target

systemctl --user enable syncthing.service

Created symlink /home/abe/.config/systemd/user/multi-user.target.wants/syncthing.service → /usr/lib/systemd/user/syncthing.service.
abePdIta
  • 21
  • 2