separate processing of a single mbox to a function
authorAlvaro Herrera <[email protected]>
Sat, 21 Mar 2009 22:54:51 +0000 (22:54 +0000)
committerAlvaro Herrera <[email protected]>
Sat, 21 Mar 2009 22:54:51 +0000 (22:54 +0000)
git-svn-id: file:///Users/dpage/pgweb/svn-repo/trunk@2438 8f5c7a92-453e-0410-a47f-ad33c8a6b003

archives/bin/mk-mhonarc

index fd6678b166ece89a539f9aa35092cd1ec4d3076c..5c336c428cdc55da0244408b286eb62243ed1ad0 100755 (executable)
@@ -39,40 +39,10 @@ fi
 
 $ARCHIVES_BIN/generate-list-descriptions
 
-for list in `ls $MAJORDOMO_FILES`; do
-  cd $ARCHIVES_ROOT
-  listdir=$MAJORDOMO_FILES/$list/files/public/archive
-
-  if [ ! -d $listdir ]; then
-    continue
-  fi
-  # If the list is present in the "blacklist file", do not archive it, and
-  # send a complain by email, but throttle it so that it's not too obnoxious.
-  if grep "$list" $ARCHIVES_BIN/blacklist >/dev/null 2>&1; then
-    complainfile=${list}_complained
-    if [ -f $complainfile ]; then
-      # already complained, but remove file if it's too old.  This makes us
-      # complain once every 12 hours
-      age=`stat --format=%Y $complainfile`
-      now=`date +%s`
-      if [ $(($now - $age)) -gt $((60 * 60 * 12)) ]; then
-       rm $complainfile
-      fi
-      continue
-    fi
-    # use a subscribed address so that it is not held for moderation
-    echo "warning: sensitive list $list found on archives" | mail -s "sensitive list found" $DESTINATION_ADDRESS -- -f $SOURCE_ADDRESS
-    touch $complainfile
-    continue
-  fi
-  if [ ! -d "$list" ]; then
-    mkdir $list
-  fi
-  cd $list
-
-  for mbox in `ls --reverse $listdir`; do
-    path=$listdir/$mbox
-    mbox=${mbox%%.gz}          # remove possible trailing .gz
+process_one_mbox() {
+    local path mbox ymon year month ydashm rcfile doit gzipped
+    path=$1
+    mbox=$2
     ymon=${mbox##*.}           # extract yyyymm
     year=${ymon%%??}           # extract yyyy
     month=${ymon##????}                # extract mm
@@ -138,6 +108,44 @@ for list in `ls $MAJORDOMO_FILES`; do
       fi
     fi
     date > $ydashm/last-checked
+}
+
+for list in `ls $MAJORDOMO_FILES`; do
+  cd $ARCHIVES_ROOT
+  listdir=$MAJORDOMO_FILES/$list/files/public/archive
+
+  if [ ! -d $listdir ]; then
+    continue
+  fi
+  # If the list is present in the "blacklist file", do not archive it, and
+  # send a complain by email, but throttle it so that it's not too obnoxious.
+  if grep "$list" $ARCHIVES_BIN/blacklist >/dev/null 2>&1; then
+    complainfile=${list}_complained
+    if [ -f $complainfile ]; then
+      # already complained, but remove file if it's too old.  This makes us
+      # complain once every 12 hours
+      age=`stat --format=%Y $complainfile`
+      now=`date +%s`
+      if [ $(($now - $age)) -gt $((60 * 60 * 12)) ]; then
+       rm $complainfile
+      fi
+      continue
+    fi
+    # use a subscribed address so that it is not held for moderation
+    echo "warning: sensitive list $list found on archives" | mail -s "sensitive list found" $DESTINATION_ADDRESS -- -f $SOURCE_ADDRESS
+    touch $complainfile
+    continue
+  fi
+  if [ ! -d "$list" ]; then
+    mkdir $list
+  fi
+  cd $list
+
+  for mbox in `ls --reverse $listdir`; do
+    path=$listdir/$mbox
+    mbox=${mbox%%.gz}          # remove possible trailing .gz
+
+    process_one_mbox $path $mbox
   done
 
   # XXX maybe this can be done better with mod_rewrite?