diff options
author | Mike Frysinger <vapier@gentoo.org> | 2015-07-23 02:57:42 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2015-07-23 02:57:42 +0000 |
commit | b84f312836ea879cb071bcf3786093c533342de4 (patch) | |
tree | 9fa2cbc48ca7696bf1ea4fb1953bf0a879364435 /sys-process | |
parent | Use err level when logging failed scripts #540274 by Tobias Klausmann. (diff) | |
download | historical-b84f312836ea879cb071bcf3786093c533342de4.tar.gz historical-b84f312836ea879cb071bcf3786093c533342de4.tar.bz2 historical-b84f312836ea879cb071bcf3786093c533342de4.zip |
Rewrite run-crons in POSIX shell #530416 by Alexander Hof.
Package-Manager: portage-2.2.20/cvs/Linux x86_64
Manifest-Sign-Key: 0xD2E96200
Diffstat (limited to 'sys-process')
-rw-r--r-- | sys-process/cronbase/ChangeLog | 8 | ||||
-rw-r--r-- | sys-process/cronbase/Manifest | 30 | ||||
-rw-r--r-- | sys-process/cronbase/cronbase-0.3.6.ebuild | 33 | ||||
-rwxr-xr-x | sys-process/cronbase/files/run-crons-0.3.6 | 133 |
4 files changed, 189 insertions, 15 deletions
diff --git a/sys-process/cronbase/ChangeLog b/sys-process/cronbase/ChangeLog index 051b114c74fd..afcffe2fdf33 100644 --- a/sys-process/cronbase/ChangeLog +++ b/sys-process/cronbase/ChangeLog @@ -1,6 +1,12 @@ # ChangeLog for sys-process/cronbase # Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/ChangeLog,v 1.45 2015/07/23 02:53:54 vapier Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/ChangeLog,v 1.46 2015/07/23 02:57:41 vapier Exp $ + +*cronbase-0.3.6 (23 Jul 2015) + + 23 Jul 2015; Mike Frysinger <vapier@gentoo.org> +cronbase-0.3.6.ebuild, + +files/run-crons-0.3.6: + Rewrite run-crons in POSIX shell #530416 by Alexander Hof. *cronbase-0.3.5-r1 (23 Jul 2015) diff --git a/sys-process/cronbase/Manifest b/sys-process/cronbase/Manifest index 0184661cabda..74e16e93435b 100644 --- a/sys-process/cronbase/Manifest +++ b/sys-process/cronbase/Manifest @@ -4,25 +4,27 @@ Hash: SHA256 AUX run-crons-0.3.3 3254 SHA256 77aa0820f5827b7fa2c35f877c2dc617c85c0ac80c35002624be091da520141a SHA512 b9f1dce57cb10ae17135bef3d197d411d802feee6645fbd753a08d154a2ab51b08f883995f041be73fd5e9e8c1a3fad487fbb02a141dd6644c339468bfe6c81d WHIRLPOOL 74e31eed4ba85548f89e5a0fa1a6bfb1a47f5b1dad9e2e75c33d796e39216ff6b88ed4e29bbb5ff59f81dfe3aa72268081eb33a4008c440a43303dde3ad2425e AUX run-crons-0.3.4 3350 SHA256 f9671f7f5d0b31f7936c25acdd4cf16ff9d48fc5c9ff87206da8e0ca98a4abba SHA512 79fdeaa3934f9d933d00904859e433d3030f85fecfd6c7d6c97ea6033b1f3a1904c015a41e1b735d28f0b6757cecb27fd34d233e1d159112872c3d6dddaa8654 WHIRLPOOL 00ccdb335ba822406a840f6b0aa9b9b12fafe05e3ea324b00f9605f1297df6b14cfd131962043ad3657bab2395da3864e7c773e2426e6cdd8e22d009330b14bd AUX run-crons-0.3.5 3604 SHA256 af2efd1d424e462a116ee183f25f26e206bd1a6ad3746aba1729cabe71e5c03e SHA512 687160ee29072160cd6b9759d37a4661326a27d6c45f03dd4024f423112a70432ea4ecbe53488611961d5de6b55a3dc2a1399eddc0d20eac49d9e0b18dd92847 WHIRLPOOL 25f498078de4bed767810716ddeb2881cd3e446fbc7cbf06fac04be3b1fd0cfc617a7a2dc158a5120c3150faac66f5226e3082e9bd8fb8ae3bfcafcdf509ea2b +AUX run-crons-0.3.6 3682 SHA256 2cce33854243758a0cad7f3c7e478b77ac7e9bfccf2e71ec5087f139a3817a21 SHA512 aa3b2c7149fd7acf6dd01a29d0b500927ac8e2e27af979eaa4df4f786925a2ebe530fdc1b8b660c0eef26f97f214e8e8940f41d1466cbf9358015c8c38ea695c WHIRLPOOL 83a61e383541ed6350d9f44c8071c44ba090e957b16d80c72fe82cb566f584fe1eba2e62600941d1ee5030fc06714921b3330c74b09fb81e0413abd80f52f644 EBUILD cronbase-0.3.3.ebuild 1401 SHA256 a964082ffb1ec5b03fc534597dd916ed1e8259508a289010957adf1d8facf28a SHA512 c9d6fe9c66345625afef2fbac2d602fcaea7f54acef6e9c5713c43964e3c3f1af96d711e620cbc79b422b5d1157c1cf16e9faac8b43fea6e82ff376677d2c6a4 WHIRLPOOL d2f7abdfd53061e02bbaf6192088a4866d96fb931ba3335b8159974296a4f21ce910bb385818ec3d2d776d8e06b4874b022cd32ca9fae52b0e0dd446f5901339 EBUILD cronbase-0.3.4.ebuild 803 SHA256 85445fdb90299c616fb34534cdce726a0a8dc612367470541b0215ded016db8d SHA512 a976aa24a4091a7c70cce219723108d9f0379a384059875b32a1f03af17dc464ae97dae51d17da952befde3f3b30d38f0c3d481c1c5debb1da4a4357dc6a6ed1 WHIRLPOOL 4ca6cb7f49e577152c9254fbcc6019db0b39673fd35ab14223b9fa34ae1e1da631be7e353dd6c0b33c971badadaf88ea3f736ab96fcaef933d18b1f42b01aaea EBUILD cronbase-0.3.5-r1.ebuild 806 SHA256 626f2d676e3a6cd33b40f76bd28e052f635b48478f8a8eb52c30822be59c4de4 SHA512 e3f49538114ed90962c8a0a1a9df73519bea110b34d5514a43b0d8096454ab1575cdb4afa97989d70e32371ef6785fb918c94ac41bd80ef7766982fa47ff862b WHIRLPOOL 2cf8e2a798a029eec24d532c240a441b799e96fbe19da571b6b40adca60973fbe95a322bab0217e27a2f7db363029c2da6556e04a7a4eb4cadd93355d4a341fa -MISC ChangeLog 9737 SHA256 c6b8db8060903ef76085e1a94a73a2cedac87f20c2e831837246291677390626 SHA512 61668619a08df8663cd68c00edc8fc990c1c324b8a20a22e8da2974ef2a777f224eb281ef83f2a984a69b2e071d7b38c049ee16d980899ad7d79a99ff7b598f3 WHIRLPOOL 2dafda48e11c97cb95656c29e3306ec306d95f29baec5f221833a7bd0fa4e238405132ee868fde7ce3b44940c7e8c4b8c4dcc8569c4fa0c1a0135a679132e3dc +EBUILD cronbase-0.3.6.ebuild 803 SHA256 9d474f20bff1cc54463fa03d7df66f9f613dcd47e0a3c839c36fcc2443ea15f0 SHA512 3162235c3396cd6b2fc40124118da7cc7be8aac7df8346a2a9ddb451119dd03d82b33dcc1f30222c686647a737fd680fa33bbe1c7d5bc112910b471ae48b0c36 WHIRLPOOL cd7e293f7ba175d88af0686c5e0a742dafe399e2e201cd0dae053ba28c8fc72881b4a619800fd3d43158758ce565cbe31d27c1aacb43a7988ba706b3a895cd11 +MISC ChangeLog 9930 SHA256 fe6b9ee15cd6a32302f527164dce9e09c916c1777667ffbe7f6404bf43978aaf SHA512 3d9d911e51e44dddb9289e79d12c6ee513e4bd9ba920706b4e68ab8fab0ffb11786aa2102583086a9f7b9a360d78af3b99ab782bd27ef5e2f98dc62a344ba64a WHIRLPOOL 5d4222139fe7187f60a0a2cac7ae6822cb8ea3263ac7abe5a719549730493e8d0012ae34b4bc821c419ee21420729746fa2e127736827dd47ee5d9c06f28c90f MISC metadata.xml 158 SHA256 a262a73b2049a89ab6a4bdf51df27bea44c7f0aa0ee33176c59a9c63eb45e764 SHA512 0848ecc6b5e718ad001952843f69815fd8c3f50d126d3a2bbc48b86a9bfa21eab50fdb2eb11188362b8ead9db4cefb3719b53e0b76e4412a7a9a377a091e60bc WHIRLPOOL 3034b4ecfc87a8678ffab15dfc07af401c1b53660f7369b80a63b5c20300a3701068e87d7f6ff28ac1fd1c373051ce895e0316ecf7d9e91ad4eb627702b1ba02 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 -iQIcBAEBCAAGBQJVsFdDAAoJEPGu1DbS6WIAeUUP/idl+Sc3qy83ZqU3gdNl2aFj -bq96yM2z78mRMjIquo5Fj/dF+tfLszyWRpOstBkknKD6A3JDL7TZ/aJcHqyQCDBI -aPaP6RFs4rgFhzprENpu/dherfGbIdZ0GsZ86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F8++N2rlq7cKpA7An5uR3StX +wAyOl6LKD2jvQNxQ4UgOA7B7BHUlel5HteSTJ3mpRLgy14oPjh/Cp+s9GEV9MDs9 +VwxSme4RP9Yu3+ImYJKLngoOMFRSzSs008TAeK3VknV+eN1WOIuPiNO8B9c7qwRD +LYPJQTkq+weayj+jnVA8uGpbQfgyukS3rmwJ69FPIjpM+yYjDpMIw/+wbc4yRKjL +5zGTipRhtflF8334tUnY +=WpTe -----END PGP SIGNATURE----- diff --git a/sys-process/cronbase/cronbase-0.3.6.ebuild b/sys-process/cronbase/cronbase-0.3.6.ebuild new file mode 100644 index 000000000000..f55599bc6681 --- /dev/null +++ b/sys-process/cronbase/cronbase-0.3.6.ebuild @@ -0,0 +1,33 @@ +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/cronbase-0.3.6.ebuild,v 1.1 2015/07/23 02:57:41 vapier Exp $ + +EAPI="5" + +inherit user + +DESCRIPTION="base for all cron ebuilds" +HOMEPAGE="http://www.gentoo.org/" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd" +IUSE="" + +S=${WORKDIR} + +pkg_setup() { + enewgroup cron 16 + enewuser cron 16 -1 /var/spool/cron cron +} + +src_install() { + newsbin "${FILESDIR}"/run-crons-${PV} run-crons + + diropts -m0750 + keepdir /etc/cron.{hourly,daily,weekly,monthly} + + keepdir /var/spool/cron/lastrun + diropts -m0750 -o root -g cron + keepdir /var/spool/cron +} diff --git a/sys-process/cronbase/files/run-crons-0.3.6 b/sys-process/cronbase/files/run-crons-0.3.6 new file mode 100755 index 000000000000..fdd54753d5cd --- /dev/null +++ b/sys-process/cronbase/files/run-crons-0.3.6 @@ -0,0 +1,133 @@ +#!/bin/sh +# +# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/files/run-crons-0.3.6,v 1.1 2015/07/23 02:57:41 vapier 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 + +# Usage: log <level> <args to logger> +# Log a message via syslog. +log() { + local level="$1" + shift + logger -i -p "cron.${level}" -t run-crons "$@" +} + +mkdir -p ${LOCKDIR} + +# Make sure we're not running multiple instances at once. +# Try twice to lock, otherwise give up. +i=0 +while [ $(( i += 1 )) -le 2 ] ; 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 + cmdline1=$(cat /proc/${cronpid}/cmdline 2>/dev/null) || : + cmdline2=$(cat /proc/$$/cmdline) + if [ "${cmdline1}" = "${cmdline2}" ] ; 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}" EXIT HUP INT QUIT TERM + + +EXIT_STATUS=0 +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 {} \; 2>/dev/null || : + 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 + # Filter out files people do not expect to be executed. + case ${SCRIPT} in + .*|*~) continue ;; + esac + + log info "($(whoami)) CMD (${SCRIPT})" + $SCRIPT + ret=$? + if [ ${ret} -ne 0 ] ; then + log err "CMD (${SCRIPT}) failed with exit status ${ret}" + EXIT_STATUS=1 + fi + fi + done + fi +done + +# Clean out bogus cron.$BASE files with future times +touch ${LOCKDIR} +find ${LOCKDIR} -newer ${LOCKDIR} -exec /bin/rm -f {} \; 2>/dev/null || : + +exit ${EXIT_STATUS} |