From ccc8e3223f18c87391ad700635b6713fa8513905 Mon Sep 17 00:00:00 2001 From: mpmc Date: Mon, 24 Oct 2022 22:48:06 +0100 Subject: [PATCH] qmi-network@.service: make ping less verbose/use more env options --- systemd/system/qmi-network@.service | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/systemd/system/qmi-network@.service b/systemd/system/qmi-network@.service index 90c267a..7875ff3 100755 --- a/systemd/system/qmi-network@.service +++ b/systemd/system/qmi-network@.service @@ -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