Index: trunk/Changelog
===================================================================
--- trunk/Changelog	(revision 202)
+++ trunk/Changelog	(revision 203)
@@ -1,2 +1,15 @@
+4.1.0:
+  * Added two new configuration options for pxeconfig.conf file: closes #17 
+     - client_script_hook_add    : The script that must be run when we create
+                                 a pxeconfig file for a host(s). This option
+                                 replaces client_script_hook.
+     - client_script_hook_remove : The script that must be run wehn we remove
+                                 a pxeconfig file for a host(s)
+
+    Both options are useful for firewall setups. To open/close ports.
+  
+  Reported by: Ramon Bastiaans (SARA)
+  Fixed by: Bas van der Vlies
+
 4.0.3:
   * Removed server_args from pxeconfig.xinetd example. Everything is set via
Index: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	(revision 202)
+++ trunk/debian/changelog	(revision 203)
@@ -1,2 +1,8 @@
+pxeconfig (4.1.0-1) stable; urgency=low
+
+  * See Changelog
+
+ -- Bas van der Vlies <bas@sara.nl>  Wed, 22 Aug 2012 14:15:57 +0200
+
 pxeconfig (4.0.3-1) stable; urgency=low
 
Index: trunk/pxeconfig.conf
===================================================================
--- trunk/pxeconfig.conf	(revision 202)
+++ trunk/pxeconfig.conf	(revision 203)
@@ -2,6 +2,7 @@
 ;pxe_config_dir	   : ./pxelinux.cfg
 ;debug		   : 0
-;client_script_hook : /usr/sara/sbin/pxefirewall-pre-install.sh
-;daemon_script_hook : /usr/sara/sbin/pxefirewall-post-install.sh
+;client_script_hook_remove : /usr/sara/sbin/pxefirewall-pre-install.sh remove
+;client_script_hook_add    : /usr/sara/sbin/pxefirewall-pre-install.sh add
+;daemon_script_hook        : /usr/sara/sbin/pxefirewall-post-install.sh
 
 ; Only set it when dynamic ip's are enabled
Index: trunk/pxeconfig.spec
===================================================================
--- trunk/pxeconfig.spec	(revision 202)
+++ trunk/pxeconfig.spec	(revision 203)
@@ -4,5 +4,5 @@
 
 Name: pxeconfig
-Version: 4.0.3 
+Version: 4.1.0 
 Release: 1%{?dist}
 License: See LICENSE
Index: trunk/src/pxeconfig.py
===================================================================
--- trunk/src/pxeconfig.py	(revision 202)
+++ trunk/src/pxeconfig.py	(revision 203)
@@ -125,5 +125,5 @@
     return files[index-1]
 
-def manage_links(haddr, options):
+def manage_links(haddr, ip_addr, options):
     """
     Create the links in the PXE_CONF_DIR,
@@ -141,10 +141,17 @@
             print 'removing %s/%s' %(PXE_CONF_DIR, haddr)
 
+            if options.SCRIPT_HOOK_REMOVE and ip_addr:
+                print 'Executing client script hook remove : %s with arg: %s' %(options.SCRIPT_HOOK_REMOVE, ip_addr)
+
         if os.path.exists(haddr) and not options.DRY_RUN:
             os.unlink(haddr)
 
     else:
+
         if options.DEBUG or options.DRY_RUN or options.VERBOSE:
             print 'linking %s to %s' %(haddr, pxe_filename)
+
+            if options.SCRIPT_HOOK_ADD and ip_addr:
+                print 'Executing client script hook add : %s with arg: %s' %(options.SCRIPT_HOOK_ADD, ip_addr)
 
         if not options.DRY_RUN:
@@ -152,4 +159,8 @@
                 os.unlink(haddr) 
             os.symlink(pxe_filename, haddr)
+    
+            if options.SCRIPT_HOOK_ADD and ip_addr:
+                cmd = '%s %s' %(options.SCRIPT_HOOK_ADD, ip_addr)
+                os.system(cmd)
 
 def net_2_hex(net, options):
@@ -194,13 +205,7 @@
     cnet = string.joinfields(net[0:3], '.')
 
-    if options.SCRIPT_HOOK:
-        if options.DEBUG or options.DRY_RUN or options.VERBOSE:
-            print 'Executing client script hook: %s with arg: %s' %(options.SCRIPT_HOOK, addr)
-        if not options.DRY_RUN:
-            cmd = '%s %s' %(options.SCRIPT_HOOK, addr)
-            os.system(cmd)
 
     haddr = '%s%02X' %(net_2_hex(cnet, options), int(net[3])) 
-    manage_links(haddr, options)
+    manage_links(haddr, addr, options)
 
 
@@ -214,5 +219,5 @@
 
     haddr = '01-%s' %(mac_addr.replace(':', '-').lower())
-    manage_links(haddr, options)
+    manage_links(haddr, None, options)
 
 def add_options(p):
@@ -226,5 +231,6 @@
         REMOVE  = False,
         VERSION  = False,
-        SCRIPT_HOOK = False,
+        SCRIPT_HOOK_ADD = False,
+        SCRIPT_HOOK_REMOVE = False,
     )
 
@@ -302,7 +308,19 @@
             options.filename = select_pxe_configfile() 
 
-    # ...
-    try:
-        options.SCRIPT_HOOK = defaults['client_script_hook']
+
+    ## This will be obsoleted by client_script_hook_add
+    #
+    try:
+        options.SCRIPT_HOOK_ADD = defaults['client_script_hook']
+    except KeyError, detail:
+        pass
+
+    try:
+        options.SCRIPT_HOOK_ADD = defaults['client_script_hook_add']
+    except KeyError, detail:
+        pass
+
+    try:
+        options.SCRIPT_HOOK_REMOVE = defaults['client_script_hook_remove']
     except KeyError, detail:
         pass
