Struct ::systemd::Unit

A systemd Unit file

This can be used to enable or mask systemd units.

For example, to enable a unit file from a package:

systemd::Unit::from_pkg("util-linux",
                        "fstrim.timer",
                        package_managers.files())
   .enable(ctx.cmds)?;

The additional functions can be used to customise the behaviour.

Methods

fn from_file(file: String, cmds: Commands) -> Result

Create a new instance from a file path

fn from_pkg(package: String, unit: String, package_manager: PackageManager) -> Unit

Create a new instace from a unit file in a package

fn user(self) -> Unit

Mark this as a user unit instead of (the default) system unit type

fn name(self, name: String) -> Unit

Override the name of the unit. Useful for parameterised units (e.g. foo@.service)

Skip installing aliases

Skip installing wanted-by

fn enable(self, commands: Commands) -> Result

Enable the unit

fn mask(self, commands: Commands) -> Result

Mask the unit