# Systemd unit for lxd-agent. It ensures the lxd-agent is copied from the shared filesystem before
# it is started. The service is triggered dynamically when the lxd-agent-generator is run inside a
# LXD VM, rather than being enabled at boot.
[Unit]
Description=LXD - agent
Documentation=https://documentation.ubuntu.com/lxd/latest/
Before=multi-user.target cloud-init-local.service shutdown.target umount.target
After=local-fs.target systemd-journald.socket
Conflicts=shutdown.target
DefaultDependencies=no

# Containers see their host's DMI information, so the generator may add
# lxd-agent.service to the boot transaction if the container's host is a LXD VM
# with systemd older than 251. Prevent this by requiring a VM (systemd 244+).
ConditionVirtualization=vm

[Service]
Type=notify
RuntimeDirectory=lxd_agent
WorkingDirectory=-/run/lxd_agent
ExecStartPre=/usr/lib/systemd/lxd-agent-setup
ExecStart=/run/lxd_agent/lxd-agent
Restart=on-failure
RestartSec=5s
StartLimitInterval=60
StartLimitBurst=10
