r17508: I didn;t realize we had this in our packages, remove it
[ira/wip.git] / packaging / Debian / debian-sarge / samba-common.dhcp
1 #!/bin/sh
2
3 SAMBA_DHCP_CONF=/etc/samba/dhcp.conf
4
5 netbios_setup() {
6         # No need to continue if we're called with an unsupported option
7
8         if [ "$reason" != BOUND ] && [ "$reason" != RENEW ] \
9            && [ "$reason" != REBIND ] && [ "$reason" != REBOOT ] \
10            && [ "$reason" != EXPIRE ] && [ "$reason" != FAIL ]
11         then
12                 return
13         fi
14
15         # Nor should we continue if no settings have changed
16         if [ "$new_netbios_name_servers" = "$old_netbios_name_servers" ] \
17            && [ "$new_netbios_scope" = "$old_netbios_scope" ]
18         then
19                 return
20         fi
21
22         # reparse our own file
23         local other_servers=`sed -n -e"s/[[:space:]]$interface:[^[:space:]]*//g; \
24                 s/^[[:space:]]*wins server[[:space:]]*=[[:space:]]*//pi" \
25                 $SAMBA_DHCP_CONF`
26
27         umask 022
28
29         local serverlist="$other_servers"
30         for server in $new_netbios_name_servers
31         do
32                 serverlist="$serverlist $interface:$server"
33         done
34
35         echo -n > $SAMBA_DHCP_CONF
36
37         # If we're updating on failure/expire, AND there are no WINS
38         # servers for other interfaces, leave the file empty.
39         if [ -z "$other_servers" ]
40         then
41                 if [ "$reason" = FAIL ] || [ "$reason" = EXPIRE ]
42                 then
43                         return
44                 fi
45         fi
46
47         if [ -n "$serverlist" ]
48         then
49                 echo "   wins server =$serverlist" >> $SAMBA_DHCP_CONF
50         fi
51         if [ -n "$new_netbios_scope" ]
52         then
53                 echo "   netbios scope = $new_netbios_scope" >> $SAMBA_DHCP_CONF
54         fi
55 }
56
57 netbios_setup