qmi-network@.service: make ping less verbose/use more env options

This commit is contained in:
mpmc 2022-10-24 22:48:06 +01:00
parent 8da0231310
commit ccc8e3223f
1 changed files with 17 additions and 1 deletions

View File

@ -18,6 +18,22 @@ Restart=always
RestartSec=60s
TimeoutSec=90s
##
# Ping host.
Environment=PHOST="one.one.one.one"
# Normal wwan%i metric (should be higher than all other dev).
Environment=NMETRIC=1025
# Failover wwan%i metric.
Environment=FOMETRIC=128
# Ping test interval.
Environment=TESTINT=20
##
# Make sure the state is cleared before starting.
ExecStartPre=-rm /tmp/qmi-network-state-cdc-wdm%i
@ -36,7 +52,7 @@ ExecStartPre=networkctl up wwan%i
ExecStartPre=-sh -e -c "sleep 5; qmi-network /dev/cdc-wdm%i start && sleep 5;"
# Main loop with **very basic** failover.
ExecStart=sh -e -c "while true; do ping -w 10 -c 3 one.one.one.one || (ping -w 10 -I wwan%i -c 3 one.one.one.one && ifmetric wwan%i 128); sleep 30; done;"
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;"
# Stop.. DOWN TIME!
ExecStop=networkctl down wwan%i