mirror of git://git.sysmocom.de/ofono
test: process-context-settings: print settings to stderr
Prepare the test to print commands to execute and let the caller evaluate those. In that way, more commands can be added to also set up name servers and default routes without secretly breaking the existing system network setup.
This commit is contained in:
parent
777ae04611
commit
1c168e8338
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import dbus
|
import dbus
|
||||||
|
|
||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
|
@ -23,13 +24,14 @@ for path, properties in modems:
|
||||||
if properties["Active"] == dbus.Boolean(0):
|
if properties["Active"] == dbus.Boolean(0):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print("Configuring %s" % (path))
|
print("Configuring %s" % (path), file=sys.stderr)
|
||||||
|
|
||||||
settings = properties["Settings"]
|
settings = properties["Settings"]
|
||||||
interface = settings["Interface"]
|
interface = settings["Interface"]
|
||||||
|
|
||||||
if settings["Method"] == "dhcp":
|
if settings["Method"] == "dhcp":
|
||||||
print(" Run DHCP on interface %s" % (interface))
|
print(" Run DHCP on interface %s" % (interface),
|
||||||
|
file=sys.stderr)
|
||||||
else:
|
else:
|
||||||
address = settings["Address"]
|
address = settings["Address"]
|
||||||
try:
|
try:
|
||||||
|
@ -37,18 +39,22 @@ for path, properties in modems:
|
||||||
except:
|
except:
|
||||||
gateway = "0.0.0.0";
|
gateway = "0.0.0.0";
|
||||||
|
|
||||||
print(" Interface is %s" % (interface))
|
print(" Interface is %s" % (interface),
|
||||||
print(" IP address is %s" % (address))
|
file=sys.stderr)
|
||||||
print(" Gateway is %s" % (gateway))
|
print(" IP address is %s" % (address),
|
||||||
|
file=sys.stderr)
|
||||||
|
print(" Gateway is %s" % (gateway),
|
||||||
|
file=sys.stderr)
|
||||||
|
|
||||||
cmd = "ip address add dev " + interface + " " + address
|
cmd = "ip address add dev " + interface + " " + address
|
||||||
cmd += "/32"
|
cmd += "/32"
|
||||||
os.system(cmd);
|
os.system(cmd);
|
||||||
|
|
||||||
for i in settings["DomainNameServers"]:
|
for i in settings["DomainNameServers"]:
|
||||||
print(" Nameserver is %s" % (i))
|
print(" Nameserver is %s" % (i),
|
||||||
|
file=sys.stderr)
|
||||||
|
|
||||||
cmd = "ip route add " + i
|
cmd = "ip route add " + i
|
||||||
cmd +=" dev " + interface
|
cmd +=" dev " + interface
|
||||||
os.system(cmd);
|
os.system(cmd);
|
||||||
print('')
|
print('', file=sys.stderr)
|
||||||
|
|
Loading…
Reference in New Issue