Samba 3: added Samba 3.0.24 sources
[tomato.git] / release / src / router / samba3 / packaging / Debian / debian-woody / samba-common.postinst
blob6c6eb9bf5374a8ebfb43bbaa72d1e8108680ac67
1 #!/bin/sh
5 set -e
7 # Do debconf stuff here
8 . /usr/share/debconf/confmodule
10 # We need a default smb.conf file. If one doesn't exist we put in place
11 # one that has some basic defaults.
12 if [ ! -e /etc/samba/smb.conf ]; then
13 cp -a /usr/share/samba/smb.conf /etc/samba/
16 # Static tempfile location, dpkg-style
17 TMPFILE=/etc/samba/smb.conf.dpkg-tmp
19 # ------------------------- Debconf questions start ---------------------
21 # Is the user configuring with debconf, or he/she prefers swat/manual
22 # config?
23 db_get samba-common/do_debconf || true
24 if [ "${RET}" = "true" ]; then
25 # Get workgroup name
26 db_get samba-common/workgroup || true
27 WORKGROUP="${RET}"
29 # Oh my GOD, this is ugly. Why would anyone put these
30 # characters in a workgroup name? Why, Lord, why???
31 WORKGROUP=`echo $WORKGROUP | \
32 sed -e's/\\\\/\\\\\\\\/g
33 s#/#\\\\/#g
34 s/&/\\\&/g
35 s/\\\$/\\\\\\\$/g'`
37 sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
38 /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
39 s/^\([[:space:]]*\)workgroup[[:space:]]*=.*/\1workgroup = ${WORKGROUP}/i" \
40 < /etc/samba/smb.conf >${TMPFILE}
41 mv -f ${TMPFILE} /etc/samba/smb.conf
43 # Encrypt passwords?
44 db_get samba-common/encrypt_passwords || true
45 ENCRYPT_PASSWORDS="${RET}"
47 sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
48 /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
49 s/^\([[:space:]]*\)encrypt passwords[[:space:]]*=.*/\1encrypt passwords = ${ENCRYPT_PASSWORDS}/i" \
50 < /etc/samba/smb.conf >${TMPFILE}
51 mv -f ${TMPFILE} /etc/samba/smb.conf
53 # Install DHCP support
54 db_get samba-common/dhcp && DHCPVAL="$RET"
55 db_fget samba-common/dhcp applied || true
56 if [ "$DHCPVAL" = true ] && [ "$RET" != true ] && \
57 ! grep -q dhcp.conf /etc/samba/smb.conf
58 then
59 sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
60 /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ {
61 /wins server[[:space:]]*=/a \\
63 # If we receive WINS server info from DHCP, override the options above. \\
64 include = /etc/samba/dhcp.conf
65 }" < /etc/samba/smb.conf > ${TMPFILE}
66 mv -f ${TMPFILE} /etc/samba/smb.conf
67 elif [ "$RET" != true ] && grep -q dhcp.conf /etc/samba/smb.conf
68 then
70 # FIXME: here we /delete/ the lines?
72 # Once we get here, the config has been applied, whatever
73 # it is.
74 if [ "$RET" != true ]; then
75 db_fset samba-common/dhcp applied true
78 # Update charset settings?
79 if ! grep -q "^[[:space:]]*unix charset[[:space:]]*=" /etc/samba/smb.conf
80 then
81 db_get samba-common/character_set || true
82 UNIXCHARSET="${RET}"
83 if [ -n "$UNIXCHARSET" ]
84 then
85 sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
86 s/^\([[:space:]]*\)character set/\1character set/i
87 /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ {
88 /^[[:space:]]*character set[[:space:]]*=/c \\
89 unix charset = $UNIXCHARSET
90 }" < /etc/samba/smb.conf > ${TMPFILE}
91 mv -f ${TMPFILE} /etc/samba/smb.conf
95 if grep -qi "^[[:space:]]*passdb backend[[:space:]]*=.*unixsam" /etc/samba/smb.conf
96 then
97 sed -e 's/^\([[:space:]]*\)passdb backend/\1passdb backend/i
98 /^[[:space:]]*passdb backend/ {
99 s/unixsam/guest/i
100 }' < /etc/samba/smb.conf > ${TMPFILE}
101 mv -f ${TMPFILE} /etc/samba/smb.conf
104 if ! grep -q "^[[:space:]]*dos charset[[:space:]]*=" /etc/samba/smb.conf
105 then
106 db_get samba-common/codepage || true
107 DOSCHARSET="${RET}"
108 if [ -n "$DOSCHARSET" ]
109 then
110 sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
111 s/^\([[:space:]]*\)client code page/\1client code page/i
112 /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ {
113 /^[[:space:]]*client code page[[:space:]]*=/c \\
114 dos charset = $DOSCHARSET
115 }" < /etc/samba/smb.conf > ${TMPFILE}
116 mv -f ${TMPFILE} /etc/samba/smb.conf
120 if dpkg --compare-versions "$2" lt 2.999+3.0.alpha20-4 \
121 && ! grep -q "^[[:space:]]*panic action[[:space:]]*=" /etc/samba/smb.conf
122 then
123 sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
124 /^[[:space:]]*\[global\]/a \\
126 # Do something sensible when Samba crashes: mail the admin a backtrace\\
127 panic action = /usr/share/samba/panic-action %d" < /etc/samba/smb.conf > ${TMPFILE}
128 mv -f ${TMPFILE} /etc/samba/smb.conf
133 chmod a+r /etc/samba/smb.conf
135 # ------------------------- Debconf questions end ---------------------
137 db_stop
139 #DEBHELPER#