/[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.16
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.16 2013/09/05 10:44:22 zx2c4 Exp $
4 4
5# @ECLASS: cron
6# @MAINTAINER:
7# cron-bugs@gentoo.org
8# @AUTHOR:
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}
30 !virtual/cron
31 virtual/mta
32 >=sys-process/cronbase-0.2.1-r3" 30RDEPEND=">=sys-process/cronbase-0.3.2"
31for pn in vixie-cron bcron cronie dcron fcron; do
32 [[ ${pn} == "${PN}" ]] || RDEPEND="${RDEPEND} !sys-process/${pn}"
33done
33 34
34PROVIDE="virtual/cron" 35# @FUNCTION: docrondir
35 36# @USAGE: [ dir ] [ perms ]
36# docrondir [ dir ] [ perms ] 37# @DESCRIPTION:
37#
38# Creates crontab directory 38# Creates crontab directory
39# 39#
40# Both arguments are optional. Everything after 'dir' is considered 40# Both arguments are optional. Everything after 'dir' is considered
41# the permissions (same format as insopts). 41# the permissions (same format as insopts).
42# 42#
45# docrondir -m0700 (uses default dir) 45# docrondir -m0700 (uses default dir)
46 46
47docrondir() { 47docrondir() {
48 # defaults 48 # defaults
49 local perms="-m0750 -o root -g cron" dir="/var/spool/cron/crontabs" 49 local perms="-m0750 -o root -g cron" dir="/var/spool/cron/crontabs"
50 50
51 if [[ -n "$1" ]] ; then 51 if [[ -n $1 ]] ; then
52 case "$1" in 52 case "$1" in
53 */*) 53 */*)
54 dir="$1" 54 dir=$1
55 shift 55 shift
56 [[ -n "$1" ]] && perms="$@" 56 [[ -n $1 ]] && perms="$@"
57 ;; 57 ;;
58 *) 58 *)
59 perms="$@" 59 perms="$@"
60 ;; 60 ;;
61 esac 61 esac
66 66
67 # reset perms to default 67 # reset perms to default
68 diropts -m0755 68 diropts -m0755
69} 69}
70 70
71# @FUNCTION: docron
71# docron [ exe ] [ perms ] 72# @USAGE: [ exe ] [ perms ]
72# 73# @DESCRIPTION:
73# Install cron executable 74# Install cron executable
74# 75#
75# Both arguments are optional. 76# Both arguments are optional.
76# 77#
77# ex: docron -m 0700 -o root -g root ('exe' defaults to "cron") 78# ex: docron -m 0700 -o root -g root ('exe' defaults to "cron")
78# docron crond -m 0110 79# docron crond -m 0110
79 80
80docron() { 81docron() {
81 local cron="cron" perms="-m 0750 -o root -g root" 82 local cron="cron" perms="-m 0750 -o root -g wheel"
82 83
83 if [[ -n "$1" ]] ; then 84 if [[ -n $1 ]] ; then
84 case "$1" in 85 case "$1" in
85 -*) 86 -*)
86 perms="$@" 87 perms="$@"
87 ;; 88 ;;
88 *) 89 *)
89 cron="$1" 90 cron=$1
90 shift 91 shift
91 [[ -n "$1" ]] && perms="$@" 92 [[ -n $1 ]] && perms="$@"
92 ;; 93 ;;
93 esac 94 esac
94 fi 95 fi
95 96
96 exeopts ${perms} 97 exeopts ${perms}
99 100
100 # reset perms to default 101 # reset perms to default
101 exeopts -m0755 102 exeopts -m0755
102} 103}
103 104
104# docrontab [ exe ] [ perms ] 105# @FUNCTION: docrontab
105# 106# @USAGE: [ exe ] [ perms ]
107# @DESCRIPTION:
106# Install crontab executable 108# Install crontab executable
107# 109#
108# Uses same semantics as docron. 110# Uses same semantics as docron.
109 111
110docrontab() { 112docrontab() {
111 local crontab="crontab" perms="-m 4750 -o root -g cron" 113 local crontab="crontab" perms="-m 4750 -o root -g cron"
112 114
113 if [[ -n "$1" ]] ; then 115 if [[ -n $1 ]] ; then
114 case "$1" in 116 case "$1" in
115 -*) 117 -*)
116 perms="$@" 118 perms="$@"
117 ;; 119 ;;
118 *) 120 *)
119 crontab="$1" 121 crontab=$1
120 shift 122 shift
121 [[ -n "$1" ]] && perms="$@" 123 [[ -n $1 ]] && perms="$@"
122 ;; 124 ;;
123 esac 125 esac
124 fi 126 fi
125 127
126 exeopts ${perms} 128 exeopts ${perms}
135 dosym ${crontab##*/} /usr/bin/crontab || \ 137 dosym ${crontab##*/} /usr/bin/crontab || \
136 die "failed to create /usr/bin/crontab symlink" 138 die "failed to create /usr/bin/crontab symlink"
137 fi 139 fi
138} 140}
139 141
142# @FUNCTION: cron_pkg_postinst
143# @DESCRIPTION:
144# Outputs a message about system crontabs
145# daemons that have a true system crontab set CRON_SYSTEM_CRONTAB="yes"
140cron-pkg_postinst() { 146cron_pkg_postinst() {
141 echo 147 echo
142 # vixie is the only daemon that has a true system crontab 148 # daemons that have a true system crontab set CRON_SYSTEM_CRONTAB="yes"
143 if [[ "${PN}" != "vixie-cron" ]] ; then 149 if [ "${CRON_SYSTEM_CRONTAB:-no}" != "yes" ] ; then
144 einfo "To activate /etc/cron.{hourly|daily|weekly|monthly} please run:" 150 einfo "To activate /etc/cron.{hourly|daily|weekly|monthly} please run:"
145 einfo " crontab /etc/crontab" 151 einfo " crontab /etc/crontab"
146 einfo 152 einfo
147 einfo "!!! That will replace root's current crontab !!!" 153 einfo "!!! That will replace root's current crontab !!!"
148 einfo 154 einfo
149 fi 155 fi
150 156
151 einfo "You may wish to read the Gentoo Linux Cron Guide, which can be" 157 einfo "You may wish to read the Gentoo Linux Cron Guide, which can be"
152 einfo "found online at:" 158 einfo "found online at:"
153 einfo " http://www.gentoo.org/doc/en/cron-guide.xml" 159 einfo " http://www.gentoo.org/doc/en/cron-guide.xml"
154 echo 160 echo
155} 161}

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

  ViewVC Help
Powered by ViewVC 1.1.20