/[pkg-listmaster]/trunk/spamassassin_config/update_spamassassin
ViewVC logotype

Contents of /trunk/spamassassin_config/update_spamassassin

Parent Directory Parent Directory | Revision Log Revision Log


Revision 151 - (show annotations) (download)
Thu Feb 14 19:13:53 2008 UTC (5 years, 3 months ago) by don
File size: 2576 byte(s)
remove tempdir on failure
1 #!/bin/sh
2
3 # This command updates the spamassassin configuration; tests the new
4 # configuration; then moves the updated configuration in place
5
6 set -e
7
8 SVN=$(which svn)
9
10 TMPDIR=$(mktemp -d);
11
12 if [ "$HOSTNAME" = "rietz" ]; 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";
18 else
19 echo "Unknown hostname '$HOSTNAME'";
20 exit 1;
21 fi;
22
23 SACONFIG="$BASEDIR/spamassassin_config";
24 BAKDIR="$BASEDIR/spamassassin_config_bak";
25
26 # figure out if there's an update to be made
27 ORIGREV=$(svn info $SACONFIG |awk '/^Revision:/{print $2}')
28 NEWREV=$(svn info $(svn info $SACONFIG|awk '/^URL:/{print $2}')|awk '/^Revision:/{print $2}')
29
30 # no changes, bug out.
31 if [ "0$ORIGREV" -ge "0$NEWREV" ]; then
32 exit 0;
33 fi;
34
35 if [ -e "$SACONFIG/.update_spamassassin" ] && kill -0 $(cat "$SACONFIG/.update_spamassassin") >/dev/null 2>&1; then
36 echo "Another update_spamassassin appears to be running"
37 exit 1;
38 else
39 echo $$ > "$SACONFIG/.update_spamassassin";
40 fi;
41
42 function remove_pidfile(){
43 rm "$SACONFIG/.update_spamassassin";
44 }
45
46 trap remove_pidfile ERR;
47
48 FAILUREMESSAGE="";
49 function report_failure(){
50 # Hrm; a previous update failed; don't report again until the file
51 # is removed
52 if [ -e "$SACONFIG/failed_update" ]; then
53 rm -rf "$TMPDIR"
54 exit 0;
55 fi;
56 echo "$FAILUREMESSAGE" >> "$SACONFIG/failed_update"
57 echo "$FAILUREMESSAGE";
58 cat - <<EOF;
59
60 Update_spamassassin will not report any additional errors until this
61 is fixed.
62
63 Please fix the problem and then remove
64 $SACONFIG/failed_update
65 EOF
66 rm -rf "$TMPDIR"
67 exit 1;
68 }
69
70 cp -ar $SACONFIG $TMPDIR/.
71 cd $TMPDIR/spamassassin_config;
72 svn update -q --non-interactive;
73 if svn status |grep -q '^C'; then
74 FAILUREMESSAGE=$'The following conflicts were found\n\n'
75 FAILUREMESSAGE="$FAILUREMESSAGE$(svn status|grep ^C)";
76 report_failure
77 fi;
78 cd - >/dev/null 2>&1
79
80 if ! spamassassin -p $TMPDIR/spamassassin_config/$USERCONF --lint > $TMPDIR/sa_lint 2>&1; then
81 FAILUREMESSAGE="$(echo -e 'spamassassin -p $TMPDIR/spamassassin_config/$USERCONF --lint\nfailed with\n'| cat - $TMPDIR/sa_lint)";
82 report_failure
83 fi;
84 mv "$SACONFIG" "$BAKDIR/spamassassin_config_r$ORIGREV"
85 mv "$TMPDIR/spamassassin_config" "$SACONFIG"
86 trap - ERR
87 remove_pidfile
88 rm -rf "$TMPDIR"
89
90 if [ "$HOSTNAME" == "rietz" ]; then
91 touch /home/debbugs/.spamassassin/user_prefs
92 elif [ "$HOSTNAME" == "liszt" ]; then
93 # do nothing
94 true;
95 else
96 echo "Unknown hostname '$HOSTNAME'";
97 exit 1;
98 fi;
99
100
101 exit 0;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5