/[gentoo-x86]/eclass/cron.eclass
Gentoo

Diff of /eclass/cron.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.3 Revision 1.14
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2011 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/cron.eclass,v 1.3 2005/03/04 23:25:25 ciaranm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cron.eclass,v 1.14 2011/04/26 11:37:37 ulm Exp $
4 4
5# @ECLASS: cron
6# @MAINTAINER:
7# cron-bugs@gentoo.org
8#
5# Original Author: Aaron Walker <ka0ttic@gentoo.org> 9# Original Author: Aaron Walker <ka0ttic@gentoo.org>
6# 10# @BLURB: Some functions for cron
11# @DESCRIPTION:
7# Purpose: The main motivation for this eclass was to simplify 12# Purpose: The main motivation for this eclass was to simplify
8# the jungle known as src_install() in cron ebuilds. Using these 13# the jungle known as src_install() in cron ebuilds. Using these
9# functions also ensures that permissions are *always* reset, 14# functions also ensures that permissions are *always* reset,
10# preventing the accidental installation of files with wrong perms. 15# preventing the accidental installation of files with wrong perms.
11# 16#
14# 19#
15# Please assign any bugs regarding this eclass to cron-bugs@gentoo.org. 20# Please assign any bugs regarding this eclass to cron-bugs@gentoo.org.
16 21
17inherit eutils flag-o-matic 22inherit eutils flag-o-matic
18 23
19ECLASS="cron"
20INHERITED="$INHERITED $ECLASS"
21EXPORT_FUNCTIONS pkg_postinst 24EXPORT_FUNCTIONS pkg_postinst
22 25
23SLOT="0" 26SLOT="0"
24 27
25DEPEND="${DEPEND}
26 virtual/libc
27 >=sys-apps/sed-4.0.5" 28DEPEND=">=sys-apps/sed-4.0.5"
28 29
29RDEPEND="${RDEPEND} 30RDEPEND="virtual/mta
30 !virtual/cron
31 virtual/mta
32 >=sys-process/cronbase-0.2.1-r3" 31 >=sys-process/cronbase-0.3.2"
32for pn in vixie-cron bcron cronie dcron fcron; do
33 [[ ${pn} == "${PN}" ]] || RDEPEND="${RDEPEND} !sys-process/${pn}"
34done
33 35
34PROVIDE="virtual/cron" 36# @FUNCTION: docrondir
35 37# @USAGE: [ dir ] [ perms ]
36# docrondir [ dir ] [ perms ] 38# @DESCRIPTION:
37#
38# Creates crontab directory 39# Creates crontab directory
39# 40#
40# Both arguments are optional. Everything after 'dir' is considered 41# Both arguments are optional. Everything after 'dir' is considered
41# the permissions (same format as insopts). 42# the permissions (same format as insopts).
42# 43#
45# docrondir -m0700 (uses default dir) 46# docrondir -m0700 (uses default dir)
46 47
47docrondir() { 48docrondir() {
48 # defaults 49 # defaults
49 local perms="-m0750 -o root -g cron" dir="/var/spool/cron/crontabs" 50 local perms="-m0750 -o root -g cron" dir="/var/spool/cron/crontabs"
50 51
51 if [[ -n "$1" ]] ; then 52 if [[ -n $1 ]] ; then
52 case "$1" in 53 case "$1" in
53 */*) 54 */*)
54 dir="$1" 55 dir=$1
55 shift 56 shift
56 [[ -n "$1" ]] && perms="$@" 57 [[ -n $1 ]] && perms="$@"
57 ;; 58 ;;
58 *) 59 *)
59 perms="$@" 60 perms="$@"
60 ;; 61 ;;
61 esac 62 esac
66 67
67 # reset perms to default 68 # reset perms to default
68 diropts -m0755 69 diropts -m0755
69} 70}
70 71
72# @FUNCTION: docron
71# docron [ exe ] [ perms ] 73# @USAGE: [ exe ] [ perms ]
72# 74# @DESCRIPTION:
73# Install cron executable 75# Install cron executable
74# 76#
75# Both arguments are optional. 77# Both arguments are optional.
76# 78#
77# ex: docron -m 0700 -o root -g root ('exe' defaults to "cron") 79# ex: docron -m 0700 -o root -g root ('exe' defaults to "cron")
78# docron crond -m 0110 80# docron crond -m 0110
79 81
80docron() { 82docron() {
81 local cron="cron" perms="-m 0750 -o root -g root" 83 local cron="cron" perms="-m 0750 -o root -g wheel"
82 84
83 if [[ -n "$1" ]] ; then 85 if [[ -n $1 ]] ; then
84 case "$1" in 86 case "$1" in
85 -*) 87 -*)
86 perms="$@" 88 perms="$@"
87 ;; 89 ;;
88 *) 90 *)
89 cron="$1" 91 cron=$1
90 shift 92 shift
91 [[ -n "$1" ]] && perms="$@" 93 [[ -n $1 ]] && perms="$@"
92 ;; 94 ;;
93 esac 95 esac
94 fi 96 fi
95 97
96 exeopts ${perms} 98 exeopts ${perms}
99 101
100 # reset perms to default 102 # reset perms to default
101 exeopts -m0755 103 exeopts -m0755
102} 104}
103 105
104# docrontab [ exe ] [ perms ] 106# @FUNCTION: docrontab
105# 107# @USAGE: [ exe ] [ perms ]
108# @DESCRIPTION:
106# Install crontab executable 109# Install crontab executable
107# 110#
108# Uses same semantics as docron. 111# Uses same semantics as docron.
109 112
110docrontab() { 113docrontab() {
111 local crontab="crontab" perms="-m 4750 -o root -g cron" 114 local crontab="crontab" perms="-m 4750 -o root -g cron"
112 115
113 if [[ -n "$1" ]] ; then 116 if [[ -n $1 ]] ; then
114 case "$1" in 117 case "$1" in
115 -*) 118 -*)
116 perms="$@" 119 perms="$@"
117 ;; 120 ;;
118 *) 121 *)
119 crontab="$1" 122 crontab=$1
120 shift 123 shift
121 [[ -n "$1" ]] && perms="$@" 124 [[ -n $1 ]] && perms="$@"
122 ;; 125 ;;
123 esac 126 esac
124 fi 127 fi
125 128
126 exeopts ${perms} 129 exeopts ${perms}
135 dosym ${crontab##*/} /usr/bin/crontab || \ 138 dosym ${crontab##*/} /usr/bin/crontab || \
136 die "failed to create /usr/bin/crontab symlink" 139 die "failed to create /usr/bin/crontab symlink"
137 fi 140 fi
138} 141}
139 142
143# @FUNCTION: cron_pkg_postinst
144# @DESCRIPTION:
145# Outputs a message about system crontabs
146# daemons that have a true system crontab set CRON_SYSTEM_CRONTAB="yes"
140cron-pkg_postinst() { 147cron_pkg_postinst() {
141 echo 148 echo
142 # vixie is the only daemon that has a true system crontab 149 # daemons that have a true system crontab set CRON_SYSTEM_CRONTAB="yes"
143 if [[ "${PN}" != "vixie-cron" ]] ; then 150 if [ "${CRON_SYSTEM_CRONTAB:-no}" != "yes" ] ; then
144 einfo "To activate /etc/cron.{hourly|daily|weekly|monthly} please run:" 151 einfo "To activate /etc/cron.{hourly|daily|weekly|monthly} please run:"
145 einfo " crontab /etc/crontab" 152 einfo " crontab /etc/crontab"
146 einfo 153 einfo
147 einfo "!!! That will replace root's current crontab !!!" 154 einfo "!!! That will replace root's current crontab !!!"
148 einfo 155 einfo
149 fi 156 fi
150 157
151 einfo "You may wish to read the Gentoo Linux Cron Guide, which can be" 158 einfo "You may wish to read the Gentoo Linux Cron Guide, which can be"
152 einfo "found online at:" 159 einfo "found online at:"
153 einfo " http://www.gentoo.org/doc/en/cron-guide.xml" 160 einfo " http://www.gentoo.org/doc/en/cron-guide.xml"
154 echo 161 echo
155} 162}

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.20