diff options
author | Ciaran McCreesh <ciaranm@gentoo.org> | 2005-03-04 23:24:54 +0000 |
---|---|---|
committer | Ciaran McCreesh <ciaranm@gentoo.org> | 2005-03-04 23:24:54 +0000 |
commit | 94ce95e761a09229b641094b22a5ee51b44cec21 (patch) | |
tree | e69d2e08322c01a6c5ddfcf48f7382159c3532b0 /sys-process/cronbase | |
parent | Adding keyword ~alpha for testing. (diff) | |
download | historical-94ce95e761a09229b641094b22a5ee51b44cec21.tar.gz historical-94ce95e761a09229b641094b22a5ee51b44cec21.tar.bz2 historical-94ce95e761a09229b641094b22a5ee51b44cec21.zip |
Move sys-apps/cronbase -> sys-process/cronbase
Package-Manager: portage-2.0.51.19
Diffstat (limited to 'sys-process/cronbase')
-rw-r--r-- | sys-process/cronbase/ChangeLog | 116 | ||||
-rw-r--r-- | sys-process/cronbase/Manifest | 22 | ||||
-rw-r--r-- | sys-process/cronbase/cronbase-0.2.1-r3.ebuild | 28 | ||||
-rw-r--r-- | sys-process/cronbase/cronbase-0.3.1.ebuild | 27 | ||||
-rw-r--r-- | sys-process/cronbase/cronbase-0.3.ebuild | 28 | ||||
-rw-r--r-- | sys-process/cronbase/files/README | 119 | ||||
-rw-r--r-- | sys-process/cronbase/files/digest-cronbase-0.2.1-r3 | 0 | ||||
-rw-r--r-- | sys-process/cronbase/files/digest-cronbase-0.3 | 0 | ||||
-rw-r--r-- | sys-process/cronbase/files/digest-cronbase-0.3.1 | 0 | ||||
-rwxr-xr-x | sys-process/cronbase/files/run-crons-0.2.1 | 83 | ||||
-rwxr-xr-x | sys-process/cronbase/files/run-crons-0.3 | 96 | ||||
-rwxr-xr-x | sys-process/cronbase/files/run-crons-0.3.1 | 103 | ||||
-rw-r--r-- | sys-process/cronbase/metadata.xml | 5 |
13 files changed, 627 insertions, 0 deletions
diff --git a/sys-process/cronbase/ChangeLog b/sys-process/cronbase/ChangeLog new file mode 100644 index 000000000000..348d97be0c60 --- /dev/null +++ b/sys-process/cronbase/ChangeLog @@ -0,0 +1,116 @@ +# ChangeLog for sys-process/cronbase +# Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2 +# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/ChangeLog,v 1.1 2005/03/04 23:24:54 ciaranm Exp $ + +*cronbase-0.2.1-r3 (04 Mar 2005) + + 04 Mar 2005; Ciaran McCreesh <ciaranm@gentoo.org> +metadata.xml, + +files/README, +files/run-crons-0.2.1, +files/run-crons-0.3, + +files/run-crons-0.3.1, +cronbase-0.2.1-r3.ebuild, +cronbase-0.3.1.ebuild, + +cronbase-0.3.ebuild: + Move sys-apps/cronbase -> sys-process/cronbase + + 08 Oct 2004; Aaron Walker <ka0ttic@gentoo.org> metadata.xml: + Updated metadata to reflect new cron herd. + + 18 Aug 2004; Aron Griffis <agriffis@gentoo.org> cronbase-0.3.1.ebuild: + stable everywhere + + 26 Jul 2004; Aron Griffis <agriffis@gentoo.org> files/run-crons-0.3.1: + Polish that locking 'til it gleams + +*cronbase-0.3.1 (25 Jul 2004) + + 25 Jul 2004; Aron Griffis <agriffis@gentoo.org> +files/run-crons-0.3.1, + +cronbase-0.3.1.ebuild: + Polish up locking code, thanks to Nahor for diagnosing the problems #58137 + + 29 Jun 2004; Aron Griffis <agriffis@gentoo.org> cronbase-0.3.ebuild: + stable everywhere + + 25 May 2004; Aron Griffis <agriffis@gentoo.org> files/run-crons-0.3: + Fix bash typo in run-crons-0.3 + +*cronbase-0.3 (24 May 2004) + + 24 May 2004; Aron Griffis <agriffis@gentoo.org> -files/run-crons, + -cronbase-0.2.1-r2.ebuild, cronbase-0.2.1-r3.ebuild, +cronbase-0.3.ebuild: + Fix bug 45155 (run-crons and /var/spool/cron/lastrun/lock problems) by + re-writing the locking code to be non-racy + + 08 Apr 2004; Joshua Kinard <kumba@gentoo.org> cronbase-0.2.1-r2.ebuild, + cronbase-0.2.1-r3.ebuild: + Marked stable on mips. + + 08 Apr 2004; Luca Barbato <lu_zero@gentoo.org> : + Marked ppc + + 07 Apr 2004; <kloeri@gentoo.org> cronbase-0.2.1-r3.ebuild: + Stable on Alpha. + + 29 Mar 2004; Jon Portnoy <avenj@gentoo.org> cronbase-0.2.1-r3.ebuild : + Stable on AMD64 + + 29 Mar 2004; Gustavo Zacarias <gustavoz@gentoo.org> + cronbase-0.2.1-r3.ebuild: + stable on sparc + + 26 Mar 2004; Seemant Kulleen <seemant@gentoo.org> cronbase-0.2.1-r3.ebuild: + move to stable x86 + + 26 Dec 2003; Guy Martin <gmsoft@gentoo.org> cronbase-0.2.1-r3.ebuild: + Marked stable on hppa. + +*cronbase-0.2.1-r3 (19 Nov 2003) + + 19 Nov 2003; Preston A. Elder <prez@gentoo.org> run-crons : + Added code to ensure only one run-crons instance runs at once. + +*cronbase-0.2.1-r2 (31 Jan 2003) + + 17 Sep 2003; Jon Portnoy <avenj@gentoo.org> cronbase-0.2.1-r2.ebuild : + ia64 keywords. + + 20 Feb 2003; Zach Welch <zwelch@gentoo.org> cronbase-0.2.1-r2.ebuild : + Added arm to keywords. + + 07 Feb 2003; Guy Martin <gmsoft@gentoo.org> cronbase-0.2.1-r2.ebuild : + Added hppa to keywords. + + 31 Jan 2003; Preston A. Elder <prez@gentoo.org> run-crons : + Chaged month delay from 30 to 31 days, as per Bug #14862 + +*cronbase-0.2.1-r1 (13 Nov 2002) + + 22 Jan 2003; Mike Frysinger <vapier@gentoo.org> : + Removed duplicate keepdir func definition + + 19 Jan 2003; Jan Seidel <tuxus@gentoo.org> : + Added mips to keywords + + 06 Dec 2002; Rodney Rees <manson@gentoo.org> : changed sparc ~sparc keywords + + 13 Nov 2002; Donny Davies <woodchip@gentoo.org> run-crons : Fix #10409. + +*cronbase-0.2.1 (27 Jun 2002) + + 22 Jan 2003; Mike Frysinger <vapier@gentoo.org> : + Removed duplicate keepdir func definition + + 14 Jul 2002; phoen][x <phoenix@gentoo.org> cronbase-0.2.1.ebuild : + Added KEYWORDS, SLOT. + + 26 Jun 2002; Thilo Bangert <bangert@gentoo.org> files/run-crons : + rethought rewrite and fixed a race. thanks go to jnelseon and george. + +*cronbase-0.2 (24 Jun 2002) + + 23 Jun 2002; Thilo Bangert <bangert@gentoo.org> files/run-crons : + minor fixors/cleanups - suggested by jon nelson + + 20 Apr 2002; Thilo Bangert <bangert@gentoo.org> files/run-crons : + moved lastrun to /var/spool/cron/lastrun + +*cronbase-0.01 (19 Apr 2002) + + 19 Apr 2002; Thilo Bangert <bangert@gentoo.org> ChangeLog : initial release. diff --git a/sys-process/cronbase/Manifest b/sys-process/cronbase/Manifest new file mode 100644 index 000000000000..10b8c39bfa0d --- /dev/null +++ b/sys-process/cronbase/Manifest @@ -0,0 +1,22 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +MD5 6eaaa244afa1aa0b96112382e643d6f6 cronbase-0.3.ebuild 795 +MD5 a8e24ef3f11a86a855b10ff1d0bb6f84 ChangeLog 3909 +MD5 7fac489e4fdfb2d9c7628aac43b5a690 cronbase-0.3.1.ebuild 799 +MD5 cb008353dea555fdac9dde6d43a47dbe cronbase-0.2.1-r3.ebuild 800 +MD5 9c8fdf815ce980c230d763b496d4d088 metadata.xml 158 +MD5 b24a8cee126be26a019b3e31b072f226 files/run-crons-0.3 2641 +MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-cronbase-0.3.1 0 +MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-cronbase-0.3 0 +MD5 e97f3765fe2a786526128816cd5d5d11 files/run-crons-0.3.1 2802 +MD5 790f5f4a29421ae2ca3bd4a6d150bb71 files/README 2861 +MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-cronbase-0.2.1-r3 0 +MD5 8a5efc0f1ab99d6942692ea684cd72c5 files/run-crons-0.2.1 1962 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (GNU/Linux) + +iD8DBQFCKO40LLFUmVNQ7rkRAnIuAKCMmdgGWVMARFJJbFiwqGPJ8y29+ACfQ9Ve +GK6mYFohhblE59WTUQUgX88= +=u0uI +-----END PGP SIGNATURE----- diff --git a/sys-process/cronbase/cronbase-0.2.1-r3.ebuild b/sys-process/cronbase/cronbase-0.2.1-r3.ebuild new file mode 100644 index 000000000000..3f82298b896c --- /dev/null +++ b/sys-process/cronbase/cronbase-0.2.1-r3.ebuild @@ -0,0 +1,28 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/cronbase-0.2.1-r3.ebuild,v 1.1 2005/03/04 23:24:54 ciaranm Exp $ + +IUSE="" + +DESCRIPTION="base for all cron ebuilds" +HOMEPAGE="http://www.gentoo.org/" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="x86 ppc ppc64 sparc mips alpha arm hppa amd64 ia64 s390" + +src_install() { + exeinto /usr/sbin + newexe ${FILESDIR}/run-crons-${PV} run-crons || die + + diropts -m0750; keepdir /etc/cron.hourly + diropts -m0750; keepdir /etc/cron.daily + diropts -m0750; keepdir /etc/cron.weekly + diropts -m0750; keepdir /etc/cron.monthly + + diropts -m0750 -o root -g cron; keepdir /var/spool/cron + + diropts -m0750; keepdir /var/spool/cron/lastrun + + dodoc ${FILESDIR}/README +} diff --git a/sys-process/cronbase/cronbase-0.3.1.ebuild b/sys-process/cronbase/cronbase-0.3.1.ebuild new file mode 100644 index 000000000000..3382ba13ad61 --- /dev/null +++ b/sys-process/cronbase/cronbase-0.3.1.ebuild @@ -0,0 +1,27 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/cronbase-0.3.1.ebuild,v 1.1 2005/03/04 23:24:54 ciaranm Exp $ + +DESCRIPTION="base for all cron ebuilds" +HOMEPAGE="http://www.gentoo.org/" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="alpha amd64 arm hppa ia64 mips ppc ppc64 s390 sh sparc x86" +IUSE="" + +src_install() { + exeinto /usr/sbin + newexe ${FILESDIR}/run-crons-${PV} run-crons || die + + diropts -m0750; keepdir /etc/cron.hourly + diropts -m0750; keepdir /etc/cron.daily + diropts -m0750; keepdir /etc/cron.weekly + diropts -m0750; keepdir /etc/cron.monthly + + diropts -m0750 -o root -g cron; keepdir /var/spool/cron + + diropts -m0750; keepdir /var/spool/cron/lastrun + + dodoc ${FILESDIR}/README +} diff --git a/sys-process/cronbase/cronbase-0.3.ebuild b/sys-process/cronbase/cronbase-0.3.ebuild new file mode 100644 index 000000000000..645489bac78c --- /dev/null +++ b/sys-process/cronbase/cronbase-0.3.ebuild @@ -0,0 +1,28 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/cronbase-0.3.ebuild,v 1.1 2005/03/04 23:24:54 ciaranm Exp $ + +IUSE="" + +DESCRIPTION="base for all cron ebuilds" +HOMEPAGE="http://www.gentoo.org/" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="x86 ppc ppc64 sparc mips alpha arm hppa amd64 ia64 s390" + +src_install() { + exeinto /usr/sbin + newexe ${FILESDIR}/run-crons-${PV} run-crons || die + + diropts -m0750; keepdir /etc/cron.hourly + diropts -m0750; keepdir /etc/cron.daily + diropts -m0750; keepdir /etc/cron.weekly + diropts -m0750; keepdir /etc/cron.monthly + + diropts -m0750 -o root -g cron; keepdir /var/spool/cron + + diropts -m0750; keepdir /var/spool/cron/lastrun + + dodoc ${FILESDIR}/README +} diff --git a/sys-process/cronbase/files/README b/sys-process/cronbase/files/README new file mode 100644 index 000000000000..42baf7d8ab2f --- /dev/null +++ b/sys-process/cronbase/files/README @@ -0,0 +1,119 @@ + +$Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/files/README,v 1.1 2005/03/04 23:24:54 ciaranm Exp $ + +22 Apr 2oo2; Thilo Bangert <bangert@gentoo.org> + +initial release + + + +The Gentoo Linux Cron README +============================ + +Subject: New Cron Layout +Date: Mon, 22 Apr 2002 21:35:26 +0200 +From: Thilo Bangert <bangert@gentoo.org> +To: gentoo-dev@gentoo.org, gentoo-announce@gentoo.org, +gentoo-user@gentoo.org, gentoo-newbies@gentoo.org + + Hi, + +I have just unmasked + + sys-apps/cronbase-0.01 + sys-apps/dcron-2.7-r9 + sys-apps/fcron-2.0.0-r1 + sys-apps/vcron-3.0.1-r1 + +Users of + + sys-apps/dcron + sys-apps/fcron (or app-admin/fcron ) + sys-apps/vcron + +should read the following before updating to the new cron layout. + + +Features +-------- + +The new cron layout incorporates the following features: + + - to be able to use cron, a user must be part of the "cron" group. + + - cron spool files are located at /var/spool/cron/ for all cron's + + - all crons run /etc/cron.{hourly|daily|weekly|monthly} (fcron and + dcron users see notice below). + + - all crons PROVIDE=virtual/cron and future ebuilds will make use of + this. Ebuild developers are encourged to use it where applicable. + + - max one cron per system. + + - dcron is the Gentoo Linux "default" (ie. dcron gets installed if + something depends on virtual/cron and no cron has been installed + yet). + + +Upgrade instructions +-------------------- + +sys-apps/dcron: + + NOTE: fcron has been moved from the app-admin category to the + sys-apps category. + + to install the new dcron, do + # emerge --pretend sys-apps/dcron + # emerge sys-apps/dcron + + NOTE: to make use of /etc/cron.{hourly|daily|weekly|monthly} the root + crontab must include the contents of /etc/crontab. + + # crontab /etc/crontab + + !! This will REPLACE root's current crontab !! + + +sys-apps/fcron: + + to install the new fcron, do + # emerge --pretend sys-apps/fcron + # emerge sys-apps/fcron + + The default location for crontabs for fcron has been changed to + /var/spool/cron/fcrontabs. To make use of previous crontabs, copy + them to the new location. Make sure your new /etc/fcron/fcron.conf + reflects this. + + NOTE: to make use of /etc/cron.{hourly|daily|weekly|monthly} the root + crontab must include the contents of /etc/crontab. + + # crontab /etc/crontab + + !! This will REPLACE root's current crontab !! + + NEW: To be able to use cron as a user, the user must be part of the + "cron" group. + + +sys-apps/vcron: + + to install the new vcron, do + # emerge --pretend sys-apps/vcron + # emerge sys-apps/vcron + + NEW: To be able to use cron as a user, the user must be part of the + "cron" group. + + +Although the new layout has been tested, bugs may be present. +Please report them on http://bugs.gentoo.org and assign them +to bangert@gentoo.org. + +Thank you. + +regards +Thilo Bangert <bangert@gentoo.org> + diff --git a/sys-process/cronbase/files/digest-cronbase-0.2.1-r3 b/sys-process/cronbase/files/digest-cronbase-0.2.1-r3 new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/sys-process/cronbase/files/digest-cronbase-0.2.1-r3 diff --git a/sys-process/cronbase/files/digest-cronbase-0.3 b/sys-process/cronbase/files/digest-cronbase-0.3 new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/sys-process/cronbase/files/digest-cronbase-0.3 diff --git a/sys-process/cronbase/files/digest-cronbase-0.3.1 b/sys-process/cronbase/files/digest-cronbase-0.3.1 new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/sys-process/cronbase/files/digest-cronbase-0.3.1 diff --git a/sys-process/cronbase/files/run-crons-0.2.1 b/sys-process/cronbase/files/run-crons-0.2.1 new file mode 100755 index 000000000000..7f0ad86c7fc6 --- /dev/null +++ b/sys-process/cronbase/files/run-crons-0.2.1 @@ -0,0 +1,83 @@ +#!/bin/sh +# +# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/files/run-crons-0.2.1,v 1.1 2005/03/04 23:24:54 ciaranm Exp $ +# +# 23 Jun 2002; Jon Nelson <jnelson@gentoo.org> run-crons: +# +# fixed a race condition, where cron jobs and run-crons wanted to delete +# touch files +# +# 20 Apr 2002; Thilo Bangert <bangert@gentoo.org> run-crons: +# +# moved lastrun directory to /var/spool/cron/lastrun +# +# Author: Achim Gottinger <achim@gentoo.org> +# +# Mostly copied from SuSE +# +# this script looks into /etc/cron.[hourly|daily|weekly|monthly] +# for scripts to be executed. The info about last run is stored in +# /var/spool/cron/lastrun + +mkdir -p /var/spool/cron/lastrun + +# Make sure its not running multiple instances at once. +if test -f /var/spool/cron/lastrun/lock +then + cronpid=`cat /var/spool/cron/lastrun/lock` + if `kill -0 $cronpid >/dev/null 2>&1` + then + exit 0 + fi +fi + +echo "$$" >/var/spool/cron/lastrun/lock + +for BASE in hourly daily weekly monthly +do + CRONDIR=/etc/cron.${BASE} + + test -d $CRONDIR || continue + + if test -e /var/spool/cron/lastrun/cron.$BASE + then + case $BASE in + hourly) + #>= 1 hour, 5 min -=> +65 min + TIME="-cmin +65" ;; + daily) + #>= 1 day, 5 min -=> +1445 min + TIME="-cmin +1445" ;; + weekly) + #>= 1 week, 5 min -=> +10085 min + TIME="-cmin +10085" ;; + monthly) + #>= 31 days, 5 min -=> +44645 min + TIME="-cmin +44645" ;; + esac + find /var/spool/cron/lastrun -name cron.$BASE $TIME -exec rm {} \; + fi + + # if there is no touch file, make one then run the scripts + if test ! -f /var/spool/cron/lastrun/cron.$BASE + then + + touch /var/spool/cron/lastrun/cron.$BASE + + set +e + for SCRIPT in $CRONDIR/* + do + test -d $SCRIPT && continue + if test -x $SCRIPT ; then + $SCRIPT + fi + done + fi +done + +# Remove lock, we're done. +rm -f /var/spool/cron/lastrun/lock + +touch /var/spool/cron/lastrun +find /var/spool/cron/lastrun -newer /var/spool/cron/lastrun -exec /bin/rm -f {} \; + diff --git a/sys-process/cronbase/files/run-crons-0.3 b/sys-process/cronbase/files/run-crons-0.3 new file mode 100755 index 000000000000..3d1c46298b7a --- /dev/null +++ b/sys-process/cronbase/files/run-crons-0.3 @@ -0,0 +1,96 @@ +#!/bin/bash +# +# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/files/run-crons-0.3,v 1.1 2005/03/04 23:24:54 ciaranm Exp $ +# +# +# 06 May 2004; Aron Griffis <agriffis@gentoo.org> run-crons: +# Make the locking actually work. The old code was racy. +# Thanks to Mathias Gumz in bug 45155 for some cleanups. +# +# 23 Jun 2002; Jon Nelson <jnelson@gentoo.org> run-crons: +# fixed a race condition, where cron jobs and run-crons wanted to +# delete touch files +# +# 20 Apr 2002; Thilo Bangert <bangert@gentoo.org> run-crons: +# moved lastrun directory to /var/spool/cron/lastrun +# +# Author: Achim Gottinger <achim@gentoo.org> +# +# Mostly copied from SuSE +# +# this script looks into /etc/cron.[hourly|daily|weekly|monthly] +# for scripts to be executed. The info about last run is stored in +# /var/spool/cron/lastrun + +LOCKDIR=/var/spool/cron/lastrun +LOCKFILE=${LOCKDIR}/lock + +mkdir -p ${LOCKDIR} + +# Make sure we're not running multiple instances at once. +# Try twice to lock, otherwise give up. +for ((i = 0; i < 2; i = i + 1)); do + ln -sn $$ ${LOCKFILE} 2>/dev/null + if [[ $? != 0 ]]; then + # lock failed, check for a running process. + # handle both old- and new-style locking. + cronpid=$(readlink ${LOCKFILE} 2>/dev/null || + cat ${LOCKFILE} 2>/dev/null) + if [[ $? == 0 ]]; then + if kill -0 ${cronpid} 2>/dev/null; then + # whoa, another process is really running + exit 0 + else + rm -f ${LOCKFILE} + fi + fi + fi +done + +# Set a trap to remove the lockfile when we're finished +trap "rm -f ${LOCKFILE}" 0 1 2 3 15 + + +for BASE in hourly daily weekly monthly +do + CRONDIR=/etc/cron.${BASE} + + test -d $CRONDIR || continue + + if [ -e ${LOCKDIR}/cron.$BASE ] + then + case $BASE in + hourly) + #>= 1 hour, 5 min -=> +65 min + TIME="-cmin +65" ;; + daily) + #>= 1 day, 5 min -=> +1445 min + TIME="-cmin +1445" ;; + weekly) + #>= 1 week, 5 min -=> +10085 min + TIME="-cmin +10085" ;; + monthly) + #>= 31 days, 5 min -=> +44645 min + TIME="-cmin +44645" ;; + esac + find ${LOCKDIR} -name cron.$BASE $TIME -exec rm {} \; + fi + + # if there is no touch file, make one then run the scripts + if [ ! -e ${LOCKDIR}/cron.$BASE ] + then + touch ${LOCKDIR}/cron.$BASE + + set +e + for SCRIPT in $CRONDIR/* + do + if [[ -x $SCRIPT && ! -d $SCRIPT ]]; then + $SCRIPT + fi + done + fi +done + +# Clean out bogus cron.$BASE files with future times +touch ${LOCKDIR} +find ${LOCKDIR} -newer ${LOCKDIR} -exec /bin/rm -f {} \; diff --git a/sys-process/cronbase/files/run-crons-0.3.1 b/sys-process/cronbase/files/run-crons-0.3.1 new file mode 100755 index 000000000000..836e074900a3 --- /dev/null +++ b/sys-process/cronbase/files/run-crons-0.3.1 @@ -0,0 +1,103 @@ +#!/bin/bash +# +# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/files/run-crons-0.3.1,v 1.1 2005/03/04 23:24:54 ciaranm Exp $ +# +# +# 06 May 2004; Aron Griffis <agriffis@gentoo.org> run-crons: +# Make the locking actually work. The old code was racy. +# Thanks to Mathias Gumz in bug 45155 for some cleanups. +# +# 23 Jun 2002; Jon Nelson <jnelson@gentoo.org> run-crons: +# fixed a race condition, where cron jobs and run-crons wanted to +# delete touch files +# +# 20 Apr 2002; Thilo Bangert <bangert@gentoo.org> run-crons: +# moved lastrun directory to /var/spool/cron/lastrun +# +# Author: Achim Gottinger <achim@gentoo.org> +# +# Mostly copied from SuSE +# +# this script looks into /etc/cron.[hourly|daily|weekly|monthly] +# for scripts to be executed. The info about last run is stored in +# /var/spool/cron/lastrun + +LOCKDIR=/var/spool/cron/lastrun +LOCKFILE=${LOCKDIR}/lock + +mkdir -p ${LOCKDIR} + +# Make sure we're not running multiple instances at once. +# Try twice to lock, otherwise give up. +for ((i = 0; i < 2; i = i + 1)); do + ln -sn $$ ${LOCKFILE} 2>/dev/null && break + + # lock failed, check for a running process. + # handle both old- and new-style locking. + cronpid=$(readlink ${LOCKFILE} 2>/dev/null) || + cronpid=$(cat ${LOCKFILE} 2>/dev/null) || + continue # lockfile disappeared? try again + + # better than kill -0 because we can verify that it's really + # another run-crons process + if [[ $(</proc/${cronpid}/cmdline) == $(</proc/$$/cmdline) ]] 2>/dev/null; then + # whoa, another process is really running + exit 0 + else + rm -f ${LOCKFILE} + fi +done + +# Check to make sure locking was successful +if [[ ! -L ${LOCKFILE} ]]; then + echo "Can't create or read existing ${LOCKFILE}, giving up" + exit 1 +fi + +# Set a trap to remove the lockfile when we're finished +trap "rm -f ${LOCKFILE}" 0 1 2 3 15 + + +for BASE in hourly daily weekly monthly +do + CRONDIR=/etc/cron.${BASE} + + test -d $CRONDIR || continue + + if [ -e ${LOCKDIR}/cron.$BASE ] + then + case $BASE in + hourly) + #>= 1 hour, 5 min -=> +65 min + TIME="-cmin +65" ;; + daily) + #>= 1 day, 5 min -=> +1445 min + TIME="-cmin +1445" ;; + weekly) + #>= 1 week, 5 min -=> +10085 min + TIME="-cmin +10085" ;; + monthly) + #>= 31 days, 5 min -=> +44645 min + TIME="-cmin +44645" ;; + esac + find ${LOCKDIR} -name cron.$BASE $TIME -exec rm {} \; + fi + + # if there is no touch file, make one then run the scripts + if [ ! -e ${LOCKDIR}/cron.$BASE ] + then + touch ${LOCKDIR}/cron.$BASE + + set +e + for SCRIPT in $CRONDIR/* + do + if [[ -x $SCRIPT && ! -d $SCRIPT ]]; then + $SCRIPT + fi + done + fi +done + +# Clean out bogus cron.$BASE files with future times +touch ${LOCKDIR} +find ${LOCKDIR} -newer ${LOCKDIR} -exec /bin/rm -f {} \; diff --git a/sys-process/cronbase/metadata.xml b/sys-process/cronbase/metadata.xml new file mode 100644 index 000000000000..3f399e92bcff --- /dev/null +++ b/sys-process/cronbase/metadata.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <herd>cron</herd> +</pkgmetadata> |