Re: [systemd-devel] Can I provide separate enabling for dbus-activation and "normal" start ?
On Fri, Feb 23, 2024 at 10:19:12AM +0100, Lennart Poettering wrote: > On Do, 22.02.24 17:09, Max Gautier (m...@max.gautier.name) wrote: > > > Is it possible when writing a dbus-activable service to provide two > > separate and independent ways to enable it ? > > > > The D-Bus service file would for instance be: > > [D-BUS Service] > > Name=org.freedesktop.Notifications > > Exec=notification-daemon > > SystemdService=dbus-org.freedesktop.Notifications.service > > > > The systemd service: > > [Unit] > > PartOf=graphical-session.target > > After=graphical-session.target > > > > [Service] > > Type=dbus > > BusName=org.freedesktop.Notifications > > ExecStart=notification-daemon > > > > [Install] > > Alias=dbus-org.freedesktop.Notifications.service > > WantedBy=graphical-session.target > > > > > > With that systemd service file, `systemctl enable` would cause the > > service to be started by graphical-session.target and by > > dbus-activation; but it is possible to have two separate enable > > commands, one which would enable the dbus activation, one the > > graphical-session start ? > > > > I suppose I should have two separate unit files but I'm not completely > > sure how to do that without copying the whole file (i.e, is there some > > Install/Unit relation I can use for that ?) > > No, in systemd there's only one "systemctl enable" and it applies the > [Install] section of the unit file, and that's really all there is. > > You can probably add two unit files and use Alias= so that they pick a > common name as alias. I guess I'll end up doing that. Thanks for the confirmation then > > But one unit cannot have two distinct [Install] sections, if that's > what you are looking for. > > Lennart > > -- > Lennart Poettering, Berlin -- Max Gautier
Re: [systemd-devel] Can I provide separate enabling for dbus-activation and "normal" start ?
On Do, 22.02.24 17:09, Max Gautier (m...@max.gautier.name) wrote: > Is it possible when writing a dbus-activable service to provide two > separate and independent ways to enable it ? > > The D-Bus service file would for instance be: > [D-BUS Service] > Name=org.freedesktop.Notifications > Exec=notification-daemon > SystemdService=dbus-org.freedesktop.Notifications.service > > The systemd service: > [Unit] > PartOf=graphical-session.target > After=graphical-session.target > > [Service] > Type=dbus > BusName=org.freedesktop.Notifications > ExecStart=notification-daemon > > [Install] > Alias=dbus-org.freedesktop.Notifications.service > WantedBy=graphical-session.target > > > With that systemd service file, `systemctl enable` would cause the > service to be started by graphical-session.target and by > dbus-activation; but it is possible to have two separate enable > commands, one which would enable the dbus activation, one the > graphical-session start ? > > I suppose I should have two separate unit files but I'm not completely > sure how to do that without copying the whole file (i.e, is there some > Install/Unit relation I can use for that ?) No, in systemd there's only one "systemctl enable" and it applies the [Install] section of the unit file, and that's really all there is. You can probably add two unit files and use Alias= so that they pick a common name as alias. But one unit cannot have two distinct [Install] sections, if that's what you are looking for. Lennart -- Lennart Poettering, Berlin
Re: [systemd-devel] Can I provide separate enabling for dbus-activation and "normal" start ?
On Thu, Feb 22, 2024 at 07:43:50PM +0300, Andrei Borzenkov wrote: > On 22.02.2024 19:09, Max Gautier wrote: > > Hi, > > > > Is it possible when writing a dbus-activable service to provide two > > separate and independent ways to enable it ? > > > > The D-Bus service file would for instance be: > > [D-BUS Service] > > Name=org.freedesktop.Notifications > > Exec=notification-daemon > > SystemdService=dbus-org.freedesktop.Notifications.service > > > > The systemd service: > > [Unit] > > PartOf=graphical-session.target > > After=graphical-session.target > > > > [Service] > > Type=dbus > > BusName=org.freedesktop.Notifications > > ExecStart=notification-daemon > > > > [Install] > > Alias=dbus-org.freedesktop.Notifications.service > > WantedBy=graphical-session.target > > > > > > With that systemd service file, `systemctl enable` would cause the > > service to be started by graphical-session.target and by > > dbus-activation; but it is possible to have two separate enable > > commands, one which would enable the dbus activation, one the > > graphical-session start ? > > > > You do not need any commands, just create corresponding links manually. I know that I can do that, but I'm trying to write a unit file which would avoid the need for users to do that. If there is no way, I'll just choose one and document the others "manual" enabling method, but if I can provide both, that'd be best. > > > I suppose I should have two separate unit files but I'm not completely > > sure how to do that without copying the whole file (i.e, is there some > > Install/Unit relation I can use for that ?) > > > > Thanks ! > > > -- Max Gautier
Re: [systemd-devel] Can I provide separate enabling for dbus-activation and "normal" start ?
On 22.02.2024 19:09, Max Gautier wrote: Hi, Is it possible when writing a dbus-activable service to provide two separate and independent ways to enable it ? The D-Bus service file would for instance be: [D-BUS Service] Name=org.freedesktop.Notifications Exec=notification-daemon SystemdService=dbus-org.freedesktop.Notifications.service The systemd service: [Unit] PartOf=graphical-session.target After=graphical-session.target [Service] Type=dbus BusName=org.freedesktop.Notifications ExecStart=notification-daemon [Install] Alias=dbus-org.freedesktop.Notifications.service WantedBy=graphical-session.target With that systemd service file, `systemctl enable` would cause the service to be started by graphical-session.target and by dbus-activation; but it is possible to have two separate enable commands, one which would enable the dbus activation, one the graphical-session start ? You do not need any commands, just create corresponding links manually. I suppose I should have two separate unit files but I'm not completely sure how to do that without copying the whole file (i.e, is there some Install/Unit relation I can use for that ?) Thanks !
[systemd-devel] Can I provide separate enabling for dbus-activation and "normal" start ?
Hi, Is it possible when writing a dbus-activable service to provide two separate and independent ways to enable it ? The D-Bus service file would for instance be: [D-BUS Service] Name=org.freedesktop.Notifications Exec=notification-daemon SystemdService=dbus-org.freedesktop.Notifications.service The systemd service: [Unit] PartOf=graphical-session.target After=graphical-session.target [Service] Type=dbus BusName=org.freedesktop.Notifications ExecStart=notification-daemon [Install] Alias=dbus-org.freedesktop.Notifications.service WantedBy=graphical-session.target With that systemd service file, `systemctl enable` would cause the service to be started by graphical-session.target and by dbus-activation; but it is possible to have two separate enable commands, one which would enable the dbus activation, one the graphical-session start ? I suppose I should have two separate unit files but I'm not completely sure how to do that without copying the whole file (i.e, is there some Install/Unit relation I can use for that ?) Thanks ! -- Max Gautier