Run updatedb from via systemd timer instead of cron
This commit is contained in:
parent
b535ab95f0
commit
6795a4954c
@ -1,5 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
nodevs=$(< /proc/filesystems awk '$1 == "nodev" && $2 != "rootfs" && $2 != "zfs" { print $2 }')
|
nodevs=$(< /proc/filesystems awk '$1 == "nodev" && $2 != "rootfs" && $2 != "zfs" { print $2 }')
|
||||||
renice +19 -p $$ >/dev/null 2>&1
|
|
||||||
ionice -c2 -n7 -p $$ >/dev/null 2>&1
|
|
||||||
/usr/bin/updatedb -f "$nodevs"
|
/usr/bin/updatedb -f "$nodevs"
|
14
mlocate-updatedb.service
Normal file
14
mlocate-updatedb.service
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Update a database for mlocate
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/libexec/mlocate-run-updatedb
|
||||||
|
Nice=19
|
||||||
|
IOSchedulingClass=2
|
||||||
|
IOSchedulingPriority=7
|
||||||
|
|
||||||
|
PrivateTmp=true
|
||||||
|
PrivateDevices=true
|
||||||
|
PrivateNetwork=true
|
||||||
|
ProtectSystem=true
|
10
mlocate-updatedb.timer
Normal file
10
mlocate-updatedb.timer
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Updates mlocate database every day
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=daily
|
||||||
|
AccuracySec=24h
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
30
mlocate.spec
30
mlocate.spec
@ -3,16 +3,18 @@
|
|||||||
Summary: An utility for finding files by name
|
Summary: An utility for finding files by name
|
||||||
Name: mlocate
|
Name: mlocate
|
||||||
Version: 0.26
|
Version: 0.26
|
||||||
Release: 10%{?dist}
|
Release: 11%{?dist}
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
URL: https://fedorahosted.org/mlocate/
|
URL: https://fedorahosted.org/mlocate/
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
Source0: https://fedorahosted.org/releases/m/l/mlocate/mlocate-%{version}.tar.xz
|
Source0: https://fedorahosted.org/releases/m/l/mlocate/mlocate-%{version}.tar.xz
|
||||||
Source1: updatedb.conf
|
Source1: updatedb.conf
|
||||||
Source2: mlocate.cron
|
Source2: mlocate-run-updatedb
|
||||||
Requires: crontabs
|
Source3: mlocate-updatedb.service
|
||||||
|
Source4: mlocate-updatedb.timer
|
||||||
Requires(pre): shadow-utils
|
Requires(pre): shadow-utils
|
||||||
Requires(post): grep, sed
|
Requires(post): grep, sed
|
||||||
|
BuildRequires: systemd
|
||||||
Provides: bundled(gnulib)
|
Provides: bundled(gnulib)
|
||||||
Obsoletes: slocate <= 2.7-30
|
Obsoletes: slocate <= 2.7-30
|
||||||
|
|
||||||
@ -36,7 +38,10 @@ make install DESTDIR=$RPM_BUILD_ROOT INSTALL='install -p' groupname=slocate
|
|||||||
|
|
||||||
mkdir -p $RPM_BUILD_ROOT{%{_sysconfdir},/etc/cron.daily}
|
mkdir -p $RPM_BUILD_ROOT{%{_sysconfdir},/etc/cron.daily}
|
||||||
install -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/updatedb.conf
|
install -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/updatedb.conf
|
||||||
install -p -m 750 %{SOURCE2} $RPM_BUILD_ROOT/etc/cron.daily/mlocate
|
install -D -p -m 750 %{SOURCE2} $RPM_BUILD_ROOT%{_libexecdir}/mlocate-run-updatedb
|
||||||
|
install -D -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_unitdir}/mlocate-updatedb.service
|
||||||
|
install -D -p -m 644 %{SOURCE4} $RPM_BUILD_ROOT%{_unitdir}/mlocate-updatedb.timer
|
||||||
|
|
||||||
# %%ghost semantics is so stupid
|
# %%ghost semantics is so stupid
|
||||||
touch $RPM_BUILD_ROOT%{_localstatedir}/lib/mlocate/mlocate.db
|
touch $RPM_BUILD_ROOT%{_localstatedir}/lib/mlocate/mlocate.db
|
||||||
|
|
||||||
@ -50,18 +55,33 @@ exit 0
|
|||||||
if /bin/grep -q '^[^#]*DAILY_UPDATE' %{_sysconfdir}/updatedb.conf; then
|
if /bin/grep -q '^[^#]*DAILY_UPDATE' %{_sysconfdir}/updatedb.conf; then
|
||||||
/bin/sed -i.rpmsave -e '/DAILY_UPDATE/s/^/#/' %{_sysconfdir}/updatedb.conf
|
/bin/sed -i.rpmsave -e '/DAILY_UPDATE/s/^/#/' %{_sysconfdir}/updatedb.conf
|
||||||
fi
|
fi
|
||||||
|
%systemd_post mlocate-updatedb.timer
|
||||||
|
|
||||||
|
%preun
|
||||||
|
%systemd_preun mlocate-updatedb.timer
|
||||||
|
|
||||||
|
%postun
|
||||||
|
%systemd_postun_with_restart mlocate-updatedb.timer
|
||||||
|
|
||||||
|
%triggerin -- %{name} < 0.26-11
|
||||||
|
/usr/bin/systemctl start mlocate-updatedb.timer
|
||||||
|
|
||||||
%files -f mlocate.lang
|
%files -f mlocate.lang
|
||||||
%doc AUTHORS COPYING NEWS README
|
%doc AUTHORS COPYING NEWS README
|
||||||
%attr(0700,-,-) %config(noreplace) /etc/cron.daily/mlocate
|
|
||||||
%config(noreplace) %{_sysconfdir}/updatedb.conf
|
%config(noreplace) %{_sysconfdir}/updatedb.conf
|
||||||
%attr(2711,root,slocate) %{_bindir}/locate
|
%attr(2711,root,slocate) %{_bindir}/locate
|
||||||
|
%{_unitdir}/mlocate-updatedb.service
|
||||||
|
%{_unitdir}/mlocate-updatedb.timer
|
||||||
|
%{_libexecdir}/mlocate-run-updatedb
|
||||||
%{_bindir}/updatedb
|
%{_bindir}/updatedb
|
||||||
%{_mandir}/man*/*
|
%{_mandir}/man*/*
|
||||||
%dir %attr(0750,root,slocate) %{_localstatedir}/lib/mlocate
|
%dir %attr(0750,root,slocate) %{_localstatedir}/lib/mlocate
|
||||||
%ghost %attr(0640,root,slocate) %{_localstatedir}/lib/mlocate/mlocate.db
|
%ghost %attr(0640,root,slocate) %{_localstatedir}/lib/mlocate/mlocate.db
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jun 9 2015 Michal Sekletar <msekleta@redhat.com> - 0.26-11
|
||||||
|
- migrate from cron job to systemd timer
|
||||||
|
|
||||||
* Tue May 26 2015 Michal Sekletar <msekleta@redhat.com> - 0.26-10
|
* Tue May 26 2015 Michal Sekletar <msekleta@redhat.com> - 0.26-10
|
||||||
- prune path /var/lib/ceph (#1223582)
|
- prune path /var/lib/ceph (#1223582)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user