diff --git a/Makefile b/Makefile index 62373c1..b8dfece 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,10 @@ PREFIX := /usr install: naxalnet install -d $(DESTDIR)$(PREFIX)/bin install -d $(DESTDIR)$(PREFIX)/lib/systemd/system/ - install naxalnet.service $(DESTDIR)$(PREFIX)/lib/systemd/system/ + install -m644 naxalnet.service $(DESTDIR)$(PREFIX)/lib/systemd/system/ install naxalnet $(DESTDIR)$(PREFIX)/bin/ install -d $(DESTDIR)$(PREFIX)/share/naxalnet/networkd - install systemd-networkd/* $(DESTDIR)$(PREFIX)/share/naxalnet/networkd + install -m644 systemd-networkd/* $(DESTDIR)$(PREFIX)/share/naxalnet/networkd testdeps: @for i in networkctl systemctl python3; do \ diff --git a/README.md b/README.md index 5c95037..b40d69a 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,16 @@ If you were using NetworkManager before, enable it: sudo systemctl enable --now NetworkManager.service ``` +## License + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +See [LICENSE.md](LICENSE.md) for the complete version of the +license. + ## TODO - add support for wireless ap (WiFi hotspot) diff --git a/naxalnet b/naxalnet index 52c6f21..a87cb81 100755 --- a/naxalnet +++ b/naxalnet @@ -5,6 +5,22 @@ Setup a working BATMAN Advanced network with systemd-networkd and iwd """ +# Copyright (C) 2021 The Authors + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + import sys from pathlib import Path from shutil import copy @@ -30,7 +46,7 @@ try: for i in src.iterdir(): copy(i, dest) except: - sys.exit("An error occured") + sys.exit("An error occured while copying network files") # Symlink resolvd.conf to systemd's stub-resolvd.conf @@ -48,24 +64,26 @@ except: sys.exit("An error occured while linking resolv.conf") -# connect to the System bus -bus = SystemMessageBus() -# iwd proxy -iwd = bus.get_proxy("net.connman.iwd", "/") +# Now, the iwd part +try: + # connect to the System bus + bus = SystemMessageBus() + # iwd proxy + iwd = bus.get_proxy("net.connman.iwd", "/") + # Get list of all devices + print("Finding connected devices") + objects = iwd.GetManagedObjects() + devices = [] + for name, obj in objects.items(): + if "net.connman.iwd.Device" in obj: + # add all devices to the list + print("Found device:", obj["net.connman.iwd.Device"]["Name"]) + devices.append(name) + # TODO: On first devices, start ad-hoc + # If there is a second device, start AP + # in it +except: + sys.exit("An error occured while communicating with iwd") -# Get list of all devices -print("Finding connected devices") -objects = iwd.GetManagedObjects() -device_paths = [] -for name, obj in objects.items(): - if "net.connman.iwd.Device" in obj: - # add all devices to the list - print("Found device:", obj["net.connman.iwd.Device"]["Name"]) - device_paths.append(name) - - -# TODO: On first devices, start ad-hoc -# If there is a second device, start AP -# in it print("Bye") diff --git a/naxalnet.service b/naxalnet.service index 9749225..339c3ed 100644 --- a/naxalnet.service +++ b/naxalnet.service @@ -1,5 +1,16 @@ [Unit] Description=Naxalnet +Requires=systemd-networkd.service +Requires=iwd.service +Wants=systemd-resolved.service +Before=systemd-networkd.service +After=iwd.service + +# Stops NetworkManager and wpa_supplicant if already running +Conflicts=NetworkManager.service +Conflicts=wpa_supplicant.service +After=NetworkManager.service +After=wpa_supplicant.service [Service] Type=oneshot