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

Contents of /eclass/cron.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Wed Nov 30 09:59:18 2005 UTC (12 years, 11 months ago) by chriswhite
Changes since 1.1: +17 -41 lines
*** empty log message ***

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

  ViewVC Help
Powered by ViewVC 1.1.20