areguera / rpms / mailman

Forked from rpms/mailman 5 years ago
Clone
Blob Blame History Raw
diff --git a/cron/bumpdigests b/cron/bumpdigests
index 57cc45e..4002731 100755
--- a/cron/bumpdigests
+++ b/cron/bumpdigests
@@ -1,4 +1,4 @@
-#! @PYTHON@
+#! @PYTHON@ -S
 #
 # Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc.
 #
diff --git a/cron/checkdbs b/cron/checkdbs
index e776f15..c4d8179 100755
--- a/cron/checkdbs
+++ b/cron/checkdbs
@@ -1,4 +1,4 @@
-#! @PYTHON@
+#! @PYTHON@ -S
 #
 # Copyright (C) 1998-2011 by the Free Software Foundation, Inc.
 #
diff --git a/cron/crontab.in.in b/cron/crontab.in.in
index 540dfc1..45c5022 100644
--- a/cron/crontab.in.in
+++ b/cron/crontab.in.in
@@ -1,27 +1,50 @@
+#
+# -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- 
+# ------------------  EDIT THE CORRECT FILE  -------------------------
+# 
+# This file is copied to /etc/cron.d/mailman from
+# @prefix@/cron/crontab.in when the mailman service is started via its
+# init.d script and the file /etc/cron.d/mailman is removed when the
+# service is stopped.  Therefore any edits made directly to
+# /etc/cron.d/mailman will be lost anytime the mailman service
+# restarts.
+#
+# To make changes edit the master copy @prefix@/cron/crontab.in and then
+# restart the service to pick up the changes (/sbin/service mailman restart).
+#
+# The reason this is done this way is because the mailman cron jobs
+# should only be invoked if the mailman service is enabled and not
+# just as a consequence of installing the rpm as was the case
+# previously. The file /etc/cron.d/mailman cannot simply be linked to
+# the master copy in @prefix@/cron because for security reasons cron
+# will not process crontab files that are links or writeable by
+# anybody else but root, thus the file must be copied into /etc/cron.d
+# with the right ownership and permissions.
+#
 # At 8AM every day, mail reminders to admins as to pending requests.
 # They are less likely to ignore these reminders if they're mailed
 # early in the morning, but of course, this is local time... ;)
-0 8 * * * @PYTHON@ -S @prefix@/cron/checkdbs
+0 8 * * * @MAILMAN_USER@ @prefix@/cron/checkdbs
 #
 # At 9AM, send notifications to disabled members that are due to be
 # reminded to re-enable their accounts.
-0 9 * * * @PYTHON@ -S @prefix@/cron/disabled
+0 9 * * * @MAILMAN_USER@ @prefix@/cron/disabled
 #
 # Noon, mail digests for lists that do periodic as well as threshhold delivery.
-0 12 * * * @PYTHON@ -S @prefix@/cron/senddigests
+0 12 * * * @MAILMAN_USER@ @prefix@/cron/senddigests
 #
 # 5 AM on the first of each month, mail out password reminders.
-0 5 1 * * @PYTHON@ -S @prefix@/cron/mailpasswds
+0 5 1 * * @MAILMAN_USER@ @prefix@/cron/mailpasswds
 #
 # Every 5 mins, try to gate news to mail.  You can comment this one out
 # if you don't want to allow gating, or don't have any going on right now,
 # or want to exclusively use a callback strategy instead of polling.
-0,5,10,15,20,25,30,35,40,45,50,55 * * * * @PYTHON@ -S @prefix@/cron/gate_news
+0,5,10,15,20,25,30,35,40,45,50,55 * * * * @MAILMAN_USER@ @prefix@/cron/gate_news
 #
 # At 3:27am every night, regenerate the gzip'd archive file.  Only
 # turn this on if the internal archiver is used and
 # GZIP_ARCHIVE_TXT_FILES is false in mm_cfg.py
-27 3 * * * @PYTHON@ -S @prefix@/cron/nightly_gzip
+27 3 * * * @MAILMAN_USER@ @prefix@/cron/nightly_gzip
 #
 # At 4:30AM daily, cull old entries from the 'bad' and 'shunt' queues.
-30 4 * * * @PYTHON@ -S @prefix@/cron/cull_bad_shunt
+30 4 * * * @MAILMAN_USER@ @prefix@/cron/cull_bad_shunt
diff --git a/cron/disabled b/cron/disabled
index ac62582..971563d 100755
--- a/cron/disabled
+++ b/cron/disabled
@@ -1,4 +1,4 @@
-#! @PYTHON@
+#! @PYTHON@ -S
 #
 # Copyright (C) 2001-2007 by the Free Software Foundation, Inc.
 #
diff --git a/cron/gate_news b/cron/gate_news
index c66c09e..247c834 100755
--- a/cron/gate_news
+++ b/cron/gate_news
@@ -1,4 +1,4 @@
-#! @PYTHON@
+#! @PYTHON@ -S
 #
 # Copyright (C) 1998-2011 by the Free Software Foundation, Inc.
 #
diff --git a/cron/mailpasswds b/cron/mailpasswds
index 5745265..4d0cd3a 100755
--- a/cron/mailpasswds
+++ b/cron/mailpasswds
@@ -1,4 +1,4 @@
-#! @PYTHON@
+#! @PYTHON@ -S
 #
 # Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
 #
diff --git a/cron/nightly_gzip b/cron/nightly_gzip
index 0a0f4e3..7dba3b1 100755
--- a/cron/nightly_gzip
+++ b/cron/nightly_gzip
@@ -1,4 +1,4 @@
-#! @PYTHON@
+#! @PYTHON@ -S
 # 
 # Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc.
 #
diff --git a/cron/senddigests b/cron/senddigests
index edf27a2..c64adc1 100755
--- a/cron/senddigests
+++ b/cron/senddigests
@@ -1,4 +1,4 @@
-#! @PYTHON@
+#! @PYTHON@ -S
 #
 # Copyright (C) 1998-2007 by the Free Software Foundation, Inc.
 #
diff --git a/misc/mailman.in b/misc/mailman.in
index bce344c..7129f14 100644
--- a/misc/mailman.in
+++ b/misc/mailman.in
@@ -24,18 +24,48 @@
 # On Debian, type "update-rc.d mailman defaults"
 # On RedHat, and derivatives, install with "chkconfig --add mailman"
 #
-# chkconfig: 2345 98 12
+# chkconfig: - 98 12
 # description: Mailman is the GNU Mailing List Manager, a program that \
 #              manages electronic mail discussion groups.  For more \
 #              on GNU Mailman see http://www.list.org
 # processname: mailmanctl
 # config: @prefix@/Mailman/mm_cfg.py
-# pidfile: @prefix@/data/master-qrunner.pid
+# pidfile: @PID_DIR@/master-qrunner.pid
 
 PYTHON=@PYTHON@
 MAILMANHOME=@prefix@
 MAILMANCTL=$MAILMANHOME/bin/mailmanctl
 
+# We used to install the mailman cron jobs when the mailman rpm was
+# installed, irrespective of whether mailman was actually being
+# run. Although the cron jobs didn't create any problems if someone
+# wasn't running mailman some users complained about the cron log file
+# filling up, resource usage, and power consumption since systems
+# wouldn't really idle. It really only makes sense to run the mailman
+# cron jobs if the mailman service is turned on and not just merely
+# having the rpm installed. This init.d script is an obvious place to
+# install or remove the cron jobs based on the service being enabled
+# or not.
+
+SRC_CRON_SCRIPT=$MAILMANHOME/cron/crontab.in
+DST_CRON_SCRIPT=/etc/cron.d/mailman
+
+function InstallCron()
+{
+    install -m644 -o root -g root $SRC_CRON_SCRIPT $DST_CRON_SCRIPT
+}
+
+function RemoveCron()
+{
+cat > $DST_CRON_SCRIPT <<EOF
+# DO NOT EDIT THIS FILE!
+#
+# Contents of this file managed by /etc/init.d/mailman
+# Master copy is @prefix@/cron/crontab.in
+# Consult that file for documentation
+EOF
+}
+
 # Source function library.
 . /etc/rc.d/init.d/functions
 
@@ -47,7 +77,11 @@ function start()
     echo -n $"Starting $prog: "
     daemon $PYTHON $MAILMANCTL -s -q start
     RETVAL=$?
-    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
+    if [ $RETVAL -eq 0 ]
+    then
+	touch /var/lock/subsys/$prog
+	InstallCron
+    fi
     echo
     return $RETVAL
 }
@@ -57,7 +91,11 @@ function stop()
     echo -n $"Shutting down $prog: "
     daemon $PYTHON $MAILMANCTL -q stop
     RETVAL=$?
-    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
+    if [ $RETVAL -eq 0 ]
+    then
+	rm -f /var/lock/subsys/$prog
+	RemoveCron
+    fi
     echo
     return $RETVAL
 }
@@ -101,5 +139,9 @@ case "$1" in
     RETVAL=$?
     ;;
 
+*)
+    echo $"Usage: $prog {start|stop|restart|condrestart|status}"
+    ;;
+
 esac
 exit $RETVAL