r13578: picking up missed commit (ran form source/ directory previously)
[Samba.git] / packaging / Debian / debian-unstable / samba-common.dhcp
blobc8c4b9e14a80956d787eec2eeea5e17feab287bf
1 #!/bin/sh
3 SAMBA_DHCP_CONF=/etc/samba/dhcp.conf
4 SAMBA_DHCP_CONF_INFO_FILE=""
6 netbios_setup() {
7 # No need to continue if we're called with an unsupported option
9 if [ "$reason" != BOUND ] && [ "$reason" != RENEW ] \
10 && [ "$reason" != REBIND ] && [ "$reason" != REBOOT ] \
11 && [ "$reason" != EXPIRE ] && [ "$reason" != FAIL ]
12 then
13 return
16 # Nor should we continue if no settings have changed
17 if [ "$new_netbios_name_servers" = "$old_netbios_name_servers" ] \
18 && [ "$new_netbios_scope" = "$old_netbios_scope" ] \
19 && [ -f $SAMBA_DHCP_CONF ]
20 then
21 return
24 # reparse our own file
25 local other_servers=`sed -n -e"s/[[:space:]]$interface:[^[:space:]]*//g; \
26 s/^[[:space:]]*wins server[[:space:]]*=[[:space:]]*//pi" \
27 $SAMBA_DHCP_CONF`
29 umask 022
31 local serverlist="$other_servers"
32 for server in $new_netbios_name_servers
34 serverlist="$serverlist $interface:$server"
35 done
37 echo -n > $SAMBA_DHCP_CONF
38 test -n "$SAMBA_DHCP_CONF_INFO_FILE" -a -f "$SAMBA_DHCP_CONF_INFO_FILE" && \
39 cat "$SAMBA_DHCP_CONF_INFO_FILE" >> $SAMBA_DHCP_CONF
41 # If we're updating on failure/expire, AND there are no WINS
42 # servers for other interfaces, leave the file empty.
43 if [ -z "$other_servers" ]
44 then
45 if [ "$reason" = FAIL ] || [ "$reason" = EXPIRE ]
46 then
47 return
51 if [ -n "$serverlist" ]
52 then
53 echo " wins server =$serverlist" >> $SAMBA_DHCP_CONF
55 if [ -n "$new_netbios_scope" ]
56 then
57 echo " netbios scope = $new_netbios_scope" >> $SAMBA_DHCP_CONF
61 # Only call netbios_setup if we're not sourced.
62 case "$0" in
63 *bin/sh|*bin/bash) : ;;
64 *) netbios_setup ;;
65 esac