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

Diff of /eclass/cron.eclass

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

Revision 1.1 Revision 1.13
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.1 2005/01/15 12:37:53 ka0ttic Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cron.eclass,v 1.13 2011/04/20 17:49:19 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="!sys-process/vixie-cron
30 !virtual/cron 31 !sys-process/bcron
32 !sys-process/cronie
33 !sys-process/dcron
34 !sys-process/fcron
31 virtual/mta 35 virtual/mta
32 >=sys-apps/cronbase-0.2.1-r3" 36 >=sys-process/cronbase-0.3.2"
33 37
34PROVIDE="virtual/cron" 38# @FUNCTION: docrondir
35 39# @USAGE: [ dir ] [ perms ]
36# docrondir [ dir ] [ perms ] 40# @DESCRIPTION:
37#
38# Creates crontab directory 41# Creates crontab directory
39# 42#
40# Both arguments are optional. Everything after 'dir' is considered 43# Both arguments are optional. Everything after 'dir' is considered
41# the permissions (same format as insopts). 44# the permissions (same format as insopts).
42# 45#
45# docrondir -m0700 (uses default dir) 48# docrondir -m0700 (uses default dir)
46 49
47docrondir() { 50docrondir() {
48 # defaults 51 # defaults
49 local perms="-m0750 -o root -g cron" dir="/var/spool/cron/crontabs" 52 local perms="-m0750 -o root -g cron" dir="/var/spool/cron/crontabs"
50 53
51 if [[ -n "$1" ]] ; then 54 if [[ -n $1 ]] ; then
52 case "$1" in 55 case "$1" in
53 */*) 56 */*)
54 dir="$1" 57 dir=$1
55 shift 58 shift
56 [[ -n "$1" ]] && perms="$@" 59 [[ -n $1 ]] && perms="$@"
57 ;; 60 ;;
58 *) 61 *)
59 perms="$@" 62 perms="$@"
60 ;; 63 ;;
61 esac 64 esac
66 69
67 # reset perms to default 70 # reset perms to default
68 diropts -m0755 71 diropts -m0755
69} 72}
70 73
74# @FUNCTION: docron
71# docron [ exe ] [ perms ] 75# @USAGE: [ exe ] [ perms ]
72# 76# @DESCRIPTION:
73# Install cron executable 77# Install cron executable
74# 78#
75# Both arguments are optional. 79# Both arguments are optional.
76# 80#
77# ex: docron -m 0700 -o root -g root ('exe' defaults to "cron") 81# ex: docron -m 0700 -o root -g root ('exe' defaults to "cron")
78# docron crond -m 0110 82# docron crond -m 0110
79 83
80docron() { 84docron() {
81 local cron="cron" perms="-m 0750 -o root -g root" 85 local cron="cron" perms="-m 0750 -o root -g wheel"
82 86
83 if [[ -n "$1" ]] ; then 87 if [[ -n $1 ]] ; then
84 case "$1" in 88 case "$1" in
85 -*) 89 -*)
86 perms="$@" 90 perms="$@"
87 ;; 91 ;;
88 *) 92 *)
89 cron="$1" 93 cron=$1
90 shift 94 shift
91 [[ -n "$1" ]] && perms="$@" 95 [[ -n $1 ]] && perms="$@"
92 ;; 96 ;;
93 esac 97 esac
94 fi 98 fi
95 99
96 exeopts ${perms} 100 exeopts ${perms}
99 103
100 # reset perms to default 104 # reset perms to default
101 exeopts -m0755 105 exeopts -m0755
102} 106}
103 107
104# docrontab [ exe ] [ perms ] 108# @FUNCTION: docrontab
105# 109# @USAGE: [ exe ] [ perms ]
110# @DESCRIPTION:
106# Install crontab executable 111# Install crontab executable
107# 112#
108# Uses same semantics as docron. 113# Uses same semantics as docron.
109 114
110docrontab() { 115docrontab() {
111 local crontab="crontab" perms="-m 4750 -o root -g cron" 116 local crontab="crontab" perms="-m 4750 -o root -g cron"
112 117
113 if [[ -n "$1" ]] ; then 118 if [[ -n $1 ]] ; then
114 case "$1" in 119 case "$1" in
115 -*) 120 -*)
116 perms="$@" 121 perms="$@"
117 ;; 122 ;;
118 *) 123 *)
119 crontab="$1" 124 crontab=$1
120 shift 125 shift
121 [[ -n "$1" ]] && perms="$@" 126 [[ -n $1 ]] && perms="$@"
122 ;; 127 ;;
123 esac 128 esac
124 fi 129 fi
125 130
126 exeopts ${perms} 131 exeopts ${perms}
135 dosym ${crontab##*/} /usr/bin/crontab || \ 140 dosym ${crontab##*/} /usr/bin/crontab || \
136 die "failed to create /usr/bin/crontab symlink" 141 die "failed to create /usr/bin/crontab symlink"
137 fi 142 fi
138} 143}
139 144
140# dopamd [ file ] [ new file ] 145# @FUNCTION: cron_pkg_postinst
141# 146# @DESCRIPTION:
142# Install pam auth config file in /etc/pam.d 147# Outputs a message about system crontabs
143# 148# daemons that have a true system crontab set CRON_SYSTEM_CRONTAB="yes"
144# NOTE: this would make much more sense as a portage script (eg. doenvd)
145#
146# The first argument, 'file' is required. Install as 'new file', if
147# specified.
148
149dopamd() {
150 local pamd="${1}" newpamd="${2:-${1}}"
151 [[ -z "${1}" ]] && die "dopamd requires at least one argument."
152
153 insinto /etc/pam.d
154 # these are the default doins options, but be explicit just in case
155 insopts -m 0644 -o root -g root
156 newins ${pamd} ${newpamd} || die "failed to install ${newpamd}"
157}
158
159cron-pkg_postinst() { 149cron_pkg_postinst() {
160 echo 150 echo
161 # vixie is the only daemon that has a true system crontab 151 # daemons that have a true system crontab set CRON_SYSTEM_CRONTAB="yes"
162 if [[ "${PN}" != "vixie-cron" ]] ; then 152 if [ "${CRON_SYSTEM_CRONTAB:-no}" != "yes" ] ; then
163 einfo "To activate /etc/cron.{hourly|daily|weekly|monthly} please run:" 153 einfo "To activate /etc/cron.{hourly|daily|weekly|monthly} please run:"
164 einfo " crontab /etc/crontab" 154 einfo " crontab /etc/crontab"
165 einfo 155 einfo
166 einfo "!!! That will replace root's current crontab !!!" 156 einfo "!!! That will replace root's current crontab !!!"
167 einfo 157 einfo
168 fi 158 fi
169 159
170 einfo "You may wish to read the Gentoo Linux Cron Guide, which can be" 160 einfo "You may wish to read the Gentoo Linux Cron Guide, which can be"
171 einfo "found online at:" 161 einfo "found online at:"
172 einfo " http://www.gentoo.org/doc/en/cron-guide.xml" 162 einfo " http://www.gentoo.org/doc/en/cron-guide.xml"
173 echo 163 echo
174} 164}

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.20