3 # Source debconf library.
4 . /usr/share/debconf/confmodule
6 # Function for grabbing a parameter from an smb.conf file
16 if [ -z "$FILE" ]; then
21 s/^[[:space:]]*\[global\]/\[global\]/i
22 /^\[global\]/,/^[[:space:]]*\[/ {
23 s/^[[:space:]]*$1[[:space:]]*=[[:space:]]*//pi
28 FILE=/etc/samba/smb.conf
30 db_title "Samba Server"
32 # We ask the question IFF the config contains complex options that could
33 # cause us to break the config.
34 if [ -f "$FILE" ] && grep -v dhcp.conf $FILE \
35 | grep -qEi '\\$|^[[:space:]]*include[[:space:]]*='
37 db_input high samba-common/do_debconf || true
40 db_set samba-common/do_debconf true
43 # If user doesn't want to use debconf to configure Samba the leave...
44 db_get samba-common/do_debconf || true
45 if [ "${RET}" = "false" ]; then
49 # User wants to use debconf, let's continue...
51 # Adjust priority of the question about the workgroup name depending
52 # on whether a workgroup name has already being specified.
53 db_get samba-common/workgroup || true
60 # Preload any values from the existing smb.conf file
62 WORKGROUP=`smbconf_retr workgroup`
63 if [ "$WORKGROUP" ]; then
64 db_set samba-common/workgroup "$WORKGROUP"
67 ENCRYPT=`smbconf_retr "encrypt passwords"`
68 if [ "$ENCRYPT" ]; then
69 ENCRYPT=`echo $ENCRYPT | tr '[A-Z]' '[a-z]'`
70 if [ "$ENCRYPT" = "yes" ]; then
72 elif [ "$ENCRYPT" = "no" ]; then
76 db_set samba-common/encrypt_passwords "$ENCRYPT"
79 CHARSET=`smbconf_retr "character set"`
80 CODEPAGE=`smbconf_retr "client code page"`
81 DISPLAYCHARSET=`smbconf_retr "display charset"`
82 UNIXCHARSET=`smbconf_retr "unix charset"`
83 DOSCHARSET=`smbconf_retr "dos charset"`
85 # If we're upgrading from an old version and there's no
86 # 'passdb backend' setting, add one.
87 if [ "$1" = "configure" -a -n "$2" ] \
88 && dpkg --compare-versions "$2" lt 2.99.cvs.20020713-2 \
89 && ! grep -q -i '^[[:space:]]*passdb backend[[:space:]]*=' $FILE
91 TMPFILE=/etc/samba/smb.conf.dpkg-tmp
93 s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
94 s/^\([[:space:]]*\)encrypt passwords/\1encrypt passwords/i
95 /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ {
96 /^[[:space:]]*encrypt passwords[[:space:]]*=/a \
97 passdb backend = smbpasswd guest
98 }' < $FILE > ${TMPFILE}
100 mv -f ${TMPFILE} /etc/samba/smb.conf
105 db_input $WGPRIORITY samba-common/workgroup || true
108 # Use encrypted passwords?
109 db_input medium samba-common/encrypt_passwords || true
112 # Handle migrating character sets
113 if [ -n "$CHARSET" -a -z "$DISPLAYCHARSET" -a -z "$UNIXCHARSET" ]
115 DISPLAYCHARSET=`echo $CHARSET | sed -e's/iso-/ISO/i'`
116 db_set samba-common/character_set "$DISPLAYCHARSET"
117 # FIXME: should eventually be low.
118 db_input medium samba-common/character_set || true
122 if [ -n "$CODEPAGE" -a -z "$DOSCHARSET" ]
124 DOSCHARSET=CP`echo $CODEPAGE | sed -e's/[[:alpha:]]*//g'`
125 db_set samba-common/codepage "$DOSCHARSET"
126 # FIXME: should eventually be low.
127 db_input medium samba-common/codepage || true
132 #if [ "$DEBCONF_RECONFIGURE" = 1 ] && [ -f /sbin/dhclient3 ]
133 if [ -f /sbin/dhclient3 ]
136 # TODO: see if we can detect that dhcp3-client is *going* to be installed,
137 # even if it isn't yet.
138 #elif dpkg-query -W --showformat='${Status}\n' dhcp3-client | grep ???
139 # unknown ok not-installed ?
143 if [ ! -f $FILE ] || grep -q -i 'wins server' $FILE
145 # check the values before and after; unset the 'applied' flag
146 # if they don't match.
147 db_get samba-common/dhcp || true
149 db_input $DHCPPRIORITY samba-common/dhcp || true
151 db_get samba-common/dhcp || true
152 if [ "$OLDDHCP" != "$RET" ]; then
153 db_fset samba-common/dhcp applied false