From: David Paleino <dapal@debian.org>
Subject: support /etc/network/ hierarchy for connection scripts
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=579497
Forwarded: no

---
 wicd/networking.py |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

--- wicd.orig/wicd/networking.py
+++ wicd/wicd/networking.py
@@ -211,6 +211,12 @@ class Controller(object):
             mac = 'X'
         if name in (None, ''):
             name = 'X'
+        os.putenv("MODE", "stop")
+        os.putenv("VERBOSITY", str(int(self.debug)))
+        os.putenv("IFACE", iface.iface)
+        os.putenv("LOGICAL", iface.iface)
+        os.putenv("PHASE", "pre-down")
+        misc.ExecuteScripts('/etc/network/if-down.d/', self.debug)
         misc.ExecuteScripts(wpath.predisconnectscripts, self.debug,
                            extra_parameters=(nettype, name, mac))
         if self.pre_disconnect_script:
@@ -224,6 +230,8 @@ class Controller(object):
         iface.FlushRoutes()
         iface.Down()
         iface.Up()
+        os.putenv("PHASE", "post-down")
+        misc.ExecuteScripts('/etc/network/if-post-down.d/', self.debug)
         misc.ExecuteScripts(wpath.postdisconnectscripts, self.debug,
                             extra_parameters=(nettype, name, mac))
         if self.post_disconnect_script:
@@ -874,6 +882,12 @@ class WirelessConnectThread(ConnectThrea
         self.is_connecting = True
         
         # Run pre-connection script.
+        os.putenv("MODE", "start")
+        os.putenv("VERBOSITY", str(int(self.debug)))
+        os.putenv("IFACE", wiface.iface)
+        os.putenv("LOGICAL", wiface.iface)
+        os.putenv("PHASE", "pre-up")
+        self.run_global_scripts_if_needed('/etc/network/if-pre-up.d/')
         self.run_global_scripts_if_needed(wpath.preconnectscripts,
                                           extra_parameters=('wireless',
                                                     self.network['essid'],
@@ -923,6 +937,8 @@ class WirelessConnectThread(ConnectThrea
         self.verify_association(wiface)
         
         # Run post-connection script.
+        os.putenv("PHASE", "post-up")
+        self.run_global_scripts_if_needed('/etc/network/if-up.d/')
         self.run_global_scripts_if_needed(wpath.postconnectscripts,
                                           extra_parameters=('wireless',
                                                     self.network['essid'],
@@ -1132,6 +1148,12 @@ class WiredConnectThread(ConnectThread):
         self.is_connecting = True
 
         # Run pre-connection script.
+        os.putenv("MODE", "start")
+        os.putenv("VERBOSITY", str(int(self.debug)))
+        os.putenv("IFACE", liface.iface)
+        os.putenv("LOGICAL", liface.iface)
+        os.putenv("PHASE", "pre-up")
+        self.run_global_scripts_if_needed('/etc/network/if-pre-up.d/')
         self.run_global_scripts_if_needed(wpath.preconnectscripts,
                                           extra_parameters=('wired', 'wired',
                                                             self.network['profilename'])
@@ -1154,6 +1176,8 @@ class WiredConnectThread(ConnectThread):
         self.set_dns_addresses(liface)
         
         # Run post-connection script.
+        os.putenv("PHASE", "post-up")
+        self.run_global_scripts_if_needed('/etc/network/if-up.d/')
         self.run_global_scripts_if_needed(wpath.postconnectscripts,
                                           extra_parameters=('wired', 'wired',
                                                 self.network['profilename'])
