stopped messing with resolv.conf

Completely removed the part that symlinks resolv.conf
to systemd-resolved's conf. Instead, added an optional
dependency of resolved in README.md
This commit is contained in:
Pranav Jerry 2021-06-12 19:28:59 +05:30
parent 1d2d4b2d88
commit 0fb8b6a8ab
Signed by: pranav
GPG Key ID: F1DCDC4FED0A0C5B
3 changed files with 3 additions and 36 deletions

View File

@ -28,7 +28,7 @@ advocating the constitutional rights).
## Requirements
- systemd v248 or more (for batman support)
- systemd{,-networkd} v248 or more (for batman support)
- Linux kernel with batman-adv module (if `modinfo batman-adv` shows
no error then you already have it)
- iwd (for starting ad-hoc network)
@ -36,6 +36,7 @@ advocating the constitutional rights).
- [python-dasbus][]
- wifi adapter with ad-hoc support
- two or more computers with wifi adapter
- systemd-resolved (optional, for DNS)
## Installing

View File

@ -22,7 +22,6 @@ with systemd-networkd and iwd
import sys
import time
from pathlib import Path
from shutil import copy
from dasbus.connection import SystemMessageBus
@ -30,8 +29,6 @@ from dasbus.error import DBusError
NETWORKD_CONFIGS = "/usr/share/naxalnet/networkd"
NETWORKD_VOLATILE_DIR = "/run/systemd/network"
RESOLVED_STUB_RESOLVE = "/run/systemd/resolve/stub-resolv.conf"
RESOLV_CONF = "/etc/resolv.conf"
ADHOC_SSID = "HelloWorld"
# Copy networkd configs to volatile dir.
@ -51,36 +48,6 @@ except PermissionError as error:
print(error)
sys.exit("Make sure you are root")
# Symlink resolvd.conf to systemd's stub-resolvd.conf
# This is needed for DNS resolution to work.
# see https://wiki.archlinux.org/title/Systemd-resolved#DNS
try:
print("Checking resolv.conf")
r = Path(RESOLV_CONF)
if r.is_symlink():
# Naxalnet will be started before resolved, so the destination
# is unlikely to exist at the time
# If r is linked to resolved's resolv.conf, dont change it
if r.samefile(RESOLVED_STUB_RESOLVE):
print(r, "is already linked to stub-resolv.conf. Not changing")
# Else if the destination exists
elif r.exists():
print(r, "is a symlink that exists. Not removing")
else:
print(r, "is a symlink to a destination that doesn't exist. Removing")
r.unlink()
elif r.exists():
print(r, "is not a symlink")
x = r.rename(RESOLV_CONF + ".naxalnet-bkp")
print(r, "was moved to", x)
print("Linking resolv.conf")
r.symlink_to(RESOLVED_STUB_RESOLVE)
except PermissionError as error:
print(error)
sys.exit("An error occured while linking resolv.conf")
# Now, the iwd part
try:
# connect to the System bus
@ -108,7 +75,7 @@ try:
print("Device is in", dev1.Mode)
print("Switching to ad-hoc")
dev1.Mode = "ad-hoc"
# Changing Mode requires connecting to the proxy again
# Changing Mode needs connecting to the proxy again
dev1 = bus.get_proxy("net.connman.iwd", devpath)
print("Starting ad-hoc network")
dev1.StartOpen(ADHOC_SSID)

View File

@ -15,7 +15,6 @@ After=wpa_supplicant.service
[Service]
Type=oneshot
RemainAfterExit=yes
# Temporary (maybe permanent) fix to aborting after changing to ad-hoc
Restart=on-failure
RestartSec=5sec
ExecStart=/usr/bin/naxalnet