delete interface during cleanup

Read the previous commit for some unhelpful remarks.
This commit is contained in:
Pranav Jerry 2021-09-27 22:48:13 +05:30
parent 2e4c3a70a4
commit 87612fac2c
Signed by: pranav
GPG Key ID: F1DCDC4FED0A0C5B
4 changed files with 7 additions and 14 deletions

View File

@ -23,15 +23,6 @@ Restart=on-failure
RestartSec=2sec
ExecStart=/usr/bin/naxalnet --systemd
KillSignal=SIGINT
# Reload systemd-networkd after naxalnet signals it is ready
#ExecStartPost=/usr/bin/networkctl reload
# When naxalnet exits, delete all files starting
# with mesh.* in /run/systemd/network
#ExecStopPost=/usr/bin/find /run/systemd/network -type f -delete -name "mesh.*"
# Then delete the two interfaces created...
#ExecStopPost=/usr/bin/networkctl delete bridge0 bat0
# ... and reload the configuration files.
#ExecStopPost=/usr/bin/networkctl reload
# naxalnet already logs to systemd journal so we don't need
# stdout and stderr.
StandardOutput=null

View File

@ -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.dev3"
__version__ = "0.4.0a5.dev4"

View File

@ -21,7 +21,7 @@ network.py
This submodule manages the systemd-networkd configuration.
TODO: Add more details
"""
import subprocess
from pathlib import Path
from dasbus.connection import SystemMessageBus
@ -71,6 +71,7 @@ class NetworkD:
def delete_interface(self, name: str) -> None:
"""delete the given interface"""
subprocess.run(["networkctl", "delete", name], check=True)
def remove_config(self, name: str) -> None:
"""

View File

@ -188,12 +188,10 @@ def setup_devices():
sys.exit(4)
def cleanup(signal=None, frame=None):
def cleanup():
"""
Remove all network config, poweroff used wireless devices and
exit with 0.
signal and frame are ununsed
"""
networkd = NetworkD(runtime_dir=args.networkd_runtime_dir)
logger.info("Exiting gracefully")
@ -202,6 +200,8 @@ def cleanup(signal=None, frame=None):
device = Device(i)
device.set_mode("station")
device.power_off()
networkd.delete_interface(args.batman_device)
networkd.delete_interface(args.bridge_device)
def print_wifi():
@ -263,5 +263,6 @@ def main():
notify("STATUS=Waiting for changes")
daemon.start()
# systemd uses SIGINT to kill this program
except KeyboardInterrupt:
cleanup()