blob: fbef2ce1d90f7b51ae7e75e218d356afd9ed9b92 (
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
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
|
#!/bin/sh -e
# Source debconf library.
. /usr/share/debconf/confmodule
# Function for grabbing a parameter from an smb.conf file
smbconf_retr() {
if [ -z "$1" ]; then
return
fi
if [ -n "$2" ]; then
local FILE="$2"
fi
if [ -z "$FILE" ]; then
return
fi
sed -n -e"
s/^[[:space:]]*\[global\]/\[global\]/i
/^\[global\]/,/^[[:space:]]*\[/ {
s/^[[:space:]]*$1[[:space:]]*=[[:space:]]*//pi
}" $FILE \
| tail -n 1
}
FILE=/etc/samba/smb.conf
db_settitle samba-common/title
# We ask the question IFF the config contains complex options that could
# cause us to break the config.
if [ -f "$FILE" ] && grep -v dhcp.conf $FILE \
| grep -qEi '\\$|^[[:space:]]*include[[:space:]]*='
then
db_input high samba-common/do_debconf || true
db_go
else
db_set samba-common/do_debconf true
fi
# 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...
# Preload any values from the existing smb.conf file
if [ -f $FILE ]; then
WORKGROUP=`smbconf_retr workgroup`
if [ "$WORKGROUP" ]; then
db_set samba-common/workgroup "$WORKGROUP"
fi
ENCRYPT=`smbconf_retr "encrypt passwords"`
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 medium samba-common/workgroup || true
db_go
# Use encrypted passwords?
db_input medium samba-common/encrypt_passwords || true
db_go
DHCPPRIORITY=medium
#if [ "$DEBCONF_RECONFIGURE" = 1 ] && [ -f /sbin/dhclient3 ]
if [ -f /sbin/dhclient3 ]
then
DHCPPRIORITY=high
# TODO: see if we can detect that dhcp3-client is *going* to be installed,
# even if it isn't yet.
#elif dpkg-query -W --showformat='${Status}\n' dhcp3-client | grep ???
# unknown ok not-installed ?
# DHCPPRIORITY=high
fi
FOUND=false
if [ -f $FILE ]; then
if grep -q 'include[[:space:]]*=[[:space:]]*/etc/samba/dhcp.conf' $FILE
then
FOUND=true
fi
db_set samba-common/dhcp $FOUND
fi
# we only prompt in one of three cases: the file doesn't exist yet, it
# has the context we need to add our include line, or the include line
# is already present.
if [ ! -f $FILE ] || grep -q -i 'wins server' $FILE || [ "$FOUND" = "true" ];
then
db_input $DHCPPRIORITY samba-common/dhcp || true
db_go
fi
|