aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components
diff options
context:
space:
mode:
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>2005-09-02 05:05:08 +0000
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>2005-09-02 05:05:08 +0000
commit5f2a1714d57cd1ae935cd20cd26ccf596acc7de6 (patch)
treebb4637f6d07bef82943211aea29d39243c874186 /lib/python/Components
parent7e3e90678897a0924cd365e117fd71679032dc40 (diff)
downloadenigma2-5f2a1714d57cd1ae935cd20cd26ccf596acc7de6.tar.gz
enigma2-5f2a1714d57cd1ae935cd20cd26ccf596acc7de6.zip
network setup stuff
Diffstat (limited to 'lib/python/Components')
-rw-r--r--lib/python/Components/Network.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/python/Components/Network.py b/lib/python/Components/Network.py
new file mode 100644
index 00000000..df2c3d9c
--- /dev/null
+++ b/lib/python/Components/Network.py
@@ -0,0 +1,42 @@
+from config import *
+
+import os
+
+class Network:
+ def __init__(self):
+ pass
+
+ def setIPAddress(self, ip):
+ print ip
+ #os.system("echo ifconfig eth0 %d.%d.%d.%d" % (ip[0], ip[1], ip[2], ip[3]))
+
+ def setIPGateway(self, ip):
+ os.system("echo route add default gw %d.%d.%d.%d" % (ip[0], ip[1], ip[2], ip[3]))
+
+ def setIPNameserver(self, ip):
+ resolvconf = file('/etc/resolv.conf', 'w')
+ resolvconf.write("nameserver %d.%d.%d.%d" % (ip[0], ip[1], ip[2], ip[3]))
+ resolvconf.close()
+
+def InitNetwork():
+ config.network = ConfigSubsection();
+ config.network.ip = configElement("config.network.ip", configSequence, [192,168,1,45], (".") );
+ config.network.gateway = configElement("config.network.gateway", configSequence, [192,168,1,3], (".") );
+ config.network.dns = configElement("config.network.dns", configSequence, [192,168,1,3], (".") );
+
+ iNetwork = Network()
+
+ def setIPAddress(configElement):
+ iNetwork.setIPAddress(configElement.value);
+
+ def setIPGateway(configElement):
+ iNetwork.setIPGateway(configElement.value);
+
+ def setIPNameserver(configElement):
+ iNetwork.setIPNameserver(configElement.value);
+
+
+ # this will call the "setup-val" initial
+ config.network.ip.addNotifier(setIPAddress);
+ config.network.gateway.addNotifier(setIPGateway);
+ config.network.dns.addNotifier(setIPNameserver);