-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcronie.spec
165 lines (140 loc) · 4.87 KB
/
cronie.spec
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
%bcond_without pam
%bcond_without inotify
Summary: Cron daemon for executing programs at set times
Name: cronie
Version: 1.7.2
Release: 1
License: MIT and BSD
Group: System/Servers
URL: https://fedorahosted.org/cronie
Source0: https://github.com/cronie-crond/cronie/releases/download/cronie-%{version}/cronie-%{version}.tar.gz
Source1: anacron-timestamp
Source2: crond.pam
BuildRequires: systemd-rpm-macros
%if %{with pam}
Requires: pam
BuildRequires: pam-devel
%endif
Requires(post): coreutils
Requires(post): sed
Suggests: anacron
Provides: cron-daemon
Provides: vixie-cron = 4:4.4
Obsoletes: vixie-cron <= 4:4.3
%{?systemd_ordering}
%description
Cronie contains the standard UNIX daemon crond that runs specified programs at
scheduled times and related tools. It is a fork of the original vixie-cron and
has security and configuration enhancements like the ability to use pam and
SELinux.
%package anacron
Summary: Utility for running regular jobs
Group: System/Servers
Requires: crontabs
Requires: %{name} = %{EVRD}
# for touch
Requires(post): coreutils
Provides: anacron = 2.4
Obsoletes: anacron < 2.4
%description anacron
Anacron becames part of cronie. Anacron is used only for running regular jobs.
The default settings execute regular jobs by anacron, however this could be
overloaded in settings.
%prep
%autosetup -p1
# Make sure anacron is started after regular cron jobs, otherwise anacron might
# run first, and after that regular cron runs the same jobs again
sed -i -e "s/^START_HOURS_RANGE.*$/START_HOURS_RANGE=6-22/" \
-e "s/nice run-parts/nice -n 19 run-parts/" \
contrib/anacrontab
%build
%serverbuild
%configure \
--with-editor=/bin/vi \
--enable-anacron \
--enable-pie \
--enable-relro \
%if %{with pam}
--with-pam \
%endif
--without-audit \
%if %{with inotify}
--with-inotify
%endif
%make_build
%install
%make_install
install -d -m 700 %{buildroot}/var/spool/cron
install -d -m 755 %{buildroot}%{_sysconfdir}/cron.d
# https://bugzilla.mandriva.com/show_bug.cgi?id=19645 and
# https://bugzilla.mandriva.com/show_bug.cgi?id=28278
touch %{buildroot}%{_sysconfdir}/cron.deny
install -d %{buildroot}%{_sysconfdir}/sysconfig
install -m0644 crond.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/crond
install -m 644 contrib/anacrontab %{buildroot}%{_sysconfdir}/anacrontab
mkdir -pm 755 %{buildroot}%{_sysconfdir}/cron.hourly
install -c -m755 contrib/0anacron %{buildroot}%{_sysconfdir}/cron.hourly/0anacron
install -m644 %{SOURCE2} %{buildroot}%{_sysconfdir}/pam.d/crond
# Install cron job which will update anacron's daily, weekly, monthly timestamps
# when these jobs are run by regular cron, in order to prevent duplicate execution
for i in daily weekly monthly
do
mkdir -p %{buildroot}/etc/cron.${i}
sed -e "s/XXXX/${i}/" %{SOURCE1} > %{buildroot}/etc/cron.${i}/0anacron-timestamp
done
# create empty %ghost files
mkdir -p %{buildroot}/var/spool/anacron
touch %{buildroot}/var/spool/anacron/cron.daily
touch %{buildroot}/var/spool/anacron/cron.weekly
touch %{buildroot}/var/spool/anacron/cron.monthly
%if ! %{with pam}
rm -f %{buildroot}%{_sysconfdir}/pam.d/crond
%endif
# install systemd initscript
mkdir -p %{buildroot}%{_unitdir}
install -m 644 contrib/cronie.systemd %{buildroot}%{_unitdir}/crond.service
%post
%systemd_post crond.service
%post anacron
[ -e /var/spool/anacron/cron.daily ] || touch /var/spool/anacron/cron.daily
[ -e /var/spool/anacron/cron.weekly ] || touch /var/spool/anacron/cron.weekly
[ -e /var/spool/anacron/cron.monthly ] || touch /var/spool/anacron/cron.monthly
%preun
# run before a package is removed
%systemd_preun crond.service
%postun
# run after a package is removed
%systemd_postun_with_restart crond.service
%triggerin -- pam, glibc
/bin/systemctl try-restart crond.service >/dev/null 2>&1 || :
%files
%doc AUTHORS COPYING INSTALL README ChangeLog
%attr(755,root,root) %{_sbindir}/crond
%attr(6755,root,root) %{_bindir}/crontab
%attr(6755,root,root) %{_bindir}/cronnext
%{_mandir}/man8/crond.*
%{_mandir}/man8/cron.*
%{_mandir}/man5/crontab.*
%{_mandir}/man1/crontab.*
%{_mandir}/man1/cronnext.*
%dir /var/spool/cron
%dir %{_sysconfdir}/cron.d
%if %{with pam}
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/pam.d/crond
%endif
%config(noreplace) %{_sysconfdir}/sysconfig/crond
%config(noreplace) %{_sysconfdir}/cron.deny
%attr(0644,root,root) %{_unitdir}/crond.service
%files anacron
%{_sbindir}/anacron
%config(noreplace) %{_sysconfdir}/anacrontab
%attr(0755,root,root) %{_sysconfdir}/cron.daily/0anacron-timestamp
%attr(0755,root,root) %{_sysconfdir}/cron.weekly/0anacron-timestamp
%attr(0755,root,root) %{_sysconfdir}/cron.monthly/0anacron-timestamp
%attr(0755,root,root) %{_sysconfdir}/cron.hourly/0anacron
%dir /var/spool/anacron
%ghost %verify(not md5 size mtime) /var/spool/anacron/cron.daily
%ghost %verify(not md5 size mtime) /var/spool/anacron/cron.weekly
%ghost %verify(not md5 size mtime) /var/spool/anacron/cron.monthly
%{_mandir}/man5/anacrontab.*
%{_mandir}/man8/anacron.*