]> git.donarmstrong.com Git - spamassassin_config.git/blobdiff - update_spamassassin
* fix trap and function dash incompatible calls
[spamassassin_config.git] / update_spamassassin
index 3ffa065e8afa39deb1eca7560dff10794904dd3f..3a15e883ca5d63070014862da8be58cd2f0b2d87 100755 (executable)
@@ -9,7 +9,9 @@ SVN=$(which svn)
 
 TMPDIR=$(mktemp -d);
 
-if [ "$HOSTNAME" = "rietz" ]; then
+HOSTNAME=$(hostname);
+
+if [ "$HOSTNAME" = "rietz" ] || [ "$HOSTNAME" = "busoni" ]; then
     BASEDIR="/org/bugs.debian.org"
     USERCONF="bugs/user_prefs";
 elif [ "$HOSTNAME" = "liszt" ]; then
@@ -23,6 +25,13 @@ fi;
 SACONFIG="$BASEDIR/spamassassin_config";
 BAKDIR="$BASEDIR/spamassassin_config_bak";
 
+# because alioth continuously fails, make sure that svn info will
+# succeed first before cluttering the log. Ideally we would report
+# this error, but it happens far too frequently, so we bail out here.
+if ! svn info $(svn info $SACONFIG|awk '/^URL:/{print $2}') >/dev/null 2>&1; then
+    exit 0;
+fi;
+
 # figure out if there's an update to be made
 ORIGREV=$(svn info $SACONFIG |awk '/^Revision:/{print $2}')
 NEWREV=$(svn info $(svn info $SACONFIG|awk '/^URL:/{print $2}')|awk '/^Revision:/{print $2}')
@@ -39,14 +48,14 @@ else
     echo $$ > "$SACONFIG/.update_spamassassin";
 fi;
 
-function remove_pidfile(){
+remove_pidfile () {
     rm "$SACONFIG/.update_spamassassin";
 }
 
-trap remove_pidfile ERR;
+trap remove_pidfile 0;
 
 FAILUREMESSAGE="";
-function report_failure(){
+report_failure () {
     # Hrm; a previous update failed; don't report again until the file
     # is removed or it's more than a day old
     if [ -e "$SACONFIG/failed_update" ] &&
@@ -69,6 +78,7 @@ EOF
 }
 
 cp -ar $SACONFIG $TMPDIR/.
+OLDDIR="$(pwd)"
 cd $TMPDIR/spamassassin_config;
 svn update -q --non-interactive; 
 if svn status |grep -q '^C'; then
@@ -76,7 +86,7 @@ if svn status |grep -q '^C'; then
     FAILUREMESSAGE="$FAILUREMESSAGE$(svn status|grep ^C)";
     report_failure
 fi;
-cd - >/dev/null 2>&1
+cd "$(pwd)"
 
 if ! spamassassin -p $TMPDIR/spamassassin_config/$USERCONF --lint > $TMPDIR/sa_lint 2>&1; then
     FAILUREMESSAGE="$(echo -e 'spamassassin -p $TMPDIR/spamassassin_config/$USERCONF --lint\nfailed with\n'| cat - $TMPDIR/sa_lint)";