File: sendmail.postinst

package info (click to toggle)
sendmail 8.9.3-3slink1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 4,744 kB
  • ctags: 2,997
  • sloc: ansic: 40,418; perl: 2,044; sh: 1,466; makefile: 319
file content (176 lines) | stat: -rw-r--r-- 4,365 bytes parent folder | download
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/bin/sh -e
#
# Debian package postinst
# Version 1.2
#
# Robert Leslie <rob@mars.org>
# Note: can't use debhelper here because the actions aren't contiguous

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 [ "$2" == "" ]; then echo "first time"; fi

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

#-----------------------------------------------------------
if test "$1" = configure && dpkg --compare-versions "$2" lt 8.9.1-13; then
   echo " "
   echo "*** IMPORTANT ***"
   echo " "
   echo "The format of sendmails databases has changed (now using libdb2)."
   echo "You *MUST* update your databases (newaliases, users, etc.)"
   echo "before allowing sendmail to restart."
   echo " "
   echo "Press <Enter> to continue"  
   read yn
   fi
   
#-----------------------------------------------------------
# Check existing /etc/mail/sendmail.cf

if [ -f /etc/mail/sendmail.cf ]; then
    if test "$1" = configure && dpkg --compare-versions "$2" lt 8.9.2; then
	echo " "
	echo "*** IMPORTANT ***"
	echo " "
	echo "This version of sendmail moves more configuration files from"
	echo "/etc/... to /etc/mail/... ie: domaintable,genericstable, etc."
	echo " "
	echo "If you you use any of these, you *MUST*:"     
	echo "  1)" 
	echo "    A) Move them by hand from /etc/... to /etc/mail/..."
	echo "    B) Move any script to create databases from the text"
	echo "    or"
	echo "  2) Update your sendmail.mc to explicitly name the file"
	echo "     FEATURE(genericstable, \`hash -o /etc/mail/genericstable.db')dnl" 
	echo " "
	echo "Press <Enter> to continue"
	read yn
	fi
    if (sed -n -e "/^DZ/s/^DZ//p" /etc/mail/sendmail.cf \
    	| grep "8.9.3" > /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