summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThilo Bangert <bangert@gentoo.org>2009-04-14 06:13:36 +0000
committerThilo Bangert <bangert@gentoo.org>2009-04-14 06:13:36 +0000
commit4e00ea7551a37fe76b28c00c15b42d6e4c9b77c3 (patch)
treec394d8e98dab9f4c94a9b6071488ec4782671a47 /sys-process/cronbase
parentMarked ~hppa (bug #264108). (diff)
downloadgentoo-2-4e00ea7551a37fe76b28c00c15b42d6e4c9b77c3.tar.gz
gentoo-2-4e00ea7551a37fe76b28c00c15b42d6e4c9b77c3.tar.bz2
gentoo-2-4e00ea7551a37fe76b28c00c15b42d6e4c9b77c3.zip
ignore emacs backup files (bug #237200) - include logging patch (bug #140869)
(Portage version: 2.1.6.7/cvs/Linux i686)
Diffstat (limited to 'sys-process/cronbase')
-rw-r--r--sys-process/cronbase/ChangeLog11
-rw-r--r--sys-process/cronbase/cronbase-0.3.3.ebuild45
-rwxr-xr-xsys-process/cronbase/files/run-crons-0.3.3110
3 files changed, 164 insertions, 2 deletions
diff --git a/sys-process/cronbase/ChangeLog b/sys-process/cronbase/ChangeLog
index 23321720ae69..0dd4e56c4570 100644
--- a/sys-process/cronbase/ChangeLog
+++ b/sys-process/cronbase/ChangeLog
@@ -1,6 +1,13 @@
# ChangeLog for sys-process/cronbase
-# Copyright 2002-2008 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/ChangeLog,v 1.30 2008/10/12 07:28:59 bangert Exp $
+# Copyright 2002-2009 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/ChangeLog,v 1.31 2009/04/14 06:13:36 bangert Exp $
+
+*cronbase-0.3.3 (13 Apr 2009)
+
+ 13 Apr 2009; Thilo Bangert <bangert@gentoo.org> +files/run-crons-0.3.3,
+ +cronbase-0.3.3.ebuild:
+ ignore emacs backup files (bug #237200) - include logging patch (bug
+ #140869)
12 Oct 2008; Thilo Bangert <bangert@gentoo.org> -files/run-crons-0.2.1,
-files/run-crons-0.3, -files/run-crons-0.3.1, -cronbase-0.2.1-r3.ebuild,
diff --git a/sys-process/cronbase/cronbase-0.3.3.ebuild b/sys-process/cronbase/cronbase-0.3.3.ebuild
new file mode 100644
index 000000000000..965418985694
--- /dev/null
+++ b/sys-process/cronbase/cronbase-0.3.3.ebuild
@@ -0,0 +1,45 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/cronbase-0.3.3.ebuild,v 1.1 2009/04/14 06:13:36 bangert Exp $
+
+inherit eutils
+
+DESCRIPTION="base for all cron ebuilds"
+HOMEPAGE="http://www.gentoo.org/"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~sparc-fbsd ~x86 ~x86-fbsd"
+IUSE=""
+
+pkg_setup() {
+ enewgroup cron 16
+ enewuser cron 16 -1 /var/spool/cron cron
+}
+
+src_install() {
+ newsbin "${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
+}
+
+pkg_postinst() {
+ #Portage doesn't enforce proper permissions on already existing"
+ #directories (bug 141619).
+ echo
+ elog "Forcing proper permissions on"
+ elog "${ROOT}etc/cron.{hourly,daily,weekly,monthly},"
+ elog "${ROOT}var/spool/cron/ and ${ROOT}var/spool/cron/lastrun/"
+ echo
+ chmod 0750 "${ROOT}"etc/cron.{hourly,daily,weekly,monthly} \
+ || die "chmod failed"
+ chmod 0750 "${ROOT}"var/spool/{cron,cron/lastrun} || die "chmod failed"
+ chown root:cron "${ROOT}var/spool/cron" || die "chown failed"
+}
diff --git a/sys-process/cronbase/files/run-crons-0.3.3 b/sys-process/cronbase/files/run-crons-0.3.3
new file mode 100755
index 000000000000..8b0116c91d3a
--- /dev/null
+++ b/sys-process/cronbase/files/run-crons-0.3.3
@@ -0,0 +1,110 @@
+#!/bin/bash
+#
+# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/files/run-crons-0.3.3,v 1.1 2009/04/14 06:13:36 bangert Exp $
+#
+# 12 Oct 2008; Thilo Bangert <bangert@gentoo.org> run-crons:
+# ignore emacs backup files (bug #237200)
+# include logging patch (bug #140869)
+#
+# 08 Mar 2005; Aaron Walker <ka0ttic@gentoo.org> run-crons:
+# Ignore the error messages from find caused by race conditions, since
+# we could care less about the error as long as the file has been removed.
+# See bug 8506.
+#
+# 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 {} \; &>/dev/null || true
+ 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
+ GLOBIGNORE="*~"
+ for SCRIPT in $CRONDIR/* ; do
+ if [[ -x $SCRIPT && ! -d $SCRIPT ]]; then
+ [ -x /usr/bin/logger ] && /usr/bin/logger -i -p cron.info -t run-crons "(`whoami`) CMD ($SCRIPT)"
+ $SCRIPT
+ fi
+ done
+ fi
+done
+
+# Clean out bogus cron.$BASE files with future times
+touch ${LOCKDIR}
+find ${LOCKDIR} -newer ${LOCKDIR} -exec /bin/rm -f {} \; &>/dev/null || true