Revision: 3880 http://gar.svn.sourceforge.net/gar/?rev=3880&view=rev Author: wahwah Date: 2009-03-23 16:31:35 +0000 (Mon, 23 Mar 2009)
Log Message: ----------- First commit of vixie-cron. It's not complete yet, and the build is disabled to avoid giving an impression of completed work. It tries to use mGAR SMF support, which isn't currently ready. Added Paths: ----------- csw/mgar/pkg/vixiecron/ csw/mgar/pkg/vixiecron/branches/ csw/mgar/pkg/vixiecron/tags/ csw/mgar/pkg/vixiecron/trunk/ csw/mgar/pkg/vixiecron/trunk/Makefile csw/mgar/pkg/vixiecron/trunk/checksums csw/mgar/pkg/vixiecron/trunk/files/ csw/mgar/pkg/vixiecron/trunk/files/CSWvixiecron.gspec csw/mgar/pkg/vixiecron/trunk/files/CSWvixiecron.postinstall csw/mgar/pkg/vixiecron/trunk/files/crontab.CSW csw/mgar/pkg/vixiecron/trunk/files/cswvixiecron csw/mgar/pkg/vixiecron/trunk/files/cswvixiecron.xml csw/mgar/pkg/vixiecron/trunk/files/gar-vixiecron_3.0pl1.patch csw/mgar/pkg/vixiecron/trunk/files/run-crons-0.3.2 csw/mgar/pkg/vixiecron/trunk/files/svc-cswvixiecron Property changes on: csw/mgar/pkg/vixiecron/trunk ___________________________________________________________________ Added: svn:ignore + work download gar cookies Added: csw/mgar/pkg/vixiecron/trunk/Makefile =================================================================== --- csw/mgar/pkg/vixiecron/trunk/Makefile (rev 0) +++ csw/mgar/pkg/vixiecron/trunk/Makefile 2009-03-23 16:31:35 UTC (rev 3880) @@ -0,0 +1,72 @@ +# Copyright 2009 Google Inc. +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +GARNAME = vixiecron +GARVERSION = 3.0pl1 +CATEGORIES = server + +DESCRIPTION = Paul Vixie cron +define BLURB + vixiecron is one of the most widely used cron implementations. + + This build includes patches from Debian. It supports /etc/cron.d directory, + which can be used to conveniently set up cron jobs by placing files. It also + supports a slash notation: */5 denotes "Every five minutes". +endef + +MASTER_SITES = http://ftp.de.debian.org/debian/pool/main/c/cron/ +DISTFILES = cron_$(GARVERSION).orig.tar.gz +DISTFILES += cron_$(GARVERSION)-105.diff.gz +DISTFILES += $(call admfiles,CSWvixiecron,postinstall) +DISTFILES += csw$(GARNAME) csw$(GARNAME).xml svc-csw$(GARNAME) +DISTFILES += crontab.CSW run-crons-0.3.2 + +WORKSRC = $(WORKDIR)/cron-$(GARVERSION).orig + +SPKG_CLASSES = none cswinitsmf + +PATCHFILES = cron_$(GARVERSION)-105.diff.gz \ + gar-$(GARNAME)_$(GARVERSION).patch + +GARCOMPILER = SOS12 +TEST_SCRIPTS = +CONFIGURE_SCRIPTS = +EXTRA_CFLAGS = -DDEBUGGING=0 -DPOSIX -DDEBIAN + +pre-install: + ginstall -d $(DESTDIR)/opt/csw + ginstall -d $(DESTDIR)/opt/csw/bin + ginstall -d $(DESTDIR)/opt/csw/sbin + ginstall -d $(DESTDIR)/opt/csw/share/man/cat5 + ginstall -d $(DESTDIR)/opt/csw/share/man/cat8 + +pre-install-isa-sparcv9: pre-install +pre-install-isa-sparcv8: pre-install +pre-install-isa-i386: pre-install +pre-install-isa-amd64: pre-install + +post-install: + ginstall -d $(DESTDIR)/etc + ginstall -m 750 files/crontab.CSW $(DESTDIR)/etc/crontab.CSW + ginstall -m 755 files/run-crons-0.3.2 $(DESTDIR)/opt/csw/sbin/run-crons + for base in hourly daily weekly monthly; do \ + ginstall -d $(DESTDIR)/etc/cron.$$base; \ + done + +post-install-isa-sparcv8: post-install +post-install-isa-sparcv9: post-install +post-install-isa-i386: post-install +post-install-isa-amd64: post-install + + +# This build is disabled for the time being, as SMF configuration isn't yet +# complete. + +# Remove the following rules and uncomment the +# include before building. +all: .DEFAULT +.DEFAULT: + @true + +# include gar/category.mk Added: csw/mgar/pkg/vixiecron/trunk/checksums =================================================================== --- csw/mgar/pkg/vixiecron/trunk/checksums (rev 0) +++ csw/mgar/pkg/vixiecron/trunk/checksums 2009-03-23 16:31:35 UTC (rev 3880) @@ -0,0 +1,11 @@ +4c64aece846f8483daf440f8e3dd210f download/cron_3.0pl1.orig.tar.gz +6235d305843da483b69671cde7d1d8ea download/cron_3.0pl1-105.diff.gz +35010a2f583a6e3dc9f0a0e996b426f4 download/CSWvixiecron.gspec +dd12d38a20e3f780fbcba0a1b1ffbfd0 download/CSWvixiecron.postinstall +b5cdad15f8d66a84b807cd9cf5a04171 download/cswvixiecron +4674c86391ccc621a6bab5442a323313 download/cswvixiecron.xml +b5cdad15f8d66a84b807cd9cf5a04171 download/svc-cswvixiecron +d1c17a3cf4f1ff253c36897d94b0b834 download/crontab.CSW +d0dd7b19670e9a40060977b0b8779cad download/run-crons-0.3.2 +6235d305843da483b69671cde7d1d8ea download/cron_3.0pl1-105.diff.gz +cf0aa68ad98415650daad595fbc415cf download/gar-vixiecron_3.0pl1.patch Added: csw/mgar/pkg/vixiecron/trunk/files/CSWvixiecron.gspec =================================================================== --- csw/mgar/pkg/vixiecron/trunk/files/CSWvixiecron.gspec (rev 0) +++ csw/mgar/pkg/vixiecron/trunk/files/CSWvixiecron.gspec 2009-03-23 16:31:35 UTC (rev 3880) @@ -0,0 +1,5 @@ +%var bitname vixiecron +%var pkgname CSWvixiecron +%include url file://%{PKGLIB}/csw_dyndepend.gspec +%var SERVICE_CONF_FILES /etc/crontab +%include url file://%{PKGLIB}/smf_enabled.gspec Added: csw/mgar/pkg/vixiecron/trunk/files/CSWvixiecron.postinstall =================================================================== --- csw/mgar/pkg/vixiecron/trunk/files/CSWvixiecron.postinstall (rev 0) +++ csw/mgar/pkg/vixiecron/trunk/files/CSWvixiecron.postinstall 2009-03-23 16:31:35 UTC (rev 3880) @@ -0,0 +1,29 @@ +#!/bin/sh +# +# $Id$ +# +# Note: it's going to be executed by /bin/sh no matter what. + +# Add group crontab if it doesn't exist +if groupmod crontab >/dev/null; then + echo # How to make a negation in /bin/sh? +else + groupadd crontab +fi + +# Prepare the directory for crontabs +mkdir -p /var/spool/cron/crontabs +chown root:crontab /var/spool/cron/crontabs +chmod 1730 /var/spool/cron/crontabs + +# Suid bit is not picked up by GAR automatically. An 'artifact' is raised: +# https://sourceforge.net/tracker2/?func=detail&aid=2679715&group_id=229205&atid=1075770 +chmod g+s /opt/csw/bin/crontab +chown root:crontab /opt/csw/bin/crontab + +# Copy the configuration file if not already present +if test ! -f /etc/crontab; then + cp /etc/crontab.CSW /etc/crontab +fi + + Added: csw/mgar/pkg/vixiecron/trunk/files/crontab.CSW =================================================================== --- csw/mgar/pkg/vixiecron/trunk/files/crontab.CSW (rev 0) +++ csw/mgar/pkg/vixiecron/trunk/files/crontab.CSW 2009-03-23 16:31:35 UTC (rev 3880) @@ -0,0 +1,19 @@ +# /etc/crontab: system-wide crontab +# +# $Id$ +# +# Unlike any other crontab you don't have to run the `crontab' +# command to install the new version when you edit this file. +# This file also has a username field, that none of the other crontabs do. + +SHELL=/bin/bash +PATH=/opt/csw/sbin:/opt/csw/bin:/sbin:/bin:/usr/sbin:/usr/bin +MAILTO=root +HOME=/ + +# m h dom mon dow user command +0 * * * * root rm -f /var/spool/cron/lastrun/cron.hourly +1 3 * * * root rm -f /var/spool/cron/lastrun/cron.daily +15 4 * * 6 root rm -f /var/spool/cron/lastrun/cron.weekly +30 5 1 * * root rm -f /var/spool/cron/lastrun/cron.monthly +*/10 * * * * root test -x /opt/csw/sbin/run-crons && /opt/csw/sbin/run-crons Added: csw/mgar/pkg/vixiecron/trunk/files/cswvixiecron =================================================================== --- csw/mgar/pkg/vixiecron/trunk/files/cswvixiecron (rev 0) +++ csw/mgar/pkg/vixiecron/trunk/files/cswvixiecron 2009-03-23 16:31:35 UTC (rev 3880) @@ -0,0 +1,17 @@ +#!/bin/sh +# +# $Id$ + +case "$1" in + start) + /opt/csw/sbin/cron -l + ;; + + stop) + /usr/bin/pkill -z `zonename` '^cron$' + ;; + *) + echo "Usage: $0 { start | stop }" + exit 1 + ;; +esac Added: csw/mgar/pkg/vixiecron/trunk/files/cswvixiecron.xml =================================================================== --- csw/mgar/pkg/vixiecron/trunk/files/cswvixiecron.xml (rev 0) +++ csw/mgar/pkg/vixiecron/trunk/files/cswvixiecron.xml 2009-03-23 16:31:35 UTC (rev 3880) @@ -0,0 +1,24 @@ +<?xml version='1.0'?> +<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> +<service_bundle type='manifest' name='export'> + <service name='system/cswcron' type='service' version='0'> + <single_instance/> + <dependency name='fs' grouping='require_all' restart_on='none' type='service'> + <service_fmri value='svc:/system/filesystem/local'/> + </dependency> + <dependency name='net' grouping='require_all' restart_on='none' type='service'> + <service_fmri value='svc:/network/loopback'/> + </dependency> + <exec_method name='start' type='method' exec='/opt/csw/lib/svc/method/svc-cswvixiecron start' timeout_seconds='30'> + <method_context/> + </exec_method> + <exec_method name='stop' type='method' exec='/opt/csw/lib/svc/method/svc-cswvixiecron stop' timeout_seconds='30'> + <method_context/> + </exec_method> + <instance name='default' enabled='true'> + <property_group name='general' type='framework'> + <propval name='package' type='astring' value='CSWvixiecron'/> + </property_group> + </instance> + </service> +</service_bundle> Added: csw/mgar/pkg/vixiecron/trunk/files/gar-vixiecron_3.0pl1.patch =================================================================== --- csw/mgar/pkg/vixiecron/trunk/files/gar-vixiecron_3.0pl1.patch (rev 0) +++ csw/mgar/pkg/vixiecron/trunk/files/gar-vixiecron_3.0pl1.patch 2009-03-23 16:31:35 UTC (rev 3880) @@ -0,0 +1,268 @@ +diff -ur cron-3.0pl1.orig-solaris/compat.c cron-3.0pl1.orig/compat.c +--- cron-3.0pl1.orig-solaris/compat.c 2009-03-12 13:30:53.000000000 +0000 ++++ cron-3.0pl1.orig/compat.c 2009-03-12 15:10:44.820233050 +0000 +@@ -33,6 +33,8 @@ + #endif + #include <errno.h> + ++#include <sys/types.h> ++#include <sys/stat.h> + + /* the code does not depend on any of vfork's + * side-effects; it just uses it as a quick +@@ -85,8 +87,8 @@ + #ifdef NEED_STRCASECMP + int + strcasecmp(left, right) +- char *left; +- char *right; ++ const char *left; ++ const char *right; + { + while (*left && (MkLower(*left) == MkLower(*right))) { + left++; +@@ -236,3 +238,13 @@ + return putenv(tmp); /* intentionally orphan 'tmp' storage */ + } + #endif ++ ++/* Solaris 10 is missing mkdtemp */ ++char *mkdtemp(char *template) ++{ ++ if (!mktemp(template) || mkdir(template, 0700)) ++ return NULL; ++ return template; ++} ++ ++ +diff -ur cron-3.0pl1.orig-solaris/compat.h cron-3.0pl1.orig/compat.h +--- cron-3.0pl1.orig-solaris/compat.h 2009-03-12 13:30:53.000000000 +0000 ++++ cron-3.0pl1.orig/compat.h 2009-03-12 15:20:37.912499900 +0000 +@@ -63,7 +63,8 @@ + + #ifndef POSIX + # if (BSD >= 199103) || defined(__linux__) || defined(__GNU__) || defined(ultrix) ||\ +- defined(AIX) ||\ defined(HPUX) || defined(CONVEX) || defined(IRIX) || defined(__GLIBC__) ++ defined(AIX) ||\ ++defined(HPUX) || defined(CONVEX) || defined(IRIX) || defined(__GLIBC__) + # define POSIX + # endif + #endif +@@ -86,7 +87,7 @@ + #endif + + #if (!defined(BSD) || (BSD < 198911)) && !defined(__linux__) &&\ +- !defined(IRIX) && !defined(UNICOS) && !defined(HPUX) && !defined(__GNU__) && !defined(__GLIBC__) ++ !defined(IRIX) && !defined(UNICOS) && !defined(HPUX) && !defined(__GNU__) && !defined(__GLIBC__) && !defined(__SUNPRO_C) + # define NEED_STRDUP + #endif + +@@ -110,7 +111,7 @@ + # define HAVE_SAVED_UIDS + #endif + +-#if !defined(ATT) && !defined(__linux__) && !defined(__GNU__) && !defined(IRIX) && !defined(UNICOS) && !defined(__GLIBC__) ++ #if !defined(ATT) && !defined(__linux__) && !defined(__GNU__) && !defined(IRIX) && !defined(UNICOS) && !defined(__GLIBC__) && !defined(__SUNPRO_C) + # define USE_SIGCHLD + #endif + +Only in cron-3.0pl1.orig: compat.o +Only in cron-3.0pl1.orig: cron +diff -ur cron-3.0pl1.orig-solaris/cron.c cron-3.0pl1.orig/cron.c +--- cron-3.0pl1.orig-solaris/cron.c 2009-03-12 13:30:53.000000000 +0000 ++++ cron-3.0pl1.orig/cron.c 2009-03-12 15:09:25.251653050 +0000 +@@ -401,7 +401,7 @@ + + #ifdef USE_SIGCHLD + static void +-sigchld_handler(x) { ++sigchld_handler(int x) { + int save_errno = errno; + WAIT_T waiter; + PID_T pid; +@@ -435,7 +435,7 @@ + + + static void +-sighup_handler(x) { ++sighup_handler(int x) { + log_close(); + + /* we should use sigaction for proper signal blocking as this +diff -ur cron-3.0pl1.orig-solaris/cron.h cron-3.0pl1.orig/cron.h +--- cron-3.0pl1.orig-solaris/cron.h 2009-03-12 13:30:53.000000000 +0000 ++++ cron-3.0pl1.orig/cron.h 2009-03-12 15:19:14.122628700 +0000 +@@ -32,7 +32,7 @@ + + #include <stdio.h> + #include <ctype.h> +-#include <bitstring.h> ++#include "bitstring.h" + #include <pwd.h> + #include <sys/wait.h> + +Only in cron-3.0pl1.orig: cron.o +Only in cron-3.0pl1.orig: crontab +Only in cron-3.0pl1.orig: crontab.o +Only in cron-3.0pl1.orig: database.o +Only in cron-3.0pl1.orig: do_command.o +Only in cron-3.0pl1.orig: entry.o +Only in cron-3.0pl1.orig: env.o +diff -ur cron-3.0pl1.orig-solaris/externs.h cron-3.0pl1.orig/externs.h +--- cron-3.0pl1.orig-solaris/externs.h 2009-03-12 13:30:53.000000000 +0000 ++++ cron-3.0pl1.orig/externs.h 2009-03-12 13:35:46.000000000 +0000 +@@ -116,11 +116,11 @@ + #endif + + #ifdef NEED_STRCASECMP +-extern int strcasecmp __P((char *, char *)); ++extern int strcasecmp __P((const char *, const char *)); + #endif + + #ifdef NEED_STRDUP +-extern char *strdup __P((char *)); ++extern char *strdup __P((const char *)); + #endif + + #ifdef NEED_STRERROR +Only in cron-3.0pl1.orig: job.o +diff -ur cron-3.0pl1.orig-solaris/Makefile cron-3.0pl1.orig/Makefile +--- cron-3.0pl1.orig-solaris/Makefile 2009-03-12 13:30:53.000000000 +0000 ++++ cron-3.0pl1.orig/Makefile 2009-03-12 17:39:22.971233150 +0000 +@@ -47,7 +47,7 @@ + + #################################### begin configurable stuff + #<<DESTROOT is assumed to have ./etc, ./bin, and ./man subdirectories>> +-DESTROOT = $(DESTDIR)/usr ++DESTROOT = $(DESTDIR)/opt/csw + DESTSBIN = $(DESTROOT)/sbin + DESTBIN = $(DESTROOT)/bin + DESTMAN = $(DESTROOT)/share/man +@@ -57,7 +57,7 @@ + #<<need getopt()>> + LIBS = $(PAM_LIBS) $(SELINUX_LIBS) $(AUDIT_LIBS) + #<<optimize or debug?>> +-OPTIM = -O2 ++#OPTIM = -O2 + #OPTIM = -g + #<<ATT or BSD or POSIX?>> + # (ATT untested) +@@ -74,12 +74,12 @@ + # Allow override from command line + DEBUG_DEFS = -DDEBUGGING=0 + # The -DUSE_SIGCHLD is needed for the Alpha port +-DEFS = -DDEBIAN -DUSE_SIGCHLD $(DEBUG_DEFS) $(PAM_DEFS) $(SELINUX_DEFS) ++#DEFS = -DDEBIAN -DUSE_SIGCHLD $(DEBUG_DEFS) $(PAM_DEFS) $(SELINUX_DEFS) + #(SGI IRIX systems need this) + #DEFS = -D_BSD_SIGNALS -Dconst= + #<<the name of the BSD-like install program>> + #INSTALL = installbsd +-INSTALL = install -s ++INSTALL = ginstall -s + #<<any special load flags>> + # LDFLAGS = -s + # Let install do the strip +@@ -87,7 +87,7 @@ + #################################### end configurable stuff + + SHELL = /bin/sh +-CFLAGS = $(OPTIM) $(INCLUDE) $(COMPAT) $(DEFS) ++# CFLAGS = $(OPTIM) $(INCLUDE) $(COMPAT) $(DEFS) + + INFOS = README CHANGES FEATURES INSTALL CONVERSION THANKS MAIL + MANPAGES = bitstring.3 crontab.5 crontab.1 cron.8 putman.sh +@@ -118,8 +118,8 @@ + $(CC) $(LDFLAGS) -o crontab $(CRONTAB_OBJ) $(LIBS) + + install : all +- $(INSTALL) -c -m 755 -o root cron $(DESTSBIN)/ +- $(INSTALL) -c -m 4755 -o root crontab $(DESTBIN)/ ++ $(INSTALL) -c -m 755 cron $(DESTSBIN)/ ++ $(INSTALL) -c -m 2755 crontab $(DESTBIN)/ + sh putman.sh crontab.1 $(DESTMAN) + sh putman.sh cron.8 $(DESTMAN) + sh putman.sh crontab.5 $(DESTMAN) +diff -ur cron-3.0pl1.orig-solaris/misc.c cron-3.0pl1.orig/misc.c +--- cron-3.0pl1.orig-solaris/misc.c 2009-03-12 13:30:53.000000000 +0000 ++++ cron-3.0pl1.orig/misc.c 2009-03-12 13:38:43.000000000 +0000 +@@ -42,6 +42,7 @@ + # include <syslog.h> + #endif + ++#include <sys/file.h> + + #if defined(LOG_DAEMON) && !defined(LOG_CRON) + #define LOG_CRON LOG_DAEMON +@@ -277,7 +278,8 @@ + exit(ERROR_EXIT); + } + +- if (flock(fd, LOCK_EX|LOCK_NB) < OK) { ++ /* This bit originally used flock(), switched to lockf() */ ++ if (lockf(fd, F_TLOCK, 0) < OK) { + int save_errno = errno; + + fscanf(fp, "%d", &otherpid); +Only in cron-3.0pl1.orig: misc.o +diff -ur cron-3.0pl1.orig-solaris/popen.c cron-3.0pl1.orig/popen.c +--- cron-3.0pl1.orig-solaris/popen.c 2009-03-12 13:30:53.000000000 +0000 ++++ cron-3.0pl1.orig/popen.c 2009-03-12 16:04:25.829649200 +0000 +@@ -35,6 +35,10 @@ + # include <grp.h> + #endif + ++#include<string.h> ++#include<strings.h> ++#include<sys/types.h> ++#include<sys/stat.h> + + #define MAX_ARGS 100 + #define WANT_GLOBBING 0 +@@ -167,9 +171,12 @@ + FILE *iop; + { + register int fdes; +- int omask; + WAIT_T stat_loc; + PID_T pid; ++ /* ++ * http://www.phys.ufl.edu/docs/porting-faq.html ++ */ ++ sigset_t block, oblock; + + /* + * pclose returns -1 if stream is not associated with a +@@ -178,10 +185,20 @@ + if (pids == 0 || pids[fdes = fileno(iop)] == 0) + return(-1); + (void)fclose(iop); +- omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP)); ++ /* ++ * omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP)); ++ */ ++ (void)sigemptyset(&block); ++ (void)sigaddset(&block, SIGINT | SIGQUIT | SIGHUP); ++ if (sigprocmask(SIG_BLOCK, &block, &oblock) < 0) ++ log_it("CRON", getpid(), "error", "sigprocmask") ++ ; + while ((pid = wait(&stat_loc)) != pids[fdes] && pid != -1) + ; +- (void)sigsetmask(omask); ++ /* ++ * (void)sigsetmask(omask); ++ */ ++ (void)sigprocmask(SIG_SETMASK, &oblock, (sigset_t *)NULL); + pids[fdes] = 0; + return (pid == -1 ? -1 : WEXITSTATUS(stat_loc)); + } +Only in cron-3.0pl1.orig: popen.o +diff -ur cron-3.0pl1.orig-solaris/putman.sh cron-3.0pl1.orig/putman.sh +--- cron-3.0pl1.orig-solaris/putman.sh 1994-09-01 20:17:17.000000000 +0000 ++++ cron-3.0pl1.orig/putman.sh 2009-03-12 20:04:07.194853350 +0000 +@@ -1,4 +1,4 @@ +-#!/bin/sh ++#!/bin/bash + + # putman.sh - install a man page according to local custom + # vixie 27dec93 [original] +Only in cron-3.0pl1.orig: user.o Added: csw/mgar/pkg/vixiecron/trunk/files/run-crons-0.3.2 =================================================================== --- csw/mgar/pkg/vixiecron/trunk/files/run-crons-0.3.2 (rev 0) +++ csw/mgar/pkg/vixiecron/trunk/files/run-crons-0.3.2 2009-03-23 16:31:35 UTC (rev 3880) @@ -0,0 +1,108 @@ +#!/bin/bash +# +# $Id$ +# +# File copied from Gentoo portage, package sys-process/cronbase. +# +# $Header: /var/cvsroot/gentoo-x86/sys-process/cronbase/files/run-crons-0.3.2,v 1.2 2007/06/24 20:23:45 vapier Exp $ +# +# 08 Mar 2005; Aaron Walker <ka0t...@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 <agrif...@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 <jnel...@gentoo.org> run-crons: +# fixed a race condition, where cron jobs and run-crons wanted to +# delete touch files +# +# 20 Apr 2002; Thilo Bangert <bang...@gentoo.org> run-crons: +# moved lastrun directory to /var/spool/cron/lastrun +# +# Author: Achim Gottinger <ac...@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 + 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 {} \; &>/dev/null || true Added: csw/mgar/pkg/vixiecron/trunk/files/svc-cswvixiecron =================================================================== --- csw/mgar/pkg/vixiecron/trunk/files/svc-cswvixiecron (rev 0) +++ csw/mgar/pkg/vixiecron/trunk/files/svc-cswvixiecron 2009-03-23 16:31:35 UTC (rev 3880) @@ -0,0 +1,17 @@ +#!/bin/sh +# +# $Id$ + +case "$1" in + start) + /opt/csw/sbin/cron -l + ;; + + stop) + /usr/bin/pkill -z `zonename` '^cron$' + ;; + *) + echo "Usage: $0 { start | stop }" + exit 1 + ;; +esac This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ devel mailing list devel@lists.opencsw.org https://lists.opencsw.org/mailman/listinfo/devel