File: amavisd-new.spec

package info (click to toggle)
amavisd-new 1:2.11.0-6.1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 12,432 kB
  • sloc: perl: 33,770; sh: 523; sql: 158; makefile: 8
file content (244 lines) | stat: -rw-r--r-- 6,404 bytes parent folder | download | duplicates (6)
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# Upstream: <amavis-user$lists,sf,net>
#
#

%define logmsg logger -t %{name}/rpm

Summary: Mail virus-scanner
Name: amavisd-new
Version: 2.6.0
Release: 1
License: GPL
Group: System Environment/Daemons
URL: http://www.ijs.si/software/amavisd/

Packager: Marius Andreiana <marius_andreiana@epon_ro>
Vendor: Amavisd-new

Source: http://www.ijs.si/software/amavisd/amavisd-new-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

Requires: arc >= 5.21e, nomarch >= 1.2, unrar >= 2.71, zoo >= 2.10
Requires: bzip2, cpio, file, freeze, lha, lzop, ncompress, unarj
Requires: perl(Archive::Tar), perl(Archive::Zip), perl(Compress::Zlib)
Requires: perl(Convert::TNEF), perl(Convert::UUlib), perl(IO::Stringy)
Requires: perl(MIME::Base64), perl(MIME::Tools), perl(Unix::Syslog)
Requires: perl(Time::HiRes), perl(Digest::MD5), perl(Digest::SHA1)
Requires: perl(Digest::HMAC), perl(Net::DNS), perl(Mail::SpamAssassin)
Requires: perl-MailTools, perl(Net::Server) >= 0.86, perl-HTML-Parser >= 3.24
Requires: perl(DB_File), perl(Mail::DKIM) >= 0.31
Obsoletes: amavisd

%description
AMaViS is a program that interfaces a mail transfer agent (MTA) with
one or more virus scanners.

Amavisd-new is a branch created by Mark Martinec that adds serveral
performance and robustness features. It's partly based on
work being done on the official amavisd branch. Please see the
README.amavisd-new-RELNOTES file for a detailed description.

%prep
%setup -n amavisd-new-%{version}

%{__cat} <<'EOF' >amavisd.sysconfig
EOF

%{__cat} <<'EOF' >amavisd.sysv
#!/bin/bash
#
# Init script for AMaViS email virus scanner.
#
# Written by Dag Wieers <dag@wieers.com>.
# Modified by Marius Andreiana.
#
# chkconfig: 2345 79 31
# description: AMaViS virus scanner.
#
# processname: amavisd
# config: %{_sysconfdir}/amavisd.conf
# pidfile: %{_localstatedir}/run/amavisd.pid

source %{_initrddir}/functions

[ -x %{_sbindir}/amavisd ] || exit 1
[ -r %{_sysconfdir}/amavisd.conf ] || exit 1

### Default variables
AMAVIS_ACCOUNT="amavis"
SYSCONFIG="%{_sysconfdir}/sysconfig/amavisd"
prog_config_file=%{_sysconfdir}/amavisd.conf

### Read configuration
[ -r "$SYSCONFIG" ] && source "$SYSCONFIG"

RETVAL=0
prog="amavisd"
desc="Mail Virus Scanner"

start() {
	echo -n $"Starting $desc ($prog): "
	daemon --user "$AMAVIS_ACCOUNT" %{_sbindir}/$prog -c $prog_config_file
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch %{_localstatedir}/lock/subsys/$prog
	return $RETVAL
}

stop() {
	echo -n $"Shutting down $desc ($prog): "
	su - $AMAVIS_ACCOUNT -c "%{_sbindir}/$prog -c $prog_config_file stop"
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f %{_localstatedir}/lock/subsys/$prog
	return $RETVAL
}

reload() {
	echo -n $"Reloading $desc ($prog): "
	su - $AMAVIS_ACCOUNT -c "%{_sbindir}/$prog -c $prog_config_file reload"
	RETVAL=$?
	echo
	return $RETVAL
}

restart() {
	stop
	start
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	restart
	;;
  reload)
	reload
	;;
  condrestart)
	[ -e %{_localstatedir}/lock/subsys/$prog ] && restart
	RETVAL=$?
	;;
  status)
	status $prog
	RETVAL=$?
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
	RETVAL=1
esac

exit $RETVAL
EOF

%build

%install
%{__rm} -rf %{buildroot}
%{__install} -d -m0755 %{buildroot}%{_sbindir}

%{__perl} -pi.orig -e '
		s|=\s*'\''vscan'\''|= "amavis"|;
		s|^#*(\$MYHOME)\s*=.*$|$1 = "%{_localstatedir}/spool/amavis";|;
		s|^#*(\$QUARANTINEDIR)\s*=.*$|$1 = "\$MYHOME/virusmails";|
	' amavisd.conf

%{__install} -d -m0700 %{buildroot}%{_localstatedir}/spool/amavis/virusmails/
%{__install} -d -m0700 %{buildroot}%{_localstatedir}/amavis/tmp
%{__install} -d -m0700 %{buildroot}%{_localstatedir}/amavis/db

%{__install} -D -m0755 amavisd %{buildroot}%{_sbindir}/amavisd
%{__install} -D -m0755 amavisd-nanny %{buildroot}%{_sbindir}/amavisd-nanny
%{__install} -D -m0755 amavisd-agent %{buildroot}%{_sbindir}/amavisd-agent
%{__install} -D -m0755 p0f-analyzer.pl %{buildroot}%{_sbindir}/p0f-analyzer.pl
%{__install} -D -m0755 amavisd.sysv %{buildroot}%{_initrddir}/amavisd
%{__install} -D -m0700 amavisd.conf %{buildroot}%{_sysconfdir}/amavisd.conf
%{__install} -D -m0644 LDAP.schema %{buildroot}%{_sysconfdir}/openldap/schema/amavisd-new.schema
%{__install} -D -m0644 amavisd.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/amavisd

%clean
%{__rm} -rf %{buildroot}

%pre
/usr/sbin/useradd -c "AMaViS email scanner user" -M -s /bin/sh -r amavis \
		-d "/var/spool/amavis" &>/dev/null || :

%post
/sbin/chkconfig --add amavisd

if [ -r /etc/postfixes/aliases ]; then
	if ! grep -q "^virusalert:" /etc/postfix/aliases; then
		echo -e "virusalert:\troot" >> /etc/postfix/aliases
		if [ -x /usr/bin/newaliases ]; then
			/usr/bin/newaliases &>/dev/null
		else
			%logmsg "Cannot exec newaliases. Please run it manually."
		fi
	fi
fi

if [ -r /etc/mail/aliases ]; then
	if ! grep -q "^virusalert:" /etc/mail/aliases; then
		echo -e "virusalert:\troot" >> /etc/mail/aliases
		if [ -x /usr/bin/newaliases ]; then
			/usr/bin/newaliases &>/dev/null
		else
			%logmsg "Cannot exec newaliases. Please run it manually."
		fi
	fi
fi

%preun
if [ $1 -eq 0 ] ; then
    /sbin/service amavisd stop &>/dev/null || :
    /sbin/chkconfig --del amavisd
fi

%postun
if [ $1 -ne 0 ]; then
    /sbin/service amavisd condrestart &>/dev/null || :
fi

if [ "`getent passwd amavis`" ]; then
    echo -en "removing user amavis.\n"
    /usr/sbin/userdel "amavis" 2>/dev/null || :
fi
if [ "`getent group amavis`" ]; then
    echo -en "removing group amavis.\n"
    /usr/sbin/groupdel "amavis" 2>/dev/null || :
fi

%files
%defattr(-, root, root, 0755)
%doc AAAREADME.first LDAP.schema LICENSE MANIFEST RELEASE_NOTES README_FILES/* test-messages/
%config %{_initrddir}/amavisd
%config %{_sysconfdir}/openldap/schema/*.schema
#%{_sbindir}/amavis
%{_sbindir}/amavisd

%defattr(0640, root, amavis, 0755)
%config(noreplace) %{_sysconfdir}/amavisd.conf
%config(noreplace) %{_sysconfdir}/sysconfig/amavisd

%defattr(0700, amavis, amavis, 0700)
%dir %{_localstatedir}/spool/amavis/
%dir %{_localstatedir}/spool/amavis/virusmails/
%dir %{_localstatedir}/amavis
%dir %{_localstatedir}/amavis/tmp
%dir %{_localstatedir}/amavis/db


%changelog
* Mon Oct 06 2004  Marius Andreiana
- Use amavisd's stop, reload, as Mark suggested
- remove amavis user/group on uninstall
- fix perms on /var/amavis

* Mon Oct 04 2004  Marius Andreiana
- Initial release, changed DAG's spec file