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?

2

Systemd doesn't support overriding the [Install] section with drop-in files. 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.

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.