Surely, there is a way. systemd
supports specifying so-called "ordering dependencies" between pairs of units which make systemd
follow a certain mutual ordering when these units happen to be activated/deactivated in a single transaction.
From systemd.unit(5):
Before=, After=
A space-separated list of unit names. Configures ordering dependencies between units. If a unit foo.service contains a setting Before=bar.service and both units are being started, bar.service's start-up is delayed until foo.service is started up. <...> Note that when two units with an ordering dependency between them are shut down, the inverse of the start-up order is applied. i.e. if a unit is configured with After= on another unit, the former is stopped before the latter if both are shut down. <...>
So, you want vmware.service
to be deactivated (stopped) before gdm.service
is stopped. Per the above, can be achieved by adding a After=gdm.service
ordering dependency to the vmware.service
unit.
In order to avoid copying the whole unit to /etc/systemd/system
, you may want to use the mechanism of drop-ins (see "example 2"). You need to create a file named /etc/systemd/system/vmware.service.d/<some name>.conf
with only the required directives and section headers:
[Unit]
After=gdm.service
After doing this, issue a systemctl daemon-reload
command to make systemd
re-read the units. On shutdown, the new dependency list should become effective.