areguera / rpms / mailman

Forked from rpms/mailman 4 years ago
Clone

Blame SOURCES/mailman-2.1.11-cron.patch

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