Add an optional argument to specify an interface to as default
connection for the system. This changes the constructed commands so that
the gateway is configured as default route, and nameservers are written
to resolv.conf.
---

I decided to drop the print-instead-execute approach, and simply add the
interface argument to get the default route and dns settings. These
changes were mostly to enable easy setup of internet on my board...

 test/process-context-settings | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/test/process-context-settings b/test/process-context-settings
index 7ffb12b3..e0bc1083 100755
--- a/test/process-context-settings
+++ b/test/process-context-settings
@@ -11,6 +11,11 @@ manager = dbus.Interface(bus.get_object('org.ofono', '/'),
 
 modems = manager.GetModems()
 
+default = None
+if len(sys.argv) > 1:
+       default = sys.argv[1]
+       print("Using %s as default link" % (default), file=sys.stderr)
+
 for path, properties in modems:
        if "org.ofono.ConnectionManager" not in properties["Interfaces"]:
                continue
@@ -50,11 +55,23 @@ for path, properties in modems:
                        cmd += "/32"
                        os.system(cmd);
 
-                       for i in settings["DomainNameServers"]:
-                               print("    Nameserver is %s" % (i),
+                       if interface == default:
+                               cmd = "ip route add default via " + gateway
+                               cmd += " dev " + interface
+                               os.system(cmd)
+
+                       for i,dns in enumerate(settings["DomainNameServers"]):
+                               print("    Nameserver is %s" % (dns),
                                        file=sys.stderr)
 
-                               cmd = "ip route add  " + i
-                               cmd +=" dev " + interface
+                               if interface == default:
+                                       redirect = " > " if i == 0 else " >> "
+                                       cmd = "echo nameserver " + dns + 
redirect
+                                       cmd += "/etc/resolv.conf"
+                               else:
+                                       cmd = "ip route add  " + dns
+                                       cmd += " dev " + interface
+
                                os.system(cmd);
+
                print('', file=sys.stderr)
-- 
2.22.0

_______________________________________________
ofono mailing list
ofono@ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

Reply via email to