3 # This command updates the spamassassin configuration; tests the new
4 # configuration; then moves the updated configuration in place
14 if [ "$HOSTNAME" = "buxtehude" ]; then
15 BASEDIR="/org/bugs.debian.org"
16 USERCONF="bugs/user_prefs";
17 elif [ "$HOSTNAME" = "bendel" ]; then
18 BASEDIR="/var/list/.etc";
19 USERCONF="lists/user_prefs";
21 echo "Unknown hostname '$HOSTNAME'";
25 SACONFIG="$BASEDIR/spamassassin_config";
26 BAKDIR="$BASEDIR/spamassassin_config_bak";
28 # because alioth continuously fails, make sure that svn info will
29 # succeed first before cluttering the log. Ideally we would report
30 # this error, but it happens far too frequently, so we bail out here.
31 if ! svn info $(svn info $SACONFIG|awk '/^URL:/{print $2}') >/dev/null 2>&1; then
35 # figure out if there's an update to be made
36 ORIGREV=$(svn info $SACONFIG |awk '/^Revision:/{print $2}')
37 NEWREV=$(svn info $(svn info $SACONFIG|awk '/^URL:/{print $2}')|awk '/^Revision:/{print $2}')
39 # no changes, bug out.
40 if [ "0$ORIGREV" -ge "0$NEWREV" ]; then
44 if [ -e "$SACONFIG/.update_spamassassin" ] && kill -0 $(cat "$SACONFIG/.update_spamassassin") >/dev/null 2>&1; then
45 echo "Another update_spamassassin appears to be running"
48 echo $$ > "$SACONFIG/.update_spamassassin";
52 rm "$SACONFIG/.update_spamassassin";
55 trap remove_pidfile 0;
59 # Hrm; a previous update failed; don't report again until the file
60 # is removed or it's more than a day old
61 if [ -e "$SACONFIG/failed_update" ] &&
62 [ $(($(date +%s) - $(stat -c '%Y' "$SACONFIG/failed_update"))) -lt 86400 ]; then
66 echo "$FAILUREMESSAGE" > "$SACONFIG/failed_update"
67 echo "$FAILUREMESSAGE";
70 update_spamassassin will only report this error once a day, and
71 updates will not occur until this is fixed.
73 Please fix the problem and then remove
74 $SACONFIG/failed_update
80 cp -ar $SACONFIG $TMPDIR/.
82 cd $TMPDIR/spamassassin_config;
83 svn update -q --non-interactive;
84 if svn status |grep -q '^C'; then
85 FAILUREMESSAGE=$'The following conflicts were found\n\n'
86 FAILUREMESSAGE="$FAILUREMESSAGE$(svn status|grep ^C)";
91 if ! spamassassin -p $TMPDIR/spamassassin_config/$USERCONF --lint > $TMPDIR/sa_lint 2>&1; then
92 FAILUREMESSAGE="$(echo -e 'spamassassin -p $TMPDIR/spamassassin_config/$USERCONF --lint\nfailed with\n'| cat - $TMPDIR/sa_lint)";
95 mv "$SACONFIG" "$BAKDIR/spamassassin_config_r$ORIGREV"
96 mv "$TMPDIR/spamassassin_config" "$SACONFIG"
101 if [ "$HOSTNAME" = "buxtehude" ]; then
102 touch /home/debbugs/.spamassassin/user_prefs
103 elif [ "$HOSTNAME" = "bendel" ]; then
107 echo "Unknown hostname '$HOSTNAME'";