summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera2009-03-21 22:54:51 +0000
committerAlvaro Herrera2009-03-21 22:54:51 +0000
commit734b0daf8ee77c7f5328fe03693dbede81ee2dac (patch)
treea1be3ecc52de183adc9981862b4e8374dbc29c71
parent6bd2a4086d986080a0ef3217c057699292624f93 (diff)
separate processing of a single mbox to a function
git-svn-id: file:///Users/dpage/pgweb/svn-repo/trunk@2438 8f5c7a92-453e-0410-a47f-ad33c8a6b003
-rwxr-xr-xarchives/bin/mk-mhonarc76
1 files changed, 42 insertions, 34 deletions
diff --git a/archives/bin/mk-mhonarc b/archives/bin/mk-mhonarc
index fd6678b1..5c336c42 100755
--- a/archives/bin/mk-mhonarc
+++ b/archives/bin/mk-mhonarc
@@ -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?