summaryrefslogtreecommitdiff
path: root/debian/postinst
blob: 6c4ecbc4a827dd33940f49cdb06fe13515036034 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh -e
#
# Debian package postinst
# Version 1.2
#
# Robert Leslie <rob@mars.org>

case "$1" in
    configure)
	# continue below
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
	exit 0
    ;;

    *)
	echo "postinst called with unknown argument \`$1'" >&2
	exit 0
    ;;
esac

if [ -e /etc/suid.conf -a -x /usr/sbin/suidregister ]; then
	suidregister -s sendmail /usr/sbin/sendmail root root 4755
else
	chown root.root /usr/sbin/sendmail
	chmod 4755 /usr/sbin/sendmail
fi

if [ ! -d /etc/mail ]
then
    mkdir /etc/mail
    chown 0.0 /etc/mail
    chmod 755 /etc/mail
fi

if [ ! -d /var/spool/mqueue ]
then
    mkdir /var/spool/mqueue
    chown 0.0 /var/spool/mqueue
    chmod 700 /var/spool/mqueue
fi

if [ ! -f /var/log/sendmail.st ]
then
    touch /var/log/sendmail.st
    chown 0.0 /var/log/sendmail.st
    chmod 644 /var/log/sendmail.st
fi

update-rc.d sendmail defaults >/dev/null
update-inetd --disable smtp

# Move old configuration files to their new home

if [ -f /etc/sendmail.cf -a  \
    ! -L /etc/sendmail.cf -a  \
    ! -f /etc/mail/sendmail.cf ]
then
    echo "This version of the Debian sendmail package keeps its configuration"
    echo "files under /etc/mail. You already have some sendmail configuration"
    echo -n "files in /etc; would you like to move them to /etc/mail? [Y] "
    read yn
    test -n "$yn" || yn="Y"

    case "$yn" in
	[Yy]*)
	    echo "Moving /etc/sendmail.* to /etc/mail ..."
	    mv -f /etc/sendmail.* /etc/mail/.

	    test ! -f /etc/mail/sendmail.cf ||  \
		mv -f /etc/mail/sendmail.cf /etc/mail/sendmail.cf.old
	;;

	*)
	    echo "Okay, leaving them where they are; they won't be used."
	;;
    esac
fi

# Make sure /etc/sendmail.cf points to /etc/mail/sendmail.cf

if [ -e /etc/sendmail.cf ]
then
    if [ -L /etc/sendmail.cf ]
    then
	rm -f /etc/sendmail.cf
    else
	echo "Saving old /etc/sendmail.cf as /etc/sendmail.cf.old ..."
	mv -f /etc/sendmail.cf /etc/sendmail.cf.old
    fi
fi

ln -sf mail/sendmail.cf /etc/sendmail.cf

# Check existing /etc/mail/sendmail.cf

if [ -f /etc/mail/sendmail.cf ]
then
    if (sed -n -e "/^DZ/s/^DZ//p" /etc/mail/sendmail.cf \
	| grep 8.8.8 > /dev/null)
    then
	echo "Existing /etc/mail/sendmail.cf found, and it appears it may be"
	echo -n "compatible with this version of sendmail.  Use it? [Y] "
	read yn
	test -n "$yn" || yn="Y"
    else
	echo "Existing /etc/mail/sendmail.cf found, but it was made for"
	echo -n "an older version of sendmail.  Use it anyway? [N] "
	read yn
	test -n "$yn" || yn="N"
    fi

    case "$yn" in
	[Yy]*)
	;;

	*)
	    echo "Saving old /etc/mail/sendmail.cf"  \
		"as /etc/mail/sendmail.cf.old ..."
	    mv -f /etc/mail/sendmail.cf /etc/mail/sendmail.cf.old
	;;
    esac
fi

test -f /etc/mail/sendmail.cf || sendmailconfig --no-reload

# Start server

echo -n "Start sendmail now? [Y] "
read yn
test -n "$yn" || yn="Y"

case "$yn" in
    [Nn]*)
	echo "Not started; to start later, do: /etc/init.d/sendmail start"
	echo -n "Press [ENTER] "
	read line
    ;;

    *)
	/etc/init.d/sendmail start
    ;;
esac