Skip to content

Instantly share code, notes, and snippets.

@cbrake
Last active March 4, 2022 14:35
Show Gist options
  • Select an option

  • Save cbrake/5092651 to your computer and use it in GitHub Desktop.

Select an option

Save cbrake/5092651 to your computer and use it in GitHub Desktop.
systemd network hotplugging
DESCRIPTION = "Network Hotplug"
LICENSE = "CLOSED"
PR = "r1"
SRC_URI = " \
file://network@.service \
file://network.rules \
"
FILES_${PN} = "${sysconfdir}/udev/rules.d/* ${base_libdir}/systemd/system/*"
RDEPENDS_${PN} = "udev"
do_install() {
install -d ${D}${base_libdir}/systemd/system/basic.target.wants
install -m 0644 ${WORKDIR}/*.service ${D}${base_libdir}/systemd/system
install -d ${D}${sysconfdir}/udev/rules.d
install -m 0644 ${WORKDIR}/network.rules ${D}${sysconfdir}/udev/rules.d/network.rules
}
================================================
more files/network@.service
# currently, the BindTo is not working
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/ifup -f %i
StandardOutput=syslog+console
BindsTo=%i.device
================================================
more files/network.rules
SUBSYSTEM=="net", KERNEL!="lo", ENV{SYSTEMD_WANTS}="network@$name.service" ENV{SYSTEMD_ALIAS}="/$name"
@shemminger

Copy link
Copy Markdown

Looks like systemd.unit uses "BindsTo=" not "BindTo="

@cbrake

cbrake commented Mar 4, 2022

Copy link
Copy Markdown
Author

thanks, fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment