mirror of
https://git.disroot.org/pranav/pybatmesh.git
synced 2025-01-11 17:22:17 +05:30
added ad-hoc support
Finally, the python rewrite is over! Currently, there is no way to change the name of ad-hoc neetwork other than editing the script.
This commit is contained in:
parent
f5755e370b
commit
a0d9c62ab7
26
naxalnet
26
naxalnet
@ -30,7 +30,7 @@ NETWORKD_CONFIGS = "/usr/share/naxalnet/networkd"
|
|||||||
NETWORKD_VOLATILE_DIR = "/run/systemd/network"
|
NETWORKD_VOLATILE_DIR = "/run/systemd/network"
|
||||||
RESOLVED_STUB_RESOLVE = "/run/systemd/resolve/stub-resolv.conf"
|
RESOLVED_STUB_RESOLVE = "/run/systemd/resolve/stub-resolv.conf"
|
||||||
RESOLV_CONF = "/etc/resolv.conf"
|
RESOLV_CONF = "/etc/resolv.conf"
|
||||||
|
ADHOC_SSID = "HelloWorld"
|
||||||
|
|
||||||
# Copy networkd configs to volatile dir.
|
# Copy networkd configs to volatile dir.
|
||||||
# See man:systemd.networkm(5)
|
# See man:systemd.networkm(5)
|
||||||
@ -45,8 +45,9 @@ try:
|
|||||||
# Copy all files in src to dest
|
# Copy all files in src to dest
|
||||||
for i in src.iterdir():
|
for i in src.iterdir():
|
||||||
copy(i, dest)
|
copy(i, dest)
|
||||||
except:
|
except PermissionError as e:
|
||||||
sys.exit("An error occured while copying network files")
|
print(e)
|
||||||
|
sys.exit("Make sure you are root")
|
||||||
|
|
||||||
|
|
||||||
# Symlink resolvd.conf to systemd's stub-resolvd.conf
|
# Symlink resolvd.conf to systemd's stub-resolvd.conf
|
||||||
@ -60,7 +61,8 @@ try:
|
|||||||
r.unlink()
|
r.unlink()
|
||||||
print("Linking resolv.conf")
|
print("Linking resolv.conf")
|
||||||
r.symlink_to(RESOLVED_STUB_RESOLVE)
|
r.symlink_to(RESOLVED_STUB_RESOLVE)
|
||||||
except:
|
except PermissionError as e:
|
||||||
|
print(e)
|
||||||
sys.exit("An error occured while linking resolv.conf")
|
sys.exit("An error occured while linking resolv.conf")
|
||||||
|
|
||||||
|
|
||||||
@ -79,8 +81,20 @@ try:
|
|||||||
# add all devices to the list
|
# add all devices to the list
|
||||||
print("Found device:", obj["net.connman.iwd.Device"]["Name"])
|
print("Found device:", obj["net.connman.iwd.Device"]["Name"])
|
||||||
devices.append(name)
|
devices.append(name)
|
||||||
# TODO: On first devices, start ad-hoc
|
|
||||||
# If there is a second device, start AP
|
# Start ad-hoc on first device
|
||||||
|
devpath = devices.pop()
|
||||||
|
print("Working on first device", devpath)
|
||||||
|
dev1 = bus.get_proxy("net.connman.iwd", devpath)
|
||||||
|
if not dev1.Powered:
|
||||||
|
print("Device is off. Turning on")
|
||||||
|
dev1.Powered = True
|
||||||
|
print("Device is in", dev1.Mode)
|
||||||
|
dev1.Mode = "ad-hoc"
|
||||||
|
print("Switched to", dev1.Mode)
|
||||||
|
print("Starting ad-hoc network")
|
||||||
|
dev1.StartOpen(ADHOC_SSID)
|
||||||
|
# TODO: If there is a second device, start AP
|
||||||
# in it
|
# in it
|
||||||
except:
|
except:
|
||||||
sys.exit("An error occured while communicating with iwd")
|
sys.exit("An error occured while communicating with iwd")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user