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

Contents of /eclass/cron.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (hide annotations) (download)
Thu Jun 26 10:51:41 2008 UTC (10 years, 2 months ago) by bangert
Branch: MAIN
Changes since 1.11: +21 -9 lines
apply manpage doc by mren (bug #209618)

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

  ViewVC Help
Powered by ViewVC 1.1.20