WPA: minimize driver specific code for /etc/network/interfaces
authorAndreas Oberritter <obi@opendreambox.org>
Mon, 14 Mar 2011 20:27:18 +0000 (21:27 +0100)
committerAndreas Oberritter <obi@opendreambox.org>
Mon, 14 Mar 2011 20:27:18 +0000 (21:27 +0100)
lib/python/Components/Network.py
lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py

index e980cb8..0a01123 100755 (executable)
@@ -171,11 +171,11 @@ class Network:
                                        if iface.has_key('gateway'):
                                                fp.write("      gateway %d.%d.%d.%d\n" % tuple(iface['gateway']))
                        if iface.has_key("configStrings"):
                                        if iface.has_key('gateway'):
                                                fp.write("      gateway %d.%d.%d.%d\n" % tuple(iface['gateway']))
                        if iface.has_key("configStrings"):
-                               fp.write("\n" + iface["configStrings"] + "\n")
+                               fp.write(iface["configStrings"])
                        if iface["preup"] is not False and not iface.has_key("configStrings"):
                                fp.write(iface["preup"])
                                fp.write(iface["postdown"])
                        if iface["preup"] is not False and not iface.has_key("configStrings"):
                                fp.write(iface["preup"])
                                fp.write(iface["postdown"])
-                       fp.write("\n")                          
+                       fp.write("\n")
                fp.close()
                self.writeNameserverConfig()
 
                fp.close()
                self.writeNameserverConfig()
 
index adf47f0..efec340 100644 (file)
@@ -454,13 +454,12 @@ def configStrings(iface):
                driver = iNetwork.detectWlanModule(iface)
        else:
                driver = 'dreambox'
                driver = iNetwork.detectWlanModule(iface)
        else:
                driver = 'dreambox'
-       if driver  in ('ralink', 'zydas'):
-               return "        pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -D"+driver+"\n        post-down wpa_cli terminate"
-       else:
-               if config.plugins.wlan.essid.value == "hidden...":
-                       return '        pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.hiddenessid.value+'"\n   pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -D'+driver+'\n    post-down wpa_cli terminate'
-               else:
-                       return '        pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.essid.value+'"\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -D'+driver+'\n    post-down wpa_cli terminate'
+       ret = ""
+       if driver == 'madwifi' and config.plugins.wlan.essid.value == "hidden...":
+               ret += "\tpre-up iwconfig " + iface + " essid \"" + config.plugins.wlan.hiddenessid.value + "\" || true\n"
+       ret += "\tpre-up wpa_supplicant -i" + iface + " -c/etc/wpa_supplicant.conf -B -dd -D" + driver + " || true\n"
+       ret += "\tpre-down wpa_cli -i" + iface + " terminate || true\n"
+       return ret
 
 def Plugins(**kwargs):
        return PluginDescriptor(name=_("Wireless LAN"), description=_("Connect to a Wireless Network"), where = PluginDescriptor.WHERE_NETWORKSETUP, needsRestart = False, fnc={"ifaceSupported": callFunction, "configStrings": configStrings, "WlanPluginEntry": lambda x: "Wireless Network Configuartion..."})
 
 def Plugins(**kwargs):
        return PluginDescriptor(name=_("Wireless LAN"), description=_("Connect to a Wireless Network"), where = PluginDescriptor.WHERE_NETWORKSETUP, needsRestart = False, fnc={"ifaceSupported": callFunction, "configStrings": configStrings, "WlanPluginEntry": lambda x: "Wireless Network Configuartion..."})