From:
[email protected]
Hello
I have modified it slightly.
Moved the diff check to mailit (that now has been renamed to onexit).
This is in order to mail even if errors occur.
I also moved the $MAILMSGDIR/diff to $MAILONMSGS/changes. The
$MAILONMSGS is a new directory for this kind of things and is
at /etc/cron-apt/mailonmsgs. I may implement it more later.
Regards,
// Ola
On Sun, Aug 08, 2004 at 12:47:58PM +0200, Marc Haber wrote:
Package: cron-apt
Version: 0.0.24
Severity: wishlist
Tags: patch
Please consider the attached patch that introduces a MAILON="changes"
option which will send an e-mail if apt-get's output has actually
changed. This allows cron-apt to be invoked often without swamping the
admin with e-mails in the case that new packages are not automatically installed.
The patch also includes hot fixes to some of the newly found bugs I
have recently reported, so you probably can't take it verbatim. The
output routine is probably wrong since I have not yet understood all
of your recent changes. I am submitting the patch for your early review.
It needs the options of action.d/0-update to be set to -qq instead of
-q until #264175 has been sorted out. I have
/etc/cron-apt/mailmsg.d/diff saying "This cron-apt run has generated different output than the last invocation. Incuding the output diff."
I have a /etc/cron-apt/config-hourly with MAILON="changes" invoked
hourly, while the normal daily cronjob still has MAILON="upgrade".
That way, I am not swamped by hourly update requests, but I get update requests _once_ immediately after the packages have appeared in the
archive, and from there on on a daily basis.
Please let me know what you think.
Greetings
Marc
-- System Information:
Debian Release: 3.1
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.7-janeway
Locale: LANG=C, LC_CTYPE=de_DE
Versions of packages cron-apt depends on:
ii apt 0.5.27 Advanced front-end for dpkg
ii bash 3.0-4 The GNU Bourne Again SHell
ii mailx 1:8.1.2-0.20040524cvs-1 A simple mail user agent
-- no debconf information
--- cron-apt.orig 2004-08-08 12:03:31.000000000 +0200
+++ cron-apt 2004-08-08 12:39:17.000000000 +0200
@@ -73,6 +73,9 @@
ACTIONLOG=/var/log/cron-apt/actionlog
INITLOG=/var/log/cron-apt/initlog
LOG=/var/log/cron-apt/log
+REF=/var/log/cron-apt/reflog
+OLDREF=/var/log/cron-apt/reflog.old
+DIFF=/var/log/cron-apt/reflog.diff
MAILTO=root
# error, always
MAILON=error
@@ -123,10 +126,10 @@
rm $RUNLOG
fi
if [ -f "$RUNERROR" ] ; then
- rm $RUNLOG
+ rm $RUNERROR
fi
if [ -f "$RUNMAIL" ] ; then
- rm $RUNLOG
+ rm $RUNMAIL
fi
if [ -f $MAIL ] ; then
SUBJECT="CRON-APT completed on $(uname -n)"
@@ -156,20 +159,20 @@
OPTACTIONCAT="$6"
STDOUT="$7"
touch $FILE
- if [ -f $OPTCAT ] ; then
+ if [ -n "$OPTCAT" ] && [ -f $OPTCAT ] ; then
if [ -n "$STDOUT" ] ; then
cat $OPTCAT
fi
cat $OPTCAT >> $FILE
fi
- if [ -f $OPTRUNCAT ] ; then
+ if [ -n "$OPTRUNCAT" ] && [ -f $OPTRUNCAT ] ; then
if [ -n "$STDOUT" ] ; then
cat $OPTRUNCAT
fi
cat $OPTRUNCAT >> $FILE
rm -f $OPTRUNCAT
fi
- if [ -f $OPTACTIONCAT ] ; then
+ if [ -n "$OPTACTIONCAT" ] && [ -f $OPTACTIONCAT ] ; then
if [ -n "$STDOUT" ] ; then
cat $OPTACTIONCAT
fi
@@ -230,6 +233,9 @@
############################### script ########################################
# Always run mailit before exit.
+touch $REF
+mv $REF $OLDREF
+touch $REF
for ACTIONF in $(ls $ACTIONDIR) ; do
if echo "$ACTIONF" | grep "~" > /dev/null 2>&1 ; then
# Temporary file, skipping.
@@ -288,6 +294,7 @@
createloginfo $ACTIONF
fi
fi
+ tail -n +2 $TEMP >> $REF
done
exit
})
@@ -298,4 +305,9 @@
fi
done
+if [ "$MAILON" = "changes" ] && ! diff -u $OLDREF $REF > $DIFF; then
+ createdivinfo $MAIL "" $DIFF $MAILMSGDIR/diff "" ""
+fi
+rm -f $DIFF
+
mailit
--
--------------------- Ola Lundqvist ---------------------------
/
[email protected] Annebergsslingan 37 \
|
[email protected] 654 65 KARLSTAD |
| +46 (0)54-10 14 30 +46 (0)70-332 1551 |
|
http://www.opal.dhs.org UIN/icq: 4912500 |
\ gpg/f.p.: 7090 A92B 18FE 7994 0C36 4FE4 18A1 B1CF 0FE5 3DD9 /
---------------------------------------------------------------
--
To UNSUBSCRIBE, email to
[email protected]
with a subject of "unsubscribe". Trouble? Contact
[email protected]
--- SoupGate-Win32 v1.05
* Origin: you cannot sedate... all the things you hate (1:229/2)