diff options
author | Aron Griffis <agriffis@gentoo.org> | 2004-07-25 15:59:07 +0000 |
---|---|---|
committer | Aron Griffis <agriffis@gentoo.org> | 2004-07-25 15:59:07 +0000 |
commit | fc891bdf70391bc3f41518b63615ac2e358a1c60 (patch) | |
tree | 747656acf17541e0ab27520bc4223c5947c44e41 /sys-apps/cronbase | |
parent | Initial import of libsrs2. (diff) | |
download | historical-fc891bdf70391bc3f41518b63615ac2e358a1c60.tar.gz historical-fc891bdf70391bc3f41518b63615ac2e358a1c60.tar.bz2 historical-fc891bdf70391bc3f41518b63615ac2e358a1c60.zip |
Polish up locking code, thanks to Nahor for diagnosing the problems #58137
Diffstat (limited to 'sys-apps/cronbase')
-rw-r--r-- | sys-apps/cronbase/ChangeLog | 8 | ||||
-rw-r--r-- | sys-apps/cronbase/Manifest | 19 | ||||
-rw-r--r-- | sys-apps/cronbase/cronbase-0.3.1.ebuild | 28 | ||||
-rw-r--r-- | sys-apps/cronbase/files/digest-cronbase-0.3.1 | 0 | ||||
-rw-r--r-- | sys-apps/cronbase/files/run-crons-0.3.1 | 103 |
5 files changed, 144 insertions, 14 deletions
diff --git a/sys-apps/cronbase/ChangeLog b/sys-apps/cronbase/ChangeLog index d5f0d6f14dde..866974ac774a 100644 --- a/sys-apps/cronbase/ChangeLog +++ b/sys-apps/cronbase/ChangeLog @@ -1,6 +1,12 @@ # ChangeLog for sys-apps/cronbase # Copyright 2002-2004 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-apps/cronbase/ChangeLog,v 1.30 2004/06/30 03:36:37 agriffis Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-apps/cronbase/ChangeLog,v 1.31 2004/07/25 15:59:07 agriffis Exp $ + +*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 diff --git a/sys-apps/cronbase/Manifest b/sys-apps/cronbase/Manifest index 32f31a088a71..db71ef00c755 100644 --- a/sys-apps/cronbase/Manifest +++ b/sys-apps/cronbase/Manifest @@ -1,19 +1,12 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -MD5 fd745f7921a1dbe853f7971eb9326e9f ChangeLog 3067 +MD5 52e03e8cbe6db962563235cdda87413c cronbase-0.3.1.ebuild 806 MD5 e65d81e57db2b515afec8ba4d23a5e0c cronbase-0.3.ebuild 793 MD5 2140f653d8a39eaac8c70f4ac662ff68 cronbase-0.2.1-r3.ebuild 799 +MD5 441213e0b33672e93b00a9ed425ac211 ChangeLog 3276 MD5 9a09f8d531c582e78977dbfd96edc1f2 metadata.xml 164 +MD5 3535c6f09818ef0ae04aaf7ddf19f39e files/run-crons-0.3 2642 +MD5 e5e6072141927cbd370b6daa5d53fbb7 files/run-crons-0.2.1 1963 +MD5 d51db0f48f428cc0d443b30563f3a3c8 files/run-crons-0.3.1 2788 MD5 aec64f4f974f1916af15c1e7e3dbda2c files/README 2862 MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-cronbase-0.3 0 -MD5 e5e6072141927cbd370b6daa5d53fbb7 files/run-crons-0.2.1 1963 -MD5 3535c6f09818ef0ae04aaf7ddf19f39e files/run-crons-0.3 2642 MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-cronbase-0.2.1-r3 0 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.2.4 (GNU/Linux) - -iD8DBQFA+f8xmdTrptrqvGERAlRgAJ0SJOxPVO9VMk4Aj9bpSGBvIm0KzQCfQc3S -WvuGkEYQLKRzJQ9+eLRLoIU= -=vNXo ------END PGP SIGNATURE----- +MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-cronbase-0.3.1 0 diff --git a/sys-apps/cronbase/cronbase-0.3.1.ebuild b/sys-apps/cronbase/cronbase-0.3.1.ebuild new file mode 100644 index 000000000000..e8176229218d --- /dev/null +++ b/sys-apps/cronbase/cronbase-0.3.1.ebuild @@ -0,0 +1,28 @@ +# Copyright 1999-2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-apps/cronbase/cronbase-0.3.1.ebuild,v 1.1 2004/07/25 15:59:07 agriffis 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-apps/cronbase/files/digest-cronbase-0.3.1 b/sys-apps/cronbase/files/digest-cronbase-0.3.1 new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/sys-apps/cronbase/files/digest-cronbase-0.3.1 diff --git a/sys-apps/cronbase/files/run-crons-0.3.1 b/sys-apps/cronbase/files/run-crons-0.3.1 new file mode 100644 index 000000000000..077d37040c78 --- /dev/null +++ b/sys-apps/cronbase/files/run-crons-0.3.1 @@ -0,0 +1,103 @@ +#!/bin/bash +# +# $Header: /var/cvsroot/gentoo-x86/sys-apps/cronbase/files/run-crons-0.3.1,v 1.1 2004/07/25 15:59:07 agriffis 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 ls -l /proc/${cronpid}/fd 2>/dev/null | grep -q "${0##*/}"; 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 {} \; |