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

Contents of /eclass/cron.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Sat Jan 15 12:37:53 2005 UTC (14 years, 3 months ago) by ka0ttic
Branch: MAIN
Initial commit.

1 # Copyright 1999-2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
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 ECLASS="cron"
20 INHERITED="$INHERITED $ECLASS"
21 EXPORT_FUNCTIONS pkg_postinst
22
23 SLOT="0"
24
25 DEPEND="${DEPEND}
26 virtual/libc
27 >=sys-apps/sed-4.0.5"
28
29 RDEPEND="${RDEPEND}
30 !virtual/cron
31 virtual/mta
32 >=sys-apps/cronbase-0.2.1-r3"
33
34 PROVIDE="virtual/cron"
35
36 # docrondir [ dir ] [ perms ]
37 #
38 # 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
51 if [[ -n "$1" ]] ; then
52 case "$1" in
53 */*)
54 dir="$1"
55 shift
56 [[ -n "$1" ]] && perms="$@"
57 ;;
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 # docron [ exe ] [ perms ]
72 #
73 # Install cron executable
74 #
75 # Both arguments are optional.
76 #
77 # ex: docron -m 0700 -o root -g root ('exe' defaults to "cron")
78 # docron crond -m 0110
79
80 docron() {
81 local cron="cron" perms="-m 0750 -o root -g root"
82
83 if [[ -n "$1" ]] ; then
84 case "$1" in
85 -*)
86 perms="$@"
87 ;;
88 *)
89 cron="$1"
90 shift
91 [[ -n "$1" ]] && perms="$@"
92 ;;
93 esac
94 fi
95
96 exeopts ${perms}
97 exeinto /usr/sbin
98 doexe ${cron} || die "failed to install ${cron}"
99
100 # reset perms to default
101 exeopts -m0755
102 }
103
104 # docrontab [ exe ] [ perms ]
105 #
106 # Install crontab executable
107 #
108 # Uses same semantics as docron.
109
110 docrontab() {
111 local crontab="crontab" perms="-m 4750 -o root -g cron"
112
113 if [[ -n "$1" ]] ; then
114 case "$1" in
115 -*)
116 perms="$@"
117 ;;
118 *)
119 crontab="$1"
120 shift
121 [[ -n "$1" ]] && perms="$@"
122 ;;
123 esac
124 fi
125
126 exeopts ${perms}
127 exeinto /usr/bin
128 doexe ${crontab} || die "failed to install ${crontab}"
129
130 # reset perms to default
131 exeopts -m0755
132
133 # users expect /usr/bin/crontab to exist...
134 if [[ "${crontab##*/}" != "crontab" ]] ; then
135 dosym ${crontab##*/} /usr/bin/crontab || \
136 die "failed to create /usr/bin/crontab symlink"
137 fi
138 }
139
140 # dopamd [ file ] [ new file ]
141 #
142 # Install pam auth config file in /etc/pam.d
143 #
144 # NOTE: this would make much more sense as a portage script (eg. doenvd)
145 #
146 # The first argument, 'file' is required. Install as 'new file', if
147 # specified.
148
149 dopamd() {
150 local pamd="${1}" newpamd="${2:-${1}}"
151 [[ -z "${1}" ]] && die "dopamd requires at least one argument."
152
153 insinto /etc/pam.d
154 # these are the default doins options, but be explicit just in case
155 insopts -m 0644 -o root -g root
156 newins ${pamd} ${newpamd} || die "failed to install ${newpamd}"
157 }
158
159 cron-pkg_postinst() {
160 echo
161 # vixie is the only daemon that has a true system crontab
162 if [[ "${PN}" != "vixie-cron" ]] ; then
163 einfo "To activate /etc/cron.{hourly|daily|weekly|monthly} please run:"
164 einfo " crontab /etc/crontab"
165 einfo
166 einfo "!!! That will replace root's current crontab !!!"
167 einfo
168 fi
169
170 einfo "You may wish to read the Gentoo Linux Cron Guide, which can be"
171 einfo "found online at:"
172 einfo " http://www.gentoo.org/doc/en/cron-guide.xml"
173 echo
174 }

  ViewVC Help
Powered by ViewVC 1.1.20