3 # This command updates the spamassassin configuration; tests the new
4 # configuration; then moves the updated configuration in place
12 if [ "$HOSTNAME" = "buxtehude" ]; then
13 BASEDIR="/org/bugs.debian.org"
14 USERCONF="bugs/user_prefs";
15 elif [ "$HOSTNAME" = "bendel" ]; then
16 BASEDIR="/var/list/.etc";
17 USERCONF="lists/user_prefs";
19 echo "Unknown hostname '$HOSTNAME'";
23 SACONFIG="$BASEDIR/spamassassin_config";
25 if [ -e "$SACONFIG/.update_spamassassin" ] && kill -0 $(cat "$SACONFIG/.update_spamassassin") >/dev/null 2>&1; then
26 echo "Another update_spamassassin appears to be running"
29 echo $$ > "$SACONFIG/.update_spamassassin";
33 rm -f "$SACONFIG/.update_spamassassin"
38 git fetch --all >/dev/null || exit 0;
39 REMOTE_BRANCH="$(git status --porcelain --branch|grep '^##'|sed 's/.*\.\.\.//;s/ \[.*$//;')";
40 CURRENT_HEAD="$(git rev-parse HEAD)"
41 REMOTE_BRANCH_HEAD="$(git rev-parse "$REMOTE_BRANCH")"
43 ## there aren't any updates, stop here.
44 if [ "$REMOTE_BRANCH_HEAD" = "$CURRENT_HEAD" ]; then
48 trap remove_pidfile 0;
52 # Hrm; a previous update failed; don't report again until the file
53 # is removed or it's more than a day old
54 if [ -e "$SACONFIG/failed_update" ] &&
55 [ $(($(date +%s) - $(stat -c '%Y' "$SACONFIG/failed_update"))) -lt 86400 ]; then
60 echo "$FAILUREMESSAGE" > "$SACONFIG/failed_update"
61 echo "$FAILUREMESSAGE";
64 update_spamassassin will only report this error once a day, and
65 updates will not occur until this is fixed.
67 Please fix the problem and then remove
68 $SACONFIG/failed_update
75 cp -ar $SACONFIG $TMPDIR/.;
77 cd $TMPDIR/spamassassin_config;
78 if ! git merge --quiet --ff-only $REMOTE_BRANCH --; then
79 FAILUREMESSAGE="The update from $REMOTE_BRANCH to $REMOTE_BRANCH_HEAD\nis not a fast-forward\n\n"
83 if ! spamassassin -p $TMPDIR/spamassassin_config/$USERCONF --lint > $TMPDIR/sa_lint 2>&1; then
84 FAILUREMESSAGE="$(echo -e 'spamassassin -p $TMPDIR/spamassassin_config/$USERCONF --lint\nfailed with\n'| cat - $TMPDIR/sa_lint)";
88 git merge --ff-only --quiet $REMOTE_BRANCH --;
93 if [ "$HOSTNAME" = "buxtehude" ]; then
94 touch /home/debbugs/.spamassassin/user_prefs
95 elif [ "$HOSTNAME" = "bendel" ]; then
99 echo "Unknown hostname '$HOSTNAME'";