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

Contents of /eclass/cron.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations) (download)
Mon Jul 11 15:08:06 2005 UTC (13 years, 9 months ago) by swegener
Branch: MAIN
Changes since 1.7: +3 -5 lines
QA: Apply whitespace checks from repoman to eclasses.

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

  ViewVC Help
Powered by ViewVC 1.1.20