Browse code

Add run-parts to cronie parckage.(bug 1628836)

Change-Id: I1048660c8bb770bebb2ed6cab4eb271f7b76564f
Reviewed-on: http://photon-jenkins.eng.vmware.com/661
Tested-by: jenkins-photon <wangnan2015@hotmail.com>
Reviewed-by: Sharath George

xiaolin-vmware authored on 2016/03/26 06:36:50
Showing 2 changed files
... ...
@@ -1,11 +1,12 @@
1 1
 Summary:	Cron Daemon
2 2
 Name:		cronie
3 3
 Version:	1.5.0
4
-Release:	6%{?dist}
4
+Release:	7%{?dist}
5 5
 License:	GPLv2+ and MIT and BSD and ISC
6 6
 URL:		https://fedorahosted.org/cronie
7 7
 Source0:	https://fedorahosted.org/releases/c/r/cronie/%{name}-%{version}.tar.gz
8 8
 %define sha1 cronie=bbf154a6db7c9802664d1f0397b5e7ae9a9618e4
9
+Source1: run-parts.sh
9 10
 Group:		System Environment/Base
10 11
 Vendor:		VMware, Inc.
11 12
 Distribution:	Photon
... ...
@@ -22,6 +23,7 @@ has security and configuration enhancements like the ability to use pam and
22 22
 SELinux.
23 23
 %prep
24 24
 %setup -q
25
+sed -i "s/\/usr\/sbin\/anacron -s/\/usr\/sbin\/anacron -s -S \/var\/spool\/anacron/" contrib/0anacron
25 26
 %build
26 27
 autoreconf
27 28
 ./configure \
... ...
@@ -58,6 +60,7 @@ touch %{buildroot}/var/spool/anacron/cron.monthly
58 58
 install -vdm755 %{buildroot}/%{_sysconfdir}/pam.d
59 59
 install -vd %{buildroot}%{_libdir}/systemd/system/
60 60
 install -m 644 contrib/cronie.systemd %{buildroot}%{_libdir}/systemd/system/crond.service
61
+install -c -m755  %{SOURCE1} %{buildroot}/%{_bindir}/run-parts
61 62
 
62 63
 ln -sfv ./crond.service %{buildroot}/usr/lib/systemd/system/cron.service
63 64
 %check
... ...
@@ -97,6 +100,8 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
97 97
 /var/spool/anacron/cron.monthly
98 98
 /var/spool/anacron/cron.weekly
99 99
 %changelog
100
+*   	Thu Mar 24 2016 Xiaolin Li <xiaolinl@vmware.com>  1.5.0-7
101
+-   	Add run-parts command.
100 102
 *   	Fri Mar 04 2016 Anish Swaminathan <anishs@vmware.com>  1.5.0-6
101 103
 -   	Add folders to sysconfdir.
102 104
 *   	Mon Feb 08 2016 Anish Swaminathan <anishs@vmware.com>  1.5.0-5
103 105
new file mode 100644
... ...
@@ -0,0 +1,48 @@
0
+#!/bin/bash
1
+# run-parts - concept taken from Debian
2
+set +e
3
+
4
+if [ $# -lt 1 ]; then
5
+	echo "Usage : run-parts <dir>" 
6
+	exit 1
7
+fi
8
+
9
+if [ ! -d $1 ]; then
10
+	echo "$1 is not a directory"
11
+	exit 1
12
+fi
13
+
14
+# ignore *~ and *, scripts
15
+for i in $(LC_ALL=C; echo $1/*[^~,]); do
16
+	# skip directory
17
+	[ -d $i ] && continue
18
+	#Don't run *.{rpmsave, rpmorig,rpmnew,swp,cfsaved} scripts
19
+	[ "${i%.rpmsave}" = "${i}" ] || continue
20
+	[ "${i%.rpmorig}" = "${i}" ] || continue
21
+	[ "${i%.rpmnew}" = "${i}" ] || continue
22
+	[ "${i%.swp}" = "${i}" ] || continue
23
+	[ "${i%.cfsaved}" = "${i}" ] || continue
24
+	[ "${i%,v}" = "${i}" ] || continue
25
+
26
+	# jobs.deny and jobs.allow
27
+	if [ -r $1/jobs.deny ]; then
28
+		grep -q "^$(basename $i)$" $1/jobs.deny && continue
29
+	fi
30
+	if [ -r S1/jobs.allow ]; then
31
+		grep -q "^$(basename $i)$" $1/job.allow || continue
32
+	fi
33
+
34
+	if [ -x $i ]; then
35
+		if [ -r $1/whitelist ]; then
36
+			grep -q "^$(basename $i)$" $1/whitelist && continue
37
+		fi
38
+		logger -p cron.notice -t "run-parts[$$]" "($1) starting $(basename $i)"
39
+		echo "${i}:"
40
+		echo 
41
+		$i 2>&1 
42
+		logger -i -p cron.notice -t "run-parts[$$]" "($1) finished $(basename $i)"
43
+	fi
44
+done
45
+
46
+exit 0
47
+