-
Notifications
You must be signed in to change notification settings - Fork 1
/
maild-installer
executable file
·106 lines (73 loc) · 2.04 KB
/
maild-installer
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
#!/bin/sh -e
# $Header: /repo/cvs.copy/maild/maild-installer,v 1.7 2005/06/14 22:32:31 dancy Exp $
# Checks for the existence of a file or symlink
function EXISTS {
[ -L "$1" -o -e "$1" ]
}
# Returns true if thing exists but is not a symlink
function NON_SYMLINK {
[ ! -L "$1" -a -e "$1" ]
}
function migrate {
if ! EXISTS "$1.sendmail" && NON_SYMLINK "$1"; then
mv "$1" "$1.sendmail"
fi
ln -nsf /usr/local/sbin/maild "$1"
}
if [ `id -u` -ne 0 ]; then
echo Maild installation requires root privileges
exit 1
fi
lib=/usr/local/lib
if [ -x /etc/init.d/maild ] && /etc/init.d/maild status; then
/etc/init.d/maild stop
restart_maild=t
fi
echo Preparing...
mkdir -p $lib /usr/local/sbin /var/spool/maild
if [ -e $lib/maild.old ]; then
echo Removing prior backup installation...
rm -r $lib/maild.old
fi
if [ -e $lib/maild ]; then
echo Making backup of current installation...
mv $lib/maild $lib/maild.old
fi
echo Extracting...
(cd $lib && tar zxf -) < maild.tar.gz
echo Installing...
chown -R root:root $lib/maild
chmod +s $lib/maild/maild
ln -snf $lib/maild/maild /usr/local/sbin/maild
ln -snf $lib/maild/maild /usr/local/sbin/maild-mailq
if [ -e /etc/init.d/maild ]; then
mv /etc/init.d/maild /etc/init.d/maild.old
fi
mv maild.init /etc/init.d/maild
if [ -e /etc/init.d/maild.old ]; then
if diff /etc/init.d/maild.old /etc/init.d/maild >/dev/null; then
rm /etc/init.d/maild.old
fi
fi
if [ ! -e /etc/sysconfig/maild ]; then
echo QUEUE=15m > /etc/sysconfig/maild
fi
if [ -x /usr/sbin/alternatives ]; then
/usr/sbin/alternatives --install \
/usr/sbin/sendmail mta /usr/local/sbin/maild 95 \
--slave /usr/bin/mailq mta-mailq /usr/local/sbin/maild-mailq \
--initscript maild
/usr/sbin/alternatives --auto mta
else
migrate /usr/sbin/sendmail
migrate /usr/bin/mailq
fi
if [ ! -L /usr/lib/sendmail ]; then
ln -snf ../sbin/sendmail /usr/lib/sendmail
fi
echo Cleaning up
rm maild.tar.gz $0
if [ -n "$restart_maild" ]; then
/etc/init.d/maild start
fi
echo Done.