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

Contents of /eclass/cron.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (show annotations) (download)
Wed Apr 20 17:49:19 2011 UTC (8 years ago) by ulm
Branch: MAIN
Changes since 1.12: +7 -5 lines
Don't PROVIDE virtual/cron, bug 360109.
Replace blocker against virtual/cron by explicit blockers against packages.

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

  ViewVC Help
Powered by ViewVC 1.1.20