Package: dhcp-client
Version: 2.0pl5-19.1
Severity: wishlist
File: /sbin/dhclient
Tags: patch

I attached a little patch to reconfigure samba wins server option if
dhcp offers it. It requires include = /etc/samba/dhcp.conf in smb.conf,
but this is the default in Debian Sarge.

-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.6.13
Locale: LANG=en_US, LC_CTYPE=hu_HU (charmap=ISO-8859-2)

Versions of packages dhcp-client depends on:
ii  libc6                       2.3.2.ds1-22 GNU C Library: Shared libraries an

-- no debconf information
--- /etc/dhclient-script.orig   2005-08-25 16:08:17.000000000 +0200
+++ /etc/dhclient-script        2005-09-01 09:16:06.000000000 +0200
@@ -60,6 +60,28 @@
   }
 fi
 
+make_samba_conf() {
+       [ x$new_netbios_name_servers == x ] && exit 0
+       if [ -e /etc/samba/dhcp.conf ]; then
+               if grep -q "^[[:space:]]*wins server[[:space:]]*=" 
/etc/samba/dhcp.conf; then
+                       sed -i "s/^\([[:space:]]*wins 
server[[:space:]]*=\).*$/\1 $new_netbios_name_servers/" /etc/samba/dhcp.conf
+               else 
+                       echo "   wins server = $wins_servers" >> 
/etc/samba/dhcp.conf
+               fi
+       else
+                       echo "   wins server = $wins_servers" > 
/etc/samba/dhcp.conf
+       fi
+       /etc/init.d/samba reload >/dev/null 2>/dev/null || :
+       return 0
+}
+
+unmake_samba_conf() {
+       sed -i "/^[[:space:]]*wins server[[:space:]]*=.*$/d"
+       /etc/init.d/samba reload >/dev/null 2>/dev/null || :
+       return 0
+}
+
+
 # Invoke the local dhcp client enter hooks, if they exist.
 if [ -f /etc/dhclient-enter-hooks ]; then
   exit_status=0
@@ -160,11 +182,13 @@
     route add -host $alias_ip_address $interface:0
   fi
   make_resolv_conf || exit_with_hooks 1
+  make_samba_conf || exit_with_hooks 1
   exit_with_hooks 0
 fi
 
 if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then
   unmake_resolv_conf
+  unmake_samba_conf
   if [ x$alias_ip_address != x ]; then
     # Turn off alias interface.
     ifconfig $interface:0- inet 0
@@ -182,6 +206,7 @@
 
 if [ x$reason = xRELEASE ] || [ x$reason = xSTOP ]; then
   unmake_resolv_conf
+  unmake_samba_conf
 fi
 
 if [ x$reason = xTIMEOUT ]; then
@@ -206,9 +231,11 @@
       route add default gw $router
     done
     make_resolv_conf || exit_with_hooks 1
+    make_samba_conf || exit_with_hooks 1
     exit_with_hooks 0
   fi
   unmake_resolv_conf
+  unmake_samba_conf
   ifconfig $interface inet down
   exit_with_hooks 1
 fi

Reply via email to