wwan0.network - RequiredForOnline=no

qmi-network@.service - add more variables for ping options & increase ping timeouts
This commit is contained in:
mpmc 2023-06-18 10:48:21 +01:00
parent 69b5458185
commit 6e7218c685
2 changed files with 16 additions and 3 deletions

View File

@ -16,3 +16,6 @@ LLDP=no
[DHCP]
# Make sure connection/route is chosen last!
RouteMetric=2048
[Link]
RequiredForOnline=no

View File

@ -22,7 +22,8 @@ KillMode=process
##
# Ping host.
Environment=PHOST="one.one.one.one"
Environment=PHOST="dns9.quad9.net"
Environment=PHOSTIP="9.9.9.9"
# Normal wwan%i metric (should be higher than all other dev).
Environment=NMETRIC=1025
@ -31,7 +32,13 @@ Environment=NMETRIC=1025
Environment=FOMETRIC=128
# Ping test interval.
Environment=TESTINT=20
Environment=PTESTINT=20
# Ping timeout. (Ping timeout / knock-out)
Environment=PTESTKO=30
# Ping count (Number of pings).
Environment=PTESTCOUNT=3
##
@ -52,8 +59,11 @@ ExecStartPre=networkctl up wwan%i
# give it some time to be ready before starting the connection process.
ExecStartPre=-sh -e -c "sleep 5; qmi-network /dev/cdc-wdm%i start && sleep 5;"
# Do a test ping before we start the main loop.
ExecStartPre=sh -e -c "ping -w ${PTESTKO} -I wwan%i -c ${PTESTCOUNT} ${PHOSTIP}"
# Main loop with **very basic** failover.
ExecStart=sh -e -c "while true; do ping -w 10 -I wwan%i -c 3 one.one.one.one 2>&1 >/dev/null; (ping -w 10 -c 3 ${PHOST} 2>&1 >/dev/null && ifmetric wwan%i ${NMETRIC}) || (ping -w 10 -I wwan%i -c 3 ${PHOST} 2>&1 >/dev/null && ifmetric wwan%i ${FOMETRIC}); sleep ${TESTINT}; done;"
ExecStart=sh -e -c "while true; do ping -w ${PTESTKO} -I wwan%i -c ${PTESTCOUNT} ${PHOSTIP} 2>&1 >/dev/null; (ping -w ${PTESTKO} -c ${PTESTCOUNT} ${PHOST} 2>&1 >/dev/null && ifmetric wwan%i ${NMETRIC}) || (ping -w ${PTESTKO} -I wwan%i -c ${PTESTCOUNT} ${PHOST} 2>&1 >/dev/null && ifmetric wwan%i ${FOMETRIC}); sleep ${PTESTINT}; done;"
# Stop.. DOWN TIME!
ExecStop=networkctl down wwan%i