mirror of
https://git.disroot.org/pranav/pybatmesh.git
synced 2025-01-12 01:32:09 +05:30
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:
parent
715f4b7308
commit
e28a0f7583
4
Makefile
4
Makefile
@ -3,10 +3,10 @@ PREFIX := /usr
|
|||||||
install: naxalnet
|
install: naxalnet
|
||||||
install -d $(DESTDIR)$(PREFIX)/bin
|
install -d $(DESTDIR)$(PREFIX)/bin
|
||||||
install -d $(DESTDIR)$(PREFIX)/lib/systemd/system/
|
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 naxalnet $(DESTDIR)$(PREFIX)/bin/
|
||||||
install -d $(DESTDIR)$(PREFIX)/share/naxalnet/networkd
|
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:
|
testdeps:
|
||||||
@for i in networkctl systemctl python3; do \
|
@for i in networkctl systemctl python3; do \
|
||||||
|
10
README.md
10
README.md
@ -98,6 +98,16 @@ If you were using NetworkManager before, enable it:
|
|||||||
sudo systemctl enable --now NetworkManager.service
|
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
|
## TODO
|
||||||
|
|
||||||
- add support for wireless ap (WiFi hotspot)
|
- add support for wireless ap (WiFi hotspot)
|
||||||
|
56
naxalnet
56
naxalnet
@ -5,6 +5,22 @@ Setup a working BATMAN Advanced network
|
|||||||
with systemd-networkd and iwd
|
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
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import copy
|
from shutil import copy
|
||||||
@ -30,7 +46,7 @@ try:
|
|||||||
for i in src.iterdir():
|
for i in src.iterdir():
|
||||||
copy(i, dest)
|
copy(i, dest)
|
||||||
except:
|
except:
|
||||||
sys.exit("An error occured")
|
sys.exit("An error occured while copying network files")
|
||||||
|
|
||||||
|
|
||||||
# Symlink resolvd.conf to systemd's stub-resolvd.conf
|
# Symlink resolvd.conf to systemd's stub-resolvd.conf
|
||||||
@ -48,24 +64,26 @@ except:
|
|||||||
sys.exit("An error occured while linking resolv.conf")
|
sys.exit("An error occured while linking resolv.conf")
|
||||||
|
|
||||||
|
|
||||||
# connect to the System bus
|
# Now, the iwd part
|
||||||
bus = SystemMessageBus()
|
try:
|
||||||
# iwd proxy
|
# connect to the System bus
|
||||||
iwd = bus.get_proxy("net.connman.iwd", "/")
|
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")
|
print("Bye")
|
||||||
|
@ -1,5 +1,16 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Naxalnet
|
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]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
Loading…
x
Reference in New Issue
Block a user