File: samba-common.postinst

package info (click to toggle)
samba 3.0.24-6
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 49,740 kB
  • ctags: 44,390
  • sloc: ansic: 335,711; sh: 8,133; perl: 7,045; makefile: 3,107; python: 2,370; exp: 1,147; yacc: 881; awk: 486; csh: 58; sed: 45
file content (113 lines) | stat: -rw-r--r-- 3,531 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/sh
#
#

set -e

# Do debconf stuff here
. /usr/share/debconf/confmodule

# We need a default smb.conf file. If one doesn't exist we put in place
#	one that has some basic defaults.
if [ ! -e /etc/samba/smb.conf ]; then
	cp -a /usr/share/samba/smb.conf /etc/samba/
fi

# Static tempfile location, dpkg-style
TMPFILE=/etc/samba/smb.conf.dpkg-tmp

# ------------------------- Debconf questions start ---------------------

# Is the user configuring with debconf, or he/she prefers swat/manual
#	config?
db_get samba-common/do_debconf || true
if [ "${RET}" = "true" ]; then
	# Get workgroup name
	db_get samba-common/workgroup || true
	WORKGROUP="${RET}"

	# Oh my GOD, this is ugly.  Why would anyone put these
	# characters in a workgroup name?  Why, Lord, why???
	WORKGROUP=`echo $WORKGROUP | \
	           sed -e's/\\\\/\\\\\\\\/g
	                  s#/#\\\\/#g
	                  s/&/\\\&/g
	                  s/\\\$/\\\\\\\$/g'`

	sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
		/^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
			s/^\([[:space:]]*\)workgroup[[:space:]]*=.*/\1workgroup = ${WORKGROUP}/i" \
		< /etc/samba/smb.conf >${TMPFILE}
	mv -f ${TMPFILE} /etc/samba/smb.conf

	# Encrypt passwords?
	db_get samba-common/encrypt_passwords || true
	ENCRYPT_PASSWORDS="${RET}"

	sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
		/^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
		        s/^\([[:space:]]*\)encrypt passwords[[:space:]]*=.*/\1encrypt passwords = ${ENCRYPT_PASSWORDS}/i" \
		< /etc/samba/smb.conf >${TMPFILE}
	mv -f ${TMPFILE} /etc/samba/smb.conf

	# Install DHCP support
	db_get samba-common/dhcp && DHCPVAL="$RET"
	db_fget samba-common/dhcp applied || true
	if [ "$DHCPVAL" = true ] && [ "$RET" != true ] && \
	   ! grep -q dhcp.conf /etc/samba/smb.conf
	then
		sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
			/^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ {
				/wins server[[:space:]]*=/a \\
\\
# If we receive WINS server info from DHCP, override the options above. \\
   include = /etc/samba/dhcp.conf
}" < /etc/samba/smb.conf > ${TMPFILE}
		mv -f ${TMPFILE} /etc/samba/smb.conf
	elif [ "$RET" != true ] && grep -q dhcp.conf /etc/samba/smb.conf
	then
		:
		# FIXME: here we /delete/ the lines?
	fi
	# Once we get here, the config has been applied, whatever
	# it is.
	if [ "$RET" != true ]; then
		db_fset samba-common/dhcp applied true
	fi

	if grep -qi "^[[:space:]]*passdb backend[[:space:]]*=.*unixsam" /etc/samba/smb.conf
	then
		sed -e 's/^\([[:space:]]*\)passdb backend/\1passdb backend/i
			/^[[:space:]]*passdb backend/ {
				s/unixsam/guest/i
			}' < /etc/samba/smb.conf > ${TMPFILE}
		mv -f ${TMPFILE} /etc/samba/smb.conf
	fi

	if [ -n "$2" ] && dpkg --compare-versions "$2" lt 3.0.23b-2 \
	   && grep -qi "^[[:space:]]*passdb backend[[:space:]]*=.*guest" /etc/samba/smb.conf
	then
		sed -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
			/^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
			        s/^\([[:space:]]*passdb backend[[:space:]]*=[^,]*\),\?[[:space:]]*guest[[:space:]]*$/\1/i" \
			< /etc/samba/smb.conf >${TMPFILE}
		mv -f ${TMPFILE} /etc/samba/smb.conf
	fi
fi

if [ -n "$2" ] && dpkg --compare-versions "$2" lt 3.0.23b-2 &&

   grep -qi '^[[:space:]]*passdb backend[[:space:]]*=[[:space:]]*[^,[:space:]]\+[,[:space:]][[:space:]]*[^[:space:]]\+' \
	/etc/samba/smb.conf
then
	db_input high samba-common/unsupported-passdb || true
	db_go
fi

chmod a+r /etc/samba/smb.conf

# ------------------------- Debconf questions end ---------------------

db_stop

#DEBHELPER#