Changed systemd service

Fixed permissions in install lines in Makefile.
The systemd service now stops NetworkManager and
wpa_supplicant before starting naxalnet. It also
starts systemd-{networkd,resolved} and iwd alongside
naxalnet.service.
This commit is contained in:
Pranav Jerry 2021-06-06 11:25:37 +05:30
parent 715f4b7308
commit e28a0f7583
4 changed files with 60 additions and 21 deletions

View File

@ -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 \

View File

@ -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)

View File

@ -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 <http://www.gnu.org/licenses/>.
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")

View File

@ -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