Systemd 服务等待 wifi 适配器插入

Systemd 服务等待 wifi 适配器插入

我有一个 systemd 服务,每次启动时都会更改 WiFi 适配器的 MAC 地址。 Systemd 服务运行良好。我想要这个 systemd 服务不等1m 30sec当 wifi 适配器未插入 USB 时。我不想触发 systemd 服务通过 udev 规则因为systemd服务在network-pre.target和NetworkManager.service之后启动,所以我想要systemd服务在这些服务之前启动

我怎样才能做到这一点?

[Unit]
Description=macchanger on %I
Wants=network-pre.target
Before=network-pre.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

[Service]
ExecStart=/usr/bin/macchanger -r %I
Type=oneshot

[Install]
WantedBy=multi-user.target

相关内容