/[smeserver]/rpms/spamassassin/sme10/sa-update.cronscript
ViewVC logotype

Contents of /rpms/spamassassin/sme10/sa-update.cronscript

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


Revision 1.1 - (show annotations) (download)
Fri Nov 27 15:26:30 2020 UTC (4 years ago) by jpp
Branch: MAIN
CVS Tags: spamassassin-4_0_0-1_el7_sme, spamassassin-3_4_5-1_el7_sme, spamassassin-3_4_4-7_el7_sme, spamassassin-3_4_4-8_el7_sme, spamassassin-4_0_0-2_el7_sme, spamassassin-3_4_6-1_el7_sme, spamassassin-4_0_1-2_el7_sme, spamassassin-4_0_1-1_el7_sme, spamassassin-4_0_1-5_el7_sme, spamassassin-4_0_1-3_el7_sme, HEAD
*** empty log message ***

1 #!/bin/bash
2 # *** DO NOT MODIFY THIS FILE ***
3 #
4 # /etc/mail/spamassassin/channel.d/*.conf
5 # Place files here to add custom channels.
6 #
7
8 # Proceed with sa-update if spam daemon is running or forced in /etc/sysconfig/sa-update
9 unset SAUPDATE OPTIONS DEBUG NOTIFY_UPD
10 [ -f /etc/sysconfig/sa-update ] && . /etc/sysconfig/sa-update
11 [ "$SAUPDATE" = "no" ] && exit 0
12 for daemon in mimedefang spamd amavisd spampd; do
13 /usr/bin/pgrep -f $daemon >& /dev/null
14 [ $? -eq 0 ] && SAUPDATE=yes
15 done
16
17 # Skip sa-update if daemon not detected
18 [ -z "$SAUPDATE" ] && exit 0
19
20 # sa-update must create keyring
21 if [ ! -d /etc/mail/spamassassin/sa-update-keys ]; then
22 sa-update
23 fi
24
25 # Initialize Channels and Keys
26 CHANNELLIST=""
27 KEYLIST=""
28 # Process each channel defined in /etc/mail/spamassassin/channel.d/
29 for file in /etc/mail/spamassassin/channel.d/*.conf; do
30 [ ! -f "$file" ] && continue
31 # Validate config file
32 PREFIXES="CHANNELURL KEYID BEGIN"
33 for prefix in $PREFIXES; do
34 if ! grep -q "$prefix" $file; then
35 echo "ERROR: $file missing $prefix"
36 exit 255
37 fi
38 done
39 . "$file"
40 #echo "CHANNELURL=$CHANNELURL"
41 #echo "KEYID=$KEYID"
42 CHANNELLIST="$CHANNELLIST $CHANNELURL"
43 KEYLIST="$KEYLIST $KEYID"
44 sa-update --import "$file"
45 done
46
47 # Sleep random amount of time before proceeding to avoid overwhelming the servers
48 sleep $(expr $RANDOM % 7200)
49
50 unset arglist
51 # Run sa-update on each channel, restart spam daemon if success
52 for channel in $CHANNELLIST; do
53 arglist="$arglist --channel $channel"
54 done
55 for keyid in $KEYLIST; do
56 arglist="$arglist --gpgkey $keyid"
57 done
58 /usr/bin/sa-update $OPTIONS $arglist
59 status=$?
60 now=`date +"%d-%b-%Y %T"`
61 # cron runs this script tee /var/log/sa-update.log
62 # We want to always write to the log, but only send mail
63 # as configured.
64 if [ $status -eq 0 ]; then
65 if [ -n "$DEBUG" -o -n "$NOTIFY_UPD" ]; then
66 echo "$now: SpamAssassin: Update processed successfully"
67 else
68 echo "$now: SpamAssassin: Update processed successfully" >>/var/log/sa-update.log
69 fi
70 if [ -f /usr/bin/systemctl ]; then
71 systemctl condrestart spamassassin.service >& /dev/null
72 [ -f /usr/lib/systemd/system/amavisd.service ] && systemctl condrestart amavisd.service >& /dev/null
73 systemctl --quiet is-active mimedefang.service; [ $? -eq 0 ] && systemctl reload mimedefang.service >& /dev/null
74 [ -f /usr/lib/systemd/system/spampd.service ] && systemctl condrestart spampd.service >& /dev/null
75 else
76 service spamassassin condrestart >& /dev/null
77 [ -f /etc/rc.d/init.d/amavisd ] && service amavisd-new condrestart >& /dev/null
78 [ -f /etc/rc.d/init.d/mimedefang ] && service mimedefang condrestart >& /dev/null
79 [ -f /etc/rc.d/init.d/spampd ] && service spampd condrestart >& /dev/null
80 fi
81
82 exit $status
83 fi
84 if [ $status -eq 1 ]; then
85 if [ -n "$DEBUG" ]; then
86 echo "$now: SpamAssassin: No update available"
87 else
88 echo "$now: SpamAssassin: No update available" >>/var/log/sa-update.log
89 fi
90 exit $status
91 fi
92 if [ $status -eq 2 ]; then
93 echo "$now: SpamAssassin: Problem applying update - pre files failed lint check"
94 exit $status
95 fi
96 if [ $status -eq 4 ]; then
97 echo "$now: SpamAssassin: Update available, but download or extract failed"
98 exit $status
99 fi
100
101 echo "$now: SpamAssassin: Unknown error code $status from sa-update"
102 exit $status

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