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

Contents of /eclass/cron.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Wed Jul 6 20:20:03 2005 UTC (13 years, 9 months ago) by agriffis
Branch: MAIN
Changes since 1.5: +1 -2 lines
Remove ECLASS= and INHERITED= which haven't been necessary for a long time now

1 ka0ttic 1.1 # Copyright 1999-2005 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 agriffis 1.6 # $Header: /var/cvsroot/gentoo-x86/eclass/cron.eclass,v 1.5 2005/05/14 16:44:37 ka0ttic Exp $
4 ka0ttic 1.1
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     INHERITED="$INHERITED $ECLASS"
20     EXPORT_FUNCTIONS pkg_postinst
21    
22     SLOT="0"
23    
24     DEPEND="${DEPEND}
25     virtual/libc
26     >=sys-apps/sed-4.0.5"
27    
28     RDEPEND="${RDEPEND}
29     !virtual/cron
30     virtual/mta
31 ciaranm 1.3 >=sys-process/cronbase-0.2.1-r3"
32 ka0ttic 1.1
33     PROVIDE="virtual/cron"
34    
35     # docrondir [ dir ] [ perms ]
36     #
37     # Creates crontab directory
38     #
39     # Both arguments are optional. Everything after 'dir' is considered
40     # the permissions (same format as insopts).
41     #
42     # ex: docrondir /some/dir -m 0770 -o root -g cron
43     # docrondir /some/dir (uses default perms)
44     # docrondir -m0700 (uses default dir)
45    
46     docrondir() {
47     # defaults
48     local perms="-m0750 -o root -g cron" dir="/var/spool/cron/crontabs"
49 ka0ttic 1.4
50 ka0ttic 1.1 if [[ -n "$1" ]] ; then
51     case "$1" in
52     */*)
53     dir="$1"
54     shift
55     [[ -n "$1" ]] && perms="$@"
56     ;;
57     *)
58     perms="$@"
59     ;;
60     esac
61     fi
62    
63     diropts ${perms}
64     keepdir ${dir}
65    
66     # reset perms to default
67     diropts -m0755
68     }
69    
70     # docron [ exe ] [ perms ]
71     #
72     # Install cron executable
73     #
74     # Both arguments are optional.
75     #
76     # ex: docron -m 0700 -o root -g root ('exe' defaults to "cron")
77     # docron crond -m 0110
78    
79     docron() {
80 ka0ttic 1.5 local cron="cron" perms="-m 0750 -o root -g wheel"
81 ka0ttic 1.1
82     if [[ -n "$1" ]] ; then
83     case "$1" in
84     -*)
85     perms="$@"
86     ;;
87     *)
88     cron="$1"
89     shift
90     [[ -n "$1" ]] && perms="$@"
91     ;;
92     esac
93     fi
94    
95     exeopts ${perms}
96     exeinto /usr/sbin
97     doexe ${cron} || die "failed to install ${cron}"
98    
99     # reset perms to default
100     exeopts -m0755
101     }
102    
103     # docrontab [ exe ] [ perms ]
104     #
105     # Install crontab executable
106     #
107     # Uses same semantics as docron.
108    
109     docrontab() {
110     local crontab="crontab" perms="-m 4750 -o root -g cron"
111    
112     if [[ -n "$1" ]] ; then
113     case "$1" in
114     -*)
115     perms="$@"
116     ;;
117     *)
118     crontab="$1"
119     shift
120     [[ -n "$1" ]] && perms="$@"
121     ;;
122     esac
123     fi
124    
125     exeopts ${perms}
126     exeinto /usr/bin
127     doexe ${crontab} || die "failed to install ${crontab}"
128    
129     # reset perms to default
130     exeopts -m0755
131    
132     # users expect /usr/bin/crontab to exist...
133     if [[ "${crontab##*/}" != "crontab" ]] ; then
134     dosym ${crontab##*/} /usr/bin/crontab || \
135     die "failed to create /usr/bin/crontab symlink"
136     fi
137     }
138    
139 ka0ttic 1.4 cron_pkg_postinst() {
140 ka0ttic 1.1 echo
141     # vixie is the only daemon that has a true system crontab
142     if [[ "${PN}" != "vixie-cron" ]] ; then
143     einfo "To activate /etc/cron.{hourly|daily|weekly|monthly} please run:"
144     einfo " crontab /etc/crontab"
145     einfo
146     einfo "!!! That will replace root's current crontab !!!"
147     einfo
148     fi
149 ka0ttic 1.4
150 ka0ttic 1.1 einfo "You may wish to read the Gentoo Linux Cron Guide, which can be"
151     einfo "found online at:"
152     einfo " http://www.gentoo.org/doc/en/cron-guide.xml"
153     echo
154     }

  ViewVC Help
Powered by ViewVC 1.1.20