[systemd-devel] Recommendation for "systemd.module" unit

Peeters Simon peeters.simon at gmail.com
Thu Jan 24 14:53:43 PST 2013


2013/1/24 Larry Baker <baker at usgs.gov>:
>...
> Then it looks for evidence that the decnet kernel module is loaded by
> testing for the file /proc/net/decnet.  If necessary, it loads the decnet
> kernel module and checks again for /proc/net/decnet.  I have already built
> the decnet kernel module and I can load it with modprobe.  I do not wish to
> force an unconditional load of the decnet kernel module using
> /etc/modules-load.d/decnet.conf; I prefer the services that need it (dnetd
> and phoned) trigger the load.  However, I find no mention of the standard
> systemd "load a kernel module" practice.  I.e., there is no "systemd.module"
> unit.  What is the recommended method in the systemd framework to trigger a
> unit that loads a kernel module?  If the modprobe command fails, I presume
> that will cause the systemd start command to fail.  I would also like the
> systemd start command to fail if /proc/net/decnet is not created (a sign
> that the module has not initialized itself correctly).  Is there a syntax in
> a systemd unit for that as well?

I know this might not be the cleanest solution, but you could use

ExecStartPre=/sbin/modprobe decnet
ExecStartPre=/bin/test -e /proc/net/decnet

in the decnet service file or create a modprobe at .service doing the modprobeing
and make the decnet.service file like

[Unit]
Description=Decnet Daemon
Wants=modprobe at decnet.service
After=modprobe at decnet.service
ConditionPathExists=/proc/net/decnet
ConditionFileNotEmpty=/etc/decnet.conf

[Service]
#Do your stuff

I am not an expert, neither am i god, these are just my 2c.

Simon


More information about the systemd-devel mailing list