summaryrefslogtreecommitdiffstats
path: root/packaging/Debian/debian/samba-common.config
blob: c82dd887b06cf88cfd13f264dc022e1be8b792c3 (plain)
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
#/bin/sh -e

# Source debconf library.
. /usr/share/debconf/confmodule

FILE=/etc/samba/smb.conf

db_title "Samba Server"

db_input medium samba-common/do_debconf || true
db_go

# If user doesn't want to use debconf to configure Samba the leave...
db_get samba-common/do_debconf || true
if [ "${RET}" = "false" ]; then
	exit 0
fi

# User wants to use debconf, let's continue...

# Adjust priority of the question about the workgroup name depending
# on whether a workgroup name has already being specified.
db_get samba-common/workgroup || true
if [ "${RET}" ]; then
	WGPRIORITY=medium
else
	WGPRIORITY=high
fi

# Preload any values from the existing smb.conf file
if [ -f $FILE ]; then
	WORKGROUP=`grep -i '^[[:space:]]*workgroup[[:space:]]*=' $FILE \
	           | sed -e's/^[[:space:]]*workgroup[[:space:]]*=[[:space:]]*//i' \
	           | tail -1`
	if [ "$WORKGROUP" ]; then
		db_set samba-common/workgroup "$WORKGROUP"
	fi

	ENCRYPT=`grep -i '^[[:space:]]*encrypt passwords[[:space:]]*=' $FILE \
	         | sed -e's/^[[:space:]]*encrypt passwords[[:space:]]*=[[:space:]]*//i' \
	         | tail -1`
	if [ "$ENCRYPT" ]; then
		ENCRYPT=`echo $ENCRYPT | tr '[A-Z]' '[a-z]'`
		if [ "$ENCRYPT" = "yes" ]; then
			ENCRYPT=true
		elif [ "$ENCRYPT" = "no" ]; then
			ENCRYPT=false
		fi

		db_set samba-common/encrypt_passwords "$ENCRYPT"
	fi
fi

# Get workgroup name
db_input $WGPRIORITY samba-common/workgroup || true
db_go

# Use encrypted passwords?
db_input medium samba-common/encrypt_passwords || true
db_go