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