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

Contents of /eclass/cron.eclass

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20