• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/ap/gpl/samba-3.0.13/packaging/Debian/debian-stable/
1#/bin/sh -e
2
3# Source debconf library.
4. /usr/share/debconf/confmodule
5
6# Function for grabbing a parameter from an smb.conf file
7smbconf_retr() {
8	if [ -z "$1" ]; then
9		return
10	fi
11
12	if [ -n "$2" ]; then
13		local FILE="$2"
14	fi
15
16	if [ -z "$FILE" ]; then
17		return
18	fi
19
20	sed -n -e"
21		s/^[[:space:]]*\[global\]/\[global\]/i
22		/^\[global\]/,/^[[:space:]]*\[/ {
23			s/^[[:space:]]*$1[[:space:]]*=[[:space:]]*//pi
24		}" $FILE \
25	| tail -1
26}
27
28FILE=/etc/samba/smb.conf
29
30db_title "Samba Server"
31
32# We ask the question IFF the config contains complex options that could
33# cause us to break the config.
34if [ -f "$FILE" ] && grep -v dhcp.conf $FILE \
35                     | grep -qEi '\\$|^[[:space:]]*include[[:space:]]*='
36then
37	db_input high samba-common/do_debconf || true
38	db_go
39else
40	db_set samba-common/do_debconf true
41fi
42
43# If user doesn't want to use debconf to configure Samba the leave...
44db_get samba-common/do_debconf || true
45if [ "${RET}" = "false" ]; then
46	exit 0
47fi
48
49# User wants to use debconf, let's continue...
50
51# Adjust priority of the question about the workgroup name depending
52# on whether a workgroup name has already being specified.
53db_get samba-common/workgroup || true
54if [ "${RET}" ]; then
55	WGPRIORITY=medium
56else
57	WGPRIORITY=high
58fi
59
60# Preload any values from the existing smb.conf file
61if [ -f $FILE ]; then
62	WORKGROUP=`smbconf_retr workgroup`
63	if [ "$WORKGROUP" ]; then
64		db_set samba-common/workgroup "$WORKGROUP"
65	fi
66
67	ENCRYPT=`smbconf_retr "encrypt passwords"`
68	if [ "$ENCRYPT" ]; then
69		ENCRYPT=`echo $ENCRYPT | tr '[A-Z]' '[a-z]'`
70		if [ "$ENCRYPT" = "yes" ]; then
71			ENCRYPT=true
72		elif [ "$ENCRYPT" = "no" ]; then
73			ENCRYPT=false
74		fi
75
76		db_set samba-common/encrypt_passwords "$ENCRYPT"
77	fi
78
79	CHARSET=`smbconf_retr "character set"`
80	CODEPAGE=`smbconf_retr "client code page"`
81	UNIXCHARSET=`smbconf_retr "unix charset"`
82	DOSCHARSET=`smbconf_retr "dos charset"`
83
84	# If we're upgrading from an old version and there's no
85	# 'passdb backend' setting, add one.
86	if [ "$1" = "configure" -a -n "$2" ] \
87	   && dpkg --compare-versions "$2" lt 2.99.cvs.20020713-2 \
88	   && ! grep -q -i '^[[:space:]]*passdb backend[[:space:]]*=' $FILE
89	then
90		TMPFILE=/etc/samba/smb.conf.dpkg-tmp
91		sed -e'
92			s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
93			s/^\([[:space:]]*\)encrypt passwords/\1encrypt passwords/i
94			/^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ {
95				/^[[:space:]]*encrypt passwords[[:space:]]*=/a \
96   passdb backend = smbpasswd guest
97			}' < $FILE > ${TMPFILE}
98		chmod a+r ${TMPFILE}
99		mv -f ${TMPFILE} /etc/samba/smb.conf
100	fi
101fi
102
103# Get workgroup name
104db_input $WGPRIORITY samba-common/workgroup || true
105db_go
106
107# Use encrypted passwords?
108db_input medium samba-common/encrypt_passwords || true
109db_go
110
111# Handle migrating character sets
112if [ -n "$CHARSET" -a -z "$UNIXCHARSET" ]
113then
114	UNIXCHARSET=`echo $CHARSET | sed -e's/iso-/ISO/i'`
115	db_set samba-common/character_set "$UNIXCHARSET"
116	# FIXME: should eventually be low.
117	db_input medium samba-common/character_set || true
118	db_go
119fi
120
121if [ -n "$CODEPAGE" -a -z "$DOSCHARSET" ]
122then
123	DOSCHARSET=CP`echo $CODEPAGE | sed -e's/[[:alpha:]]*//g'`
124	db_set samba-common/codepage "$DOSCHARSET"
125	# FIXME: should eventually be low.
126	db_input medium samba-common/codepage || true
127	db_go
128fi
129
130DHCPPRIORITY=medium
131#if [ "$DEBCONF_RECONFIGURE" = 1 ] && [ -f /sbin/dhclient3 ]
132if [ -f /sbin/dhclient3 ]
133then
134	DHCPPRIORITY=high
135# TODO: see if we can detect that dhcp3-client is *going* to be installed,
136# even if it isn't yet.
137#elif dpkg-query -W --showformat='${Status}\n' dhcp3-client | grep ???
138# unknown ok not-installed ? 
139#	DHCPPRIORITY=high
140fi
141
142if [ ! -f $FILE ] || grep -q -i 'wins server' $FILE
143then
144	# check the values before and after; unset the 'applied' flag
145	# if they don't match.
146	db_get samba-common/dhcp || true
147	OLDDHCP="$RET"
148	db_input $DHCPPRIORITY samba-common/dhcp || true
149	db_go
150	db_get samba-common/dhcp || true
151	if [ "$OLDDHCP" != "$RET" ]; then
152		db_fset samba-common/dhcp applied false
153	fi
154fi
155