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

Contents of /eclass/cron.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (hide annotations) (download)
Thu Sep 5 10:44:22 2013 UTC (5 years, 3 months ago) by zx2c4
Branch: MAIN
CVS Tags: HEAD
Changes since 1.15: +2 -3 lines
Per extensive discussion with zmedico about removing the need for package.provided, several packages have been changed, like sudo, to not explicitly require an mta. Cron will follow, leaving mta support optional.

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

  ViewVC Help
Powered by ViewVC 1.1.20