query power status directly from kernel

This commit is contained in:
Tomas Mraz 2016-08-23 15:33:09 +02:00
parent 63359d0bd6
commit a1d815b665
2 changed files with 28 additions and 1 deletions

21
cronie-1.5.1-power.patch Normal file
View File

@ -0,0 +1,21 @@
diff --git a/contrib/0anacron b/contrib/0anacron
index 7bcb684..72a613d 100644
--- a/contrib/0anacron
+++ b/contrib/0anacron
@@ -4,14 +4,11 @@ if test -r /var/spool/anacron/cron.daily; then
day=`cat /var/spool/anacron/cron.daily`
fi
if [ `date +%Y%m%d` = "$day" ]; then
- exit 0;
+ exit 0
fi
# Do not run jobs when on battery power
-if test -x /usr/bin/on_ac_power; then
- /usr/bin/on_ac_power >/dev/null 2>&1
- if test $? -eq 1; then
+if [ `cat /sys/class/power_supply/AC/online 2>/dev/null`x = 0x ]; then
exit 0
- fi
fi
/usr/sbin/anacron -s

View File

@ -6,12 +6,14 @@
Summary: Cron daemon for executing programs at set times Summary: Cron daemon for executing programs at set times
Name: cronie Name: cronie
Version: 1.5.1 Version: 1.5.1
Release: 1%{?dist} Release: 2%{?dist}
License: MIT and BSD and ISC and GPLv2+ License: MIT and BSD and ISC and GPLv2+
Group: System Environment/Base Group: System Environment/Base
URL: https://fedorahosted.org/cronie URL: https://fedorahosted.org/cronie
Source0: https://fedorahosted.org/releases/c/r/cronie/%{name}-%{version}.tar.gz Source0: https://fedorahosted.org/releases/c/r/cronie/%{name}-%{version}.tar.gz
Patch1: cronie-1.5.1-power.patch
Requires: dailyjobs Requires: dailyjobs
%if %{with selinux} %if %{with selinux}
@ -75,6 +77,7 @@ extra features.
%prep %prep
%setup -q %setup -q
%patch1 -p1 -b .power
%build %build
%configure \ %configure \
@ -201,6 +204,9 @@ exit 0
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cron.d/dailyjobs %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cron.d/dailyjobs
%changelog %changelog
* Tue Aug 23 2016 Tomáš Mráz <tmraz@redhat.com> - 1.5.1-2
- query power status directly from kernel
* Thu Jun 23 2016 Tomáš Mráz <tmraz@redhat.com> - 1.5.1-1 * Thu Jun 23 2016 Tomáš Mráz <tmraz@redhat.com> - 1.5.1-1
- new upstream release - new upstream release