/[smecontribs]/rpms/mailman/contribs9/mailman-crontab-edit
ViewVC logotype

Contents of /rpms/mailman/contribs9/mailman-crontab-edit

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Fri Aug 21 17:30:01 2015 UTC (8 years, 8 months ago) by stephdl
Branch: MAIN
CVS Tags: mailman-2_1_12-103_el6_sme, mailman-2_1_12-100_el6_sme, mailman-2_1_12-104_el6_sme, mailman-2_1_12-25_el6_sme_sme, mailman-2_1_12-102_el6_sme, mailman-2_1_12-101_el6_sme, HEAD
Fri Aug 21 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 2.1.12
2.1.12-25.sme.sme - Initial release to contribs9

1 #!/usr/bin/python
2
3 # This script inserts the mailman user name into the crontab entries after
4 # the 5 time/date fields so that it can be installed under /etc/cron.d
5 #
6 # usage: mailman-crontab-edit [-s src_file] [-u mailman_user] [-d dst_file]
7 # src_file defaults to stdin
8 # mailman_user defaults to mailman
9 # dst_file defaults to stdout
10
11 import sys, re, getopt
12
13 srcFile = None
14 dstFile = None
15 mmUser = None
16
17 opts, args = getopt.getopt(sys.argv[1:], "s:d:u:")
18 for o, a in opts:
19 if o == "-s":
20 srcFile = a
21 if o == "-d":
22 dstFile = a
23 if o == "-u":
24 mmUser = a
25
26 if srcFile:
27 inFD = open(srcFile)
28 else:
29 inFD = sys.stdin
30
31 if dstFile:
32 outFD = open(dstFile, mode='w')
33 else:
34 outFD = sys.stdout
35
36 if not mmUser:
37 mmUser = "mailman"
38
39 comment_re = re.compile(r'^\s*#')
40 time_date_re = re.compile(r'(^\s*(\S+\s+){5,5})')
41
42 for line in inFD:
43 if not comment_re.search(line):
44 match = time_date_re.search(line)
45 if match:
46 line = time_date_re.sub(r'\1 %s ' % mmUser, line)
47 print >>outFD, line,

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed