3 # $Id: samba-common.postinst,v 1.2 2003/06/01 07:12:51 peloy Exp $
8 # Do debconf stuff here
9 . /usr/share/debconf/confmodule
11 # We need a default smb.conf file. If one doesn't exist we put in place
12 # one that has some basic defaults.
13 if [ ! -e /etc/samba/smb.conf ]; then
14 cp -a /usr/share/samba/smb.conf /etc/samba/
17 # Static tempfile location, dpkg-style
18 TMPFILE=/etc/samba/smb.conf.dpkg-tmp
20 # ------------------------- Debconf questions start ---------------------
22 # Is the user configuring with debconf, or he/she prefers swat/manual
24 db_get samba-common/do_debconf || true
25 if [ "${RET}" = "true" ]; then
27 db_get samba-common/workgroup || true
30 # Oh my GOD, this is ugly. Why would anyone put these
31 # characters in a workgroup name? Why, Lord, why???
32 WORKGROUP=`echo $WORKGROUP | \
33 sed -e's/\\\\/\\\\\\\\/g
38 sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
39 /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
40 s/^\([[:space:]]*\)workgroup[[:space:]]*=.*/\1workgroup = ${WORKGROUP}/i" \
41 < /etc/samba/smb.conf >${TMPFILE}
42 mv -f ${TMPFILE} /etc/samba/smb.conf
45 db_get samba-common/encrypt_passwords || true
46 ENCRYPT_PASSWORDS="${RET}"
48 sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
49 /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
50 s/^\([[:space:]]*\)encrypt passwords[[:space:]]*=.*/\1encrypt passwords = ${ENCRYPT_PASSWORDS}/i" \
51 < /etc/samba/smb.conf >${TMPFILE}
52 mv -f ${TMPFILE} /etc/samba/smb.conf
54 # Install DHCP support
55 db_get samba-common/dhcp && DHCPVAL="$RET"
56 db_fget samba-common/dhcp applied || true
57 if [ "$DHCPVAL" = true ] && [ "$RET" != true ] && \
58 ! grep -q dhcp.conf /etc/samba/smb.conf
60 sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
61 /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ {
62 /wins server[[:space:]]*=/a \\
64 # If we receive WINS server info from DHCP, override the options above. \\
65 include = /etc/samba/dhcp.conf
66 }" < /etc/samba/smb.conf > ${TMPFILE}
67 mv -f ${TMPFILE} /etc/samba/smb.conf
68 elif [ "$RET" != true ] && grep -q dhcp.conf /etc/samba/smb.conf
71 # FIXME: here we /delete/ the lines?
73 # Once we get here, the config has been applied, whatever
75 if [ "$RET" != true ]; then
76 db_fset samba-common/dhcp applied true
79 # Update charset settings?
80 if ! grep -q "^[[:space:]]*unix charset[[:space:]]*=" /etc/samba/smb.conf
82 db_get samba-common/character_set || true
83 DISPLAYCHARSET="${RET}"
84 if [ -n "$DISPLAYCHARSET" ]
86 sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
87 s/^\([[:space:]]*\)character set/\1character set/i
88 /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ {
89 /^[[:space:]]*character set[[:space:]]*=/c \\
90 display charset = $DISPLAYCHARSET\\
91 unix charset = $DISPLAYCHARSET
92 }" < /etc/samba/smb.conf > ${TMPFILE}
93 mv -f ${TMPFILE} /etc/samba/smb.conf
97 if grep -qi "^[[:space:]]*passdb backend[[:space:]]*=.*unixsam" /etc/samba/smb.conf
99 sed -e 's/^\([[:space:]]*\)passdb backend/\1passdb backend/i
100 /^[[:space:]]*passdb backend/ {
102 }' < /etc/samba/smb.conf > ${TMPFILE}
103 mv -f ${TMPFILE} /etc/samba/smb.conf
106 if ! grep -q "^[[:space:]]*dos charset[[:space:]]*=" /etc/samba/smb.conf
108 db_get samba-common/codepage || true
110 if [ -n "$DOSCHARSET" ]
112 sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
113 s/^\([[:space:]]*\)client code page/\1client code page/i
114 /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ {
115 /^[[:space:]]*client code page[[:space:]]*=/c \\
116 dos charset = $DOSCHARSET
117 }" < /etc/samba/smb.conf > ${TMPFILE}
118 mv -f ${TMPFILE} /etc/samba/smb.conf
122 if dpkg --compare-versions "$2" lt 2.999+3.0.alpha20-4 \
123 && ! grep -q "^[[:space:]]*panic action[[:space:]]*=" /etc/samba/smb.conf
125 sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
126 /^[[:space:]]*\[global\]/a \\
128 # Do something sensible when Samba crashes: mail the admin a backtrace\\
129 panic action = /usr/share/samba/panic-action %d" < /etc/samba/smb.conf > ${TMPFILE}
130 mv -f ${TMPFILE} /etc/samba/smb.conf
135 chmod a+r /etc/samba/smb.conf
137 # ------------------------- Debconf questions end ---------------------