Initial import
[samba] / debian / samba.config
1 #!/bin/sh -e
2 #
3 #
4
5 # Source debconf library.
6 . /usr/share/debconf/confmodule
7
8 RCFILE=/etc/default/samba
9
10 # Function for grabbing a parameter from an smb.conf file
11 smbconf_retr() {
12         if [ -z "$1" ]; then
13                 return
14         fi
15
16         if [ -n "$2" ]; then
17                 local FILE="$2"
18         fi
19
20         if [ -z "$FILE" ]; then
21                 return
22         fi
23
24         sed -n -e"
25                 s/^[[:space:]]*\[global\]/\[global\]/i
26                 /^\[global\]/,/^[[:space:]]*\[/ {
27                         s/^[[:space:]]*$1[[:space:]]*=[[:space:]]*//pi
28                 }" $FILE \
29         | tail -n 1
30 }
31
32 read_rcfile() {
33     # Default values
34     if [ -f $RCFILE ]; then
35         . $RCFILE || true
36     fi
37 }
38
39 set_debconf() {
40     if [ -n "$RUN_MODE" ]; then
41         db_set samba/run_mode "$RUN_MODE" || true
42     fi
43 }
44
45 FILE=/etc/samba/smb.conf
46
47 db_title "Samba Server"
48
49 # Babysit users who don't read README.Debian
50 if [ -n "$2" ] && dpkg --compare-versions "$2" lt "2.2"
51 then
52         db_input medium samba/log_files_moved || true
53         db_go
54 fi
55
56
57 # We first read the settings file
58 # in order to get admin-modified settings
59 read_rcfile
60 # Debconf-stored values are updated accordingly
61 set_debconf
62 db_input medium samba/run_mode || true
63 db_go
64
65
66 # Offer to move the password database for existing users
67 if [ "$1" = "configure" -a -n "$2" -a -e /etc/samba/smbpasswd \
68      -a ! -e /var/lib/samba/passdb.tdb ] \
69    && dpkg --compare-versions "$2" lt 2.99.cvs.20020713-2
70 then
71         FILE=/etc/samba/smb.conf
72         PASSDB=""
73         if [ -f "$FILE" ]; then
74                 PASSDB=`smbconf_retr "passdb backend"`
75         fi
76         TDBPRIORITY=medium
77         if echo "$PASSDB" | grep -q ldapsam; then
78                 TDBPRIORITY=low
79         fi
80         db_get samba-common/do_debconf || true
81         if [ "${RET}" = "false" ]; then
82                 TDBPRIORITY=low
83         fi
84
85         db_input "$TDBPRIORITY" samba/tdbsam || true
86 fi
87
88 # We vary the priority of the next question depending on whether
89 #       the password database already exists...
90 if [ -e /etc/samba/smbpasswd -o -e /var/lib/samba/passdb.tdb ]; then
91         PRIORITY="low"
92 else
93         # If 'encrypt passwords' is true in smb.conf, and smbpasswd
94         # does not exist, default to yes here.
95         FILE=/etc/samba/smb.conf
96         if [ -f "$FILE" ]; then
97                 ENCRYPT=`smbconf_retr "encrypt passwords"`
98                 if [ "$ENCRYPT" ]; then
99                         ENCRYPT=`echo $ENCRYPT | tr '[A-Z]' '[a-z]'`
100                         if [ "$ENCRYPT" = "yes" ]; then
101                                 ENCRYPT=true
102                         fi
103                         if [ "$ENCRYPT" = "no" ]; then
104                                 ENCRYPT=false
105                         fi
106                 fi
107                 db_set samba/generate_smbpasswd "$ENCRYPT"
108         fi
109         PRIORITY="medium"
110 fi
111
112 db_input $PRIORITY samba/generate_smbpasswd || true
113 db_go