You can also use ConditionKernelVersion like so /etc/systemd/system/{vboxadd,vboxadd-service}.service.d/kerver.conf ------------------------------------------------- [Unit] ConditionKernelVersion=<4.15 Giacomo Longo 2018-02-11 13:47 GMT+01:00 Giacomo Longo <gabibbo97@gmail.com>:
So you want to have
vboxadd-service and vboxadd systemd services not starting on Linux kernel versions 4.15 and above?
You can manage this by creating a template systemd unit
/etc/systemd/system/kernel-version-less-then@.service ----------------------------------- [Unit] Description=Check if currently installed kernel version is less than target
[Service] Type=oneshot ExecStart=/usr/bin/sh -c '[[ "$(/usr/bin/vercmp %i %v)" = "1" ]]' Restart=no CollectMode=inactive-or-failed
[Install] WantedBy=multi-user.target
Then create the directories
/etc/systemd/system/vboxadd.service.d/ /etc/systemd/system/vboxadd-service.service.d/
Then for each service
/etc/systemd/system/vboxadd.service.d/kerver.conf ------------------------------------------------- [Unit] After=kernel-version-less-then@4.15.service Requires=kernel-version-less-then@4.15.service
/etc/systemd/system/vboxadd-service.service.d/kerver.conf --------------------------------------------------------- [Unit] After=kernel-version-less-then@4.15.service Requires=kernel-version-less-then@4.15.service
In this way, if my bash-fu is correct, the version compare will fail the kernel-version-less-then@4.15.service and vboxadd and vboxadd-service will not start
Giacomo Longo