From 761618aff462695d051d21bda7fdfaf6778397c3 Mon Sep 17 00:00:00 2001 From: Pranav Jerry Date: Mon, 27 Sep 2021 11:27:44 +0530 Subject: [PATCH] added new args and config options This will allow changing name of batman and bridge interface. But deleting them after stopping naxalnet will not work at the moment. --- naxalnet.conf.example | 5 ++++- naxalnet/__init__.py | 2 +- naxalnet/config.py | 12 ++++++++++++ naxalnet/default.py | 1 + naxalnet/scripts.py | 3 +-- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/naxalnet.conf.example b/naxalnet.conf.example index b74d660..cde3d4f 100644 --- a/naxalnet.conf.example +++ b/naxalnet.conf.example @@ -11,6 +11,10 @@ confdir = /usr/share/naxalnet/networkd # See man:systemd.network(5) runtimedir = /run/systemd/network +[device] +batman=bat0 +bridge=bridge0 + [adhoc] # All your nodes should have the same name name = NxMesh @@ -20,4 +24,3 @@ name = NxMesh ssid = MeshWiFi # Note the spelling. It's passwd, not password. passwd = naxalnet256 - diff --git a/naxalnet/__init__.py b/naxalnet/__init__.py index 240727f..ed843d0 100644 --- a/naxalnet/__init__.py +++ b/naxalnet/__init__.py @@ -35,4 +35,4 @@ See README.md for documentation. # # In case you forgot to change the version, skip the number # and put the next number in the next commit. -__version__ = "0.4.0a5" +__version__ = "0.4.0a5.dev1" diff --git a/naxalnet/config.py b/naxalnet/config.py index 7a77b60..434ea39 100644 --- a/naxalnet/config.py +++ b/naxalnet/config.py @@ -158,6 +158,18 @@ def parse_args() -> Namespace: help="send log messages to systemd journal", ) + parser.add_argument( + "--batman-device", + default=config["device"]["batman"], + help="name of interface used by batman-adv", + ) + + parser.add_argument( + "--bridge-device", + default=config["device"]["bridge"], + help="name of bridge interface", + ) + parser.add_argument( "--version", "-V", diff --git a/naxalnet/default.py b/naxalnet/default.py index fb5b5c7..ac09674 100644 --- a/naxalnet/default.py +++ b/naxalnet/default.py @@ -31,6 +31,7 @@ CONFIG = { "confdir": "/usr/share/naxalnet/networkd", "runtimedir": "/run/systemd/network", }, + "device": {"batman": "bat0", "bridge": "bridge0"}, "adhoc": {"name": "NxMesh"}, "ap": {"ssid": "MeshWiFi", "passwd": "naxalnet256"}, } diff --git a/naxalnet/scripts.py b/naxalnet/scripts.py index 02dffc3..0802330 100644 --- a/naxalnet/scripts.py +++ b/naxalnet/scripts.py @@ -64,8 +64,7 @@ def setup_mesh(): dest.mkdir(parents=True, exist_ok=True) networkd = NetworkD(runtime_dir=args.networkd_runtime_dir) - # TODO: replace with valus from args - networkd.set_vars(batdev="bat0", bridgedev="bridge0") + networkd.set_vars(batdev=args.batman_device, bridgedev=args.bridge_device) for i in get_sorted_glob(args.networkd_config_dir, MESH_GLOB): logger.debug("Adding network config %s", i) networkd.add_config(i)