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

Contents of /eclass/cron.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (show annotations) (download)
Mon Aug 22 04:46:31 2011 UTC (3 years, 3 months ago) by vapier
Branch: MAIN
Changes since 1.14: +2 -2 lines
fix random bugs in eclass documentation, and convert to new @AUTHOR tag

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

  ViewVC Help
Powered by ViewVC 1.1.20