3 # This command updates the spamassassin configuration; tests the new
4 # configuration; then moves the updated configuration in place
12 if [ "$HOSTNAME" = "rietz" ] || [ "$HOSTNAME" = "busoni" ]; then
13 BASEDIR="/org/bugs.debian.org"
14 USERCONF="bugs/user_prefs";
15 elif [ "$HOSTNAME" = "liszt" ]; then
16 BASEDIR="/var/list/.etc";
17 USERCONF="lists/user_prefs";
19 echo "Unknown hostname '$HOSTNAME'";
23 SACONFIG="$BASEDIR/spamassassin_config";
24 BAKDIR="$BASEDIR/spamassassin_config_bak";
26 # because alioth continuously fails, make sure that svn info will
27 # succeed first before cluttering the log. Ideally we would report
28 # this error, but it happens far too frequently, so we bail out here.
29 if ! svn info $(svn info $SACONFIG|awk '/^URL:/{print $2}') >/dev/null 2>&1; then
33 # figure out if there's an update to be made
34 ORIGREV=$(svn info $SACONFIG |awk '/^Revision:/{print $2}')
35 NEWREV=$(svn info $(svn info $SACONFIG|awk '/^URL:/{print $2}')|awk '/^Revision:/{print $2}')
37 # no changes, bug out.
38 if [ "0$ORIGREV" -ge "0$NEWREV" ]; then
42 if [ -e "$SACONFIG/.update_spamassassin" ] && kill -0 $(cat "$SACONFIG/.update_spamassassin") >/dev/null 2>&1; then
43 echo "Another update_spamassassin appears to be running"
46 echo $$ > "$SACONFIG/.update_spamassassin";
49 function remove_pidfile(){
50 rm "$SACONFIG/.update_spamassassin";
53 trap remove_pidfile ERR;
56 function report_failure(){
57 # Hrm; a previous update failed; don't report again until the file
58 # is removed or it's more than a day old
59 if [ -e "$SACONFIG/failed_update" ] &&
60 [ $(($(date +%s) - $(stat -c '%Y' "$SACONFIG/failed_update"))) -lt 86400 ]; then
64 echo "$FAILUREMESSAGE" > "$SACONFIG/failed_update"
65 echo "$FAILUREMESSAGE";
68 update_spamassassin will only report this error once a day, and
69 updates will not occur until this is fixed.
71 Please fix the problem and then remove
72 $SACONFIG/failed_update
78 cp -ar $SACONFIG $TMPDIR/.
80 cd $TMPDIR/spamassassin_config;
81 svn update -q --non-interactive;
82 if svn status |grep -q '^C'; then
83 FAILUREMESSAGE=$'The following conflicts were found\n\n'
84 FAILUREMESSAGE="$FAILUREMESSAGE$(svn status|grep ^C)";
89 if ! spamassassin -p $TMPDIR/spamassassin_config/$USERCONF --lint > $TMPDIR/sa_lint 2>&1; then
90 FAILUREMESSAGE="$(echo -e 'spamassassin -p $TMPDIR/spamassassin_config/$USERCONF --lint\nfailed with\n'| cat - $TMPDIR/sa_lint)";
93 mv "$SACONFIG" "$BAKDIR/spamassassin_config_r$ORIGREV"
94 mv "$TMPDIR/spamassassin_config" "$SACONFIG"
99 if [ "$HOSTNAME" == "rietz" ]; then
100 touch /home/debbugs/.spamassassin/user_prefs
101 elif [ "$HOSTNAME" == "liszt" ]; then
105 echo "Unknown hostname '$HOSTNAME'";