I was looking into the dbus interface for systemd, and one way to restart a service would be
DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket \
gdbus call --system \
--dest org.freedesktop.systemd1 \
--object-path /org/freedesktop/systemd1 \
--method org.freedesktop.systemd1.Manager.RestartUnit \
"<servicename>.service" \
"replace"
Where for example you’d replace <servicename>
with a host OS service’s name, such as NetworkManager
. Just tried it on a test device, that was connected, and it has reconnected fine afterwards.
See more info in these docs of what --method
are available and what are their parameters: https://www.freedesktop.org/wiki/Software/systemd/dbus/
The dbus-send
example would be as follows:
DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket \
dbus-send --system --print-reply --reply-timeout=2000 \
--type=method_call \
--dest=org.freedesktop.systemd1 \
/org/freedesktop/systemd1 \
org.freedesktop.systemd1.Manager.RestartUnit \
string:<servicename>.service \
string:replace
This is just an example, though, and in general be careful of automatic network manipulation, as you might end up with a disconnected device. You are right, the device reboot should be last resort too. The best outcome would be to figure out what causes that outage, and fix up in the firmware level - though that we are usually have to rely on upstream, though we do our fair share of upstreaming of fixes…
Let us know if you have any experience trying it!
Yeah, need more 5GHz dongles, though we have made some developments in that direction too (will keep everyone posted). If you have any other dongles that you’d recommend based on experience, would love to hear.