summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-12-10 22:10:37 +0100
committerChristian Poessinger <christian@poessinger.com>2021-12-10 22:10:37 +0100
commite73b40a04ee90a91b778ce72a60cbb751f42a306 (patch)
tree6676535c246015ca4d1f91de764488ba9e325a0c
parenta8ebb4817955b3f33f773a4d05c753dfc77958cd (diff)
downloadvyos-1x-e73b40a04ee90a91b778ce72a60cbb751f42a306.tar.gz
vyos-1x-e73b40a04ee90a91b778ce72a60cbb751f42a306.zip
wwan: T3795: only enable cron helper when interface is in use
-rwxr-xr-xsrc/conf_mode/interfaces-wwan.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/conf_mode/interfaces-wwan.py b/src/conf_mode/interfaces-wwan.py
index 7fdd0d447..e052e152d 100755
--- a/src/conf_mode/interfaces-wwan.py
+++ b/src/conf_mode/interfaces-wwan.py
@@ -30,12 +30,14 @@ from vyos.util import call
from vyos.util import dict_search
from vyos.util import DEVNULL
from vyos.util import is_systemd_service_active
+from vyos.util import write_file
from vyos.template import render
from vyos import ConfigError
from vyos import airbag
airbag.enable()
service_name = 'ModemManager.service'
+cron_script = '/etc/cron.d/wwan'
def get_config(config=None):
"""
@@ -80,6 +82,11 @@ def verify(wwan):
return None
def generate(wwan):
+ if 'deleted' in wwan:
+ return None
+
+ if not os.path.exists(cron_script):
+ write_file(cron_script, '*/5 * * * * root /usr/libexec/vyos/vyos-check-wwan.py')
return None
def apply(wwan):
@@ -108,6 +115,10 @@ def apply(wwan):
# There are no other WWAN interfaces - stop the daemon
if 'other_interfaces' not in wwan:
cmd(f'systemctl stop {service_name}')
+ # Clean CRON helper script which is used for to re-connect when
+ # RF signal is lost
+ if os.path.exists(cron_script):
+ os.unlink(cron_script)
return None