source: samba/trunk/fuentes/samba-common.postinst @ 4744

Last change on this file since 4744 was 4744, checked in by hectorgh, 4 years ago

adding modified files

File size: 2.7 KB
Line 
1#!/bin/sh
2#
3#
4
5set -e
6
7# Do debconf stuff here
8. /usr/share/debconf/confmodule
9
10TEMPDIR=/var/run/samba/upgrades
11NEWFILE=$TEMPDIR/smb.conf
12CONFIG=/etc/samba/smb.conf
13
14# ------------------------- Debconf questions start ---------------------
15
16configure_smb_conf() {
17        local CONFIG
18        CONFIG="$1"
19
20        # Is the user configuring with debconf, or he/she prefers
21        # swat/manual config?
22        return 0
23        db_get samba-common/do_debconf || true
24        if [ "${RET}" != "true" ]; then
25                return 0
26        fi
27
28        # Get workgroup name
29        db_get samba-common/workgroup || true
30        WORKGROUP="${RET}"
31
32        # Oh my GOD, this is ugly.  Why would anyone put these
33        # characters in a workgroup name?  Why, Lord, why???
34        WORKGROUP=`echo $WORKGROUP | \
35                   sed -e's/\\\\/\\\\\\\\/g
36                          s#/#\\\\/#g
37                          s/&/\\\&/g
38                          s/\\\$/\\\\\\\$/g'`
39
40        sed -i -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
41                /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ \
42                        s/^\([[:space:]]*\)workgroup[[:space:]]*=.*/\1workgroup = ${WORKGROUP}/i" \
43                "$CONFIG"
44
45        # Install DHCP support
46        db_get samba-common/dhcp
47        if [ "$RET" = true ] && \
48           ! grep -q dhcp.conf "$CONFIG"
49        then
50                sed -i -e "s/^\([[:space:]]*\)\[global\]/\1\[global\]/i
51                        /^[[:space:]]*\[global\]/,/^[[:space:]]*\[/ {
52                                /wins server[[:space:]]*=/a \\
53\\
54# If we receive WINS server info from DHCP, override the options above. \\
55   include = /etc/samba/dhcp.conf
56}" "$CONFIG"
57        elif [ "$RET" != true ]; then
58                sed -i -e '
59                /^#[[:space:]]*If we receive WINS server info from DHCP, override the options above/d
60                /^#*[[:space:]]*include[[:space:]]*=[[:space:]]*\/etc\/samba\/dhcp.conf/,/[^[:space:]]/ {
61                        /^#*[[:space:]]*include[[:space:]]*=[[:space:]]*\/etc\/samba\/dhcp.conf/d
62                        /^[[:space:]]*$/d
63                }' "$CONFIG"
64        fi
65
66}
67
68
69if [ -e "$CONFIG" ]; then
70        configure_smb_conf "$CONFIG"
71fi
72
73mkdir -p "$TEMPDIR"
74
75cp /usr/share/samba/smb.conf "$NEWFILE"
76configure_smb_conf "$NEWFILE"
77
78if [ -e "$CONFIG" ]; then
79        sed -e '1,/^[;#[:space:]]*\[cdrom\]/ { d }
80                1,/^[[:space:]]*\[/ { /^[^[]/d; /^$/d }
81        ' "$CONFIG" >> "$NEWFILE"
82fi
83
84ucf --three-way --debconf-ok "$NEWFILE" "$CONFIG"
85
86if [ ! -e "$CONFIG" ]; then
87        echo "Install/upgrade will fail. To recover, please try:"
88        echo " sudo cp /usr/share/samba/smb.conf $CONFIG"
89        echo " sudo dpkg --configure -a"
90else
91        ucfr samba-common "$CONFIG"
92        chmod a+r "$CONFIG"
93fi
94
95# ------------------------- Debconf questions end ---------------------
96
97db_stop
98
99#DEBHELPER#
100
101# Clean up the now-empty dir which our conffile was previously in,
102# since it wasn't empty at the time dpkg could automatically remove it
103# for us.
104if dpkg --compare-versions "$2" lt-nl 2:4.1.4+dfsg-2~
105then
106        rmdir -p --ignore-fail-on-non-empty /etc/dhcp3/dhclient-enter-hooks.d
107fi
108
109
Note: See TracBrowser for help on using the repository browser.