mirror of
https://git.disroot.org/pranav/pybatmesh.git
synced 2024-12-24 01:00:02 +05:30
delete interface during cleanup
Read the previous commit for some unhelpful remarks.
This commit is contained in:
parent
2e4c3a70a4
commit
87612fac2c
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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:
|
||||
"""
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user