-
Notifications
You must be signed in to change notification settings - Fork 7
/
afd.spec.in
485 lines (455 loc) · 13.3 KB
/
afd.spec.in
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
Summary: A file distribution and fetching system
Name: afd
Version: @AFD_VERSION@
Release: 1%{?dist}
License: GPLv2
Group: Applications/Communications
Prefix: @prefix@
Source0: %{name}-%{version}.tar.bz2
Requires: @REQUIRES@
%if 0%{?rhl}%{?fedora}%{?rhel}
BuildRequires: @BUILD_REQUIRES_REDHAT@
%else
BuildRequires: @BUILD_REQUIRES@
%endif
URL: https://www.dwd.de/AFD/
%define distro_style_rpms @DISTRO_STYLE_RPMS@
%define INITDIR @INITDIR@
%define BINARY_OWNER @BINARY_OWNER@
%define BINARY_GROUP @BINARY_GROUP@
%define with_systemd @WITH_SYSTMD@
%define with_afdmon @WITH_AFD_MON_SPEC@
%define cleaned_configure_args @cleaned_configure_args@
%define with_dir_check_cap_chown @WITH_DIR_CHECK_CAP_CHOWN@
%if %{distro_style_rpms}
%define prefix %{_prefix}
%define bindir %{_bindir}
%define sbindir %{_sbindir}
%define mandir %{_mandir}
%define docdir %{_docdir}
%define share %{_datadir}
%if %{with_systemd}
%define sysconfdir %{_sysconfdir}
%else
%define sysconfdir %{_sysconfdir}/sysconfig
%endif
%define rundir %{_rundir}
%else
%define prefix @prefix@
%define bindir @bindir@
%define sbindir @sbindir@
%define mandir @mandir@
%define docdir @docdir@
%define share @datadir@
%if %{with_systemd}
%define sysconfdir /etc
%else
%define sysconfdir @SYSCONFIGDIR@
%endif
%define rundir /run
%endif
%description
The Automatic File Distributor provides a framework for very flexible,
non-stop, log and debug-able delivery of an arbitrary amount of files to
multiple recipients as expressed in URLs (currently mailing, ftp, ftps,
sftp and http supported with the mailto://user@domain and
ftp://user:password@host URL conventions).
%prep
%setup -n %{name}-%{version}
%build
if [ -x %{bindir}/getconf ]; then
CPUS=`getconf _NPROCESSORS_ONLN`
fi
if test "x$CPUS" = "x" -o "x$CPUS" = "x0"; then
CPUS=1
fi
%if %{distro_style_rpms}
%configure
%else
./configure '--libdir=%{prefix}/%{_lib}' %{?cleaned_configure_args}
%endif
make -j$CPUS
%install
if [ ! "$RPM_BUILD_ROOT" = "/" ]
then
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{prefix} $RPM_BUILD_ROOT/%{prefix}/bin $RPM_BUILD_ROOT/%{prefix}/sbin $RPM_BUILD_ROOT/%{prefix}/etc
mkdir -p $RPM_BUILD_ROOT/%{INITDIR}
%if %{with_systemd}
mkdir -p $RPM_BUILD_ROOT/%{sysconfdir}/afd
%if %{with_afdmon}
mkdir -p $RPM_BUILD_ROOT/%{sysconfdir}/afdmon
%endif
mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
%else
mkdir -p $RPM_BUILD_ROOT/%{sysconfdir}
%endif
else
if [ ! -d $RPM_BUILD_ROOT/%{prefix} ]
then
mkdir -p $RPM_BUILD_ROOT/%{prefix} $RPM_BUILD_ROOT/%{prefix}/bin $RPM_BUILD_ROOT/%{prefix}/sbin $RPM_BUILD_ROOT/%{prefix}/etc
else
if [ ! -d $RPM_BUILD_ROOT/%{prefix}/bin ]
then
mkdir $RPM_BUILD_ROOT/%{prefix}/bin
fi
if [ ! -d $RPM_BUILD_ROOT/%{prefix}/sbin ]
then
mkdir $RPM_BUILD_ROOT/%{prefix}/sbin
fi
if [ ! -d $RPM_BUILD_ROOT/%{prefix}/etc ]
then
mkdir $RPM_BUILD_ROOT/%{prefix}/etc
fi
fi
if [ ! -d $RPM_BUILD_ROOT/%{INITDIR} ]
then
mkdir -p $RPM_BUILD_ROOT/%{INITDIR}
fi
%if %{with_systemd}
if [ ! -d $RPM_BUILD_ROOT/%{_unitdir} ]
then
mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
fi
if [ ! -d $RPM_BUILD_ROOT/%{sysconfdir}/afd ]
then
mkdir -p $RPM_BUILD_ROOT/%{sysconfdir}/afd
fi
%if %{with_afdmon}
if [ ! -d $RPM_BUILD_ROOT/%{sysconfdir}/afdmon ]
then
mkdir -p $RPM_BUILD_ROOT/%{sysconfdir}/afdmon
fi
%endif
%else
if [ ! -d $RPM_BUILD_ROOT/%{sysconfdir} ]
then
mkdir -p $RPM_BUILD_ROOT/%{sysconfdir}
fi
%endif
fi
make DESTDIR=$RPM_BUILD_ROOT install
%if %{with_systemd}
install -p -m644 scripts/[email protected] $RPM_BUILD_ROOT/%{_unitdir}
install -p -m644 scripts/afd.target $RPM_BUILD_ROOT/%{_unitdir}
install -p -m644 scripts/afd_environment.conf $RPM_BUILD_ROOT/%{sysconfdir}/afd
%if %{with_afdmon}
install -p -m644 scripts/[email protected] $RPM_BUILD_ROOT/%{_unitdir}
install -p -m644 scripts/afdmon.target $RPM_BUILD_ROOT/%{_unitdir}
install -p -m644 scripts/afdmon_environment.conf $RPM_BUILD_ROOT/%{sysconfdir}/afdmon
%endif
%else
install -p -m755 scripts/afd $RPM_BUILD_ROOT/%{INITDIR}
install -p -m644 scripts/afd.sysconfig $RPM_BUILD_ROOT/%{sysconfdir}/afd
%if %{with_afdmon}
install -p -m755 scripts/afdmon $RPM_BUILD_ROOT/%{INITDIR}
install -p -m644 scripts/afdmon.sysconfig $RPM_BUILD_ROOT/%{sysconfdir}/afdmon
%endif
%endif
%clean
if [ ! "$RPM_BUILD_ROOT" = "/" ]
then
rm -rf $RPM_BUILD_ROOT
fi
%post
if [ "$1" = 1 ]
then
%if %{with_systemd}
systemctl enable afd.target --no-pager
%if %{with_afdmon}
systemctl enable afdmon.target --no-pager
%endif
%else
if [ -x sbin/chkconfig ]
then
sbin/chkconfig --add %{name}
%if %{with_afdmon}
sbin/chkconfig --add afdmon
%endif
fi
%endif
else
%if %{with_systemd}
if [ -f /tmp/.afd.condrestart ]
then
AFD_INSTANCES="`grep ^afd@ /tmp/.afd.condrestart`"
for afd_instance in $AFD_INSTANCES
do
if [ ! -f /etc/systemd/system/afd.target.wants/$afd_instance ]
then
systemctl start $afd_instance
if [ $? -eq 0 ]
then
echo "Conditional start of $afd_instance"
else
echo "Failed to do conditional start of $afd_instance"
fi
fi
done
rm -f /tmp/.afd.condrestart
fi
systemctl start afd.target --no-pager
%if %{with_afdmon}
if [ -f /tmp/.afdmon.condrestart ]
then
AFDMON_INSTANCES="`grep ^afdmon@ /tmp/.afdmon.condrestart`"
for afdmon_instance in $AFDMON_INSTANCES
do
if [ ! -f /etc/systemd/system/afdmon.target.wants/$afdmon_instance ]
then
systemctl start $afdmon_instance
if [ $? -eq 0 ]
then
echo "Conditional start of $afdmon_instance"
else
echo "Failed to do conditional start of $afdmon_instance"
fi
fi
done
rm -f /tmp/.afdmon.condrestart
fi
systemctl start afdmon.target --no-pager
%endif
%else
/etc/init.d/afd condrestart > /dev/null 2>&1 || :
%if %{with_afdmon}
/etc/init.d/afdmon condrestart > /dev/null 2>&1 || :
%endif
%endif
fi
%pre
if [ "$1" != 1 ]
then
%if %{with_systemd}
systemctl status afd.target --no-pager
if [ "$?" = 0 ]
then
rm -f /tmp/.afd.condrestart
cd %{rundir} && ls -d afd@*.service > /tmp/.afd.condrestart
systemctl stop afd.target --no-pager
fi
%if %{with_afdmon}
systemctl status afdmon.target --no-pager
if [ "$?" = 0 ]
then
rm -f /tmp/.afdmon.condrestart
cd %{rundir} && ls -d afdmon@*.service > /tmp/.afdmon.condrestart
systemctl stop afdmon.target --no-pager
fi
%endif
%else
if [ -r %{sysconfdir}/afd ]
then
AFD_USERS="`grep \^AFD_USER_ %{sysconfdir}/afd | cut -d '=' -f2` `grep \^AFD_HA_USER_ %{sysconfdir}/afd | cut -d '=' -f2`"
else
AFD_USERS=""
fi
if [ -d /var/lock/subsys ]
then
SYS_LOCKDIR="/var/lock/subsys"
else
SYS_LOCKDIR="/var/lock"
fi
if [ ! "$AFD_USERS" = "" ]
then
for afduser in $AFD_USERS
do
USER_HOME_DIR="`grep \^${afduser}: /etc/passwd | cut -d ':' -f 6`"
if [ -d $USER_HOME_DIR ]
then
AFD_WORK_DIR_LIST=`su - $afduser -c 'echo MULTIAFDDIRS:\$MULTI_AFD_DIRS' | grep "^MULTIAFDDIRS:" | cut -d: -f2`
if [ "$AFD_WORK_DIR_LIST" = "" ]
then
su - $afduser -c "afd -c" > /dev/null 2>&1
if [ "$?" = 5 ]
then
touch $SYS_LOCKDIR/restart_afd.$afduser
fi
su - $afduser -c "afd -S"
if [ $? -eq 0 ]
then
rm -f $SYS_LOCKDIR/afd.$afduser
fi
else
counter=0
for afddir in $AFD_WORK_DIR_LIST
do
su - $afduser -c "afd -w $afddir -c" > /dev/null 2>&1
if [ "$?" = 5 ]
then
touch $SYS_LOCKDIR/restart_afd.$afduser-$counter
fi
su - $afduser -c "afd -w $afddir -S"
if [ $? -eq 0 ]
then
rm -f $SYS_LOCKDIR/afd.$afduser-$counter
fi
counter=`expr "$counter" + 1`
done
fi
else
echo "Unable to determine status of AFD for user $afduser, since home directory is missing."
fi
done
fi
%if %{with_afdmon}
if [ -r %{sysconfdir}/afdmon ]
then
AFDMON_USERS="`grep \^AFDMON_USER_ %{sysconfdir}/afdmon | cut -d '=' -f2` `grep \^AFDMON_HA_USER_ %{sysconfdir}/afdmon | cut -d '=' -f2`"
else
AFDMON_USERS=""
fi
if [ ! "$AFDMON_USERS" = "" ]
then
for afduser in $AFDMON_USERS
do
USER_HOME_DIR="`grep \^${afduser}: /etc/passwd | cut -d ':' -f 6`"
if [ -d $USER_HOME_DIR ]
then
su - $afduser -c "mafd -c" > /dev/null 2>&1
if [ "$?" = 5 ]
then
touch $SYS_LOCKDIR/restart_afdmon.$afduser
fi
su - $afduser -c "mafd -S"
if [ $? -eq 0 ]
then
rm -f $SYS_LOCKDIR/afdmon.$afduser
fi
else
echo "Unable to determine status of AFDMON for user $afduser, since home directory is missing."
fi
done
fi
%endif
%endif
fi
%preun
if [ "$1" = 0 ]
then
%if %{with_systemd}
%systemd_preun afd.target
%if %{with_afdmon}
%systemd_preun afdmon.target
%endif
%else
%{INITDIR}/afd stop > /dev/null 2>&1 || :
if [ -r %{sysconfdir}/afd ]
then
AFD_HA_USERS="`grep \^AFD_HA_USER_ %{sysconfdir}/afd | cut -d '=' -f2`"
else
AFD_HA_USERS=""
fi
if [ ! "$AFD_HA_USERS" = "" ]
then
for afduser in $AFD_HA_USERS
do
USER_HOME_DIR="`grep \^${afduser}: /etc/passwd | cut -d ':' -f 6`"
if [ -d $USER_HOME_DIR ]
then
AFD_WORK_DIR_LIST=`su - $afduser -c 'echo MULTIAFDDIRS:\$MULTI_AFD_DIRS' | grep "^MULTIAFDDIRS:" | cut -d: -f2`
if [ "$AFD_WORK_DIR_LIST" = "" ]
then
su - $afduser -c "afd -S"
else
for afddir in $AFD_WORK_DIR_LIST
do
su - $afduser -c "afd -w $afddir -S"
done
fi
else
echo "Unable to determine shutdown AFD for user $afduser, since home directory is missing."
fi
done
fi
if [ -x sbin/chkconfig ]
then
sbin/chkconfig --del %{name}
fi
%if %{with_afdmon}
%{INITDIR}/afdmon stop > /dev/null 2>&1 || :
if [ -r %{sysconfdir}/afdmon ]
then
AFDMON_HA_USERS="`grep \^AFDMON_HA_USER_ %{sysconfdir}/afdmon | cut -d '=' -f2`"
else
AFDMON_HA_USERS=""
fi
if [ ! "$AFDMON_HA_USERS" = "" ]
then
for afduser in $AFDMON_HA_USERS
do
su - $afduser -c "mafd -S"
done
fi
if [ -x sbin/chkconfig ]
then
sbin/chkconfig --del afdmon
fi
%endif
%endif
fi
exit 0
%files
%defattr(-,root,root)
%if %{with_systemd}
%{_unitdir}/[email protected]
%{_unitdir}/afd.target
%config(noreplace) %{sysconfdir}/afd/afd_environment.conf
%if %{with_afdmon}
%{_unitdir}/[email protected]
%{_unitdir}/afdmon.target
%config(noreplace) %{sysconfdir}/afdmon/afdmon_environment.conf
%endif
%else
%config(noreplace) %{sysconfdir}/afd
%{INITDIR}/afd
%if %{with_afdmon}
%config(noreplace) %{sysconfdir}/afdmon
%{INITDIR}/afdmon
%endif
%endif
%doc %{docdir}/*
%doc %{mandir}/man1/*
%doc %{mandir}/man5/*
%{prefix}/bin/*
%{prefix}/sbin/*
%if %{with_dir_check_cap_chown}
%attr(-,root,root) %caps(cap_chown=p) %{_bindir}/dir_check
%endif
%changelog
*Wed Jul 18 2018 Holger Kiehl <[email protected]>
- Add systemd support.
*Mon Feb 07 2011 Holger Kiehl <[email protected]>
- Handle case when users write some data to stdout or stderr.
*Wed Nov 05 2008 Holger Kiehl <[email protected]>
- Let autotools handle doc and man directories.
*Wed Aug 08 2007 Holger Kiehl <[email protected]>
- Added AFD Monitor boot scripts.
*Thu Nov 16 2006 Holger Kiehl <[email protected]>
- Don't rely on the lock file in /var/lock/subsys, do a real check if AFD is up.
- Added support for AFD HA users.
*Tue Apr 11 2006 Holger Kiehl <[email protected]>
- When updating, stop AFD before new binaries are installed.
*Thu Sep 8 2005 Holger Kiehl <[email protected]>
- When installing use use strip by default.
*Thu Jul 21 2005 Holger Kiehl <[email protected]>
- Do not overwrite @SYSCONFIGDIR@/afd.
*Sun Jun 26 2005 Holger Kiehl <[email protected]>
- Include etc directory
- Setup init/rc script.
*Sat Jun 25 2005 Holger Kiehl <[email protected]>
- Check for user and group.
- Include doc directory.
*Wed Jun 22 2005 Holger Kiehl <[email protected]>
- Adapt to build from make.
*Mon May 17 2004 Holger Kiehl <[email protected]>
- Adapt for version 1.3.x.
*Sat Dec 14 2002 Holger Kiehl <[email protected]>
- AFD requires openmotif.
*Sat Mar 2 2002 Holger Kiehl <[email protected]>
- Use build root so the build version is not installed on the build system.
*Sun Feb 10 2002 Holger Kiehl <[email protected]>
- Default install in /opt
*Fri Feb 1 2002 Doug Henry <[email protected]>
- Initial release