summaryrefslogtreecommitdiffhomepage
path: root/plugins/weblog/procmail/procmail.sh
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-02-11 11:58:03 +0100
committerRoland Reichwein <mail@reichwein.it>2023-02-11 11:58:03 +0100
commitaaaaed8479368b87bc6960dc6abe5a97b4cc7ef9 (patch)
treeb42aba96bb84c0e3593b910011a8b05cffe4e7be /plugins/weblog/procmail/procmail.sh
parente1f1bf463631c73b5a7e70c3f3a1b1206df6c317 (diff)
Separated out weblog
Diffstat (limited to 'plugins/weblog/procmail/procmail.sh')
-rwxr-xr-xplugins/weblog/procmail/procmail.sh119
1 files changed, 0 insertions, 119 deletions
diff --git a/plugins/weblog/procmail/procmail.sh b/plugins/weblog/procmail/procmail.sh
deleted file mode 100755
index 134d957..0000000
--- a/plugins/weblog/procmail/procmail.sh
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/bin/bash
-#
-# Mail Blog input script, to be called by procmail
-#
-set -e
-
-function atexit {
- if [ "$ERRORMSG" != "" -o -s errormsg.txt ] ; then
- (echo "$ERRORMSG" ; cat errormsg.txt) | mutt -s "bloginput: Error" -- "$ADDR" >> ~/log 2>&1
- fi
- cd
- rm -rf "$DIR"
-}
-trap atexit EXIT
-
-function mimedecode() {
- perl -ne 'require MIME::Head; $head = MIME::Head->read(\*STDIN); $head->decode(); print $head->get("Subject")'
-}
-
-function next_index() {
- DIR=$1
-
- LASTENTRY=`ls -1dr $DIR/$(date +%Y)/$(date +%Y%m%d)* 2>/dev/null | xargs -n 1 basename | head -n1`
-
- if [ "$LASTENTRY" == "" ] ; then
- echo 001
- return
- fi
-
- INDEX=${LASTENTRY:9:3}
-
- INDEX=$(($INDEX + 1))
-
- while [ "$((${#INDEX} < 3))" == "1" ] ; do INDEX=0$INDEX ; done
-
- echo $INDEX
-}
-
-echo "Log at `date`:" >> ~/log 2>&1
-
-BLOGDIR=/var/www/rolandreichwein.de-blog
-#BLOGDIR=/var/www/blog
-
-# Default: Error
-ERRORMSG="General error."
-USERLOG=""
-
-DIR=`mktemp -d`
-
-cd "$DIR"
-
-touch body.txt
-touch errormsg.txt
-
-cat > inmail
-
-ADDR=`grep "^From: " inmail | sed -e 's/^From: //'`
-if echo "$ADDR" | grep -q -v "^[a-zA-Z0-9@._-<>\" ]\+$" ; then
- # can't send error message to unknown requester
- ERRORMSG=""
- exit 1
-fi
-if echo "$ADDR" | grep -q "weblog-bloginput" ; then
- # don't reply to mails from weblog-bloginput, i.e. prevent mail loops
- ERRORMSG=""
- exit 1
-fi
-
-ALLLINES=`wc -l inmail | cut -f1 -d" "`
-
-HEADERLINES=`cat inmail | (n=0; while read i ; do
- if [ "$i" == "" ] ; then
- echo $n
- break
- fi
- n=$(($n + 1))
-done)`
-
-HEADER=`head -n$HEADERLINES inmail`
-BODY=`tail -n$(($ALLLINES - $HEADERLINES - 1)) inmail`
-
-echo "$HEADER" > /home/weblog-bloginput/header.txt
-echo "$BODY" > /home/weblog-bloginput/body.txt
-
-SUBJECT=`echo "$HEADER" | mimedecode`
-SUBJECT_PATH=`echo "$SUBJECT" | sed -e 's/[^a-zA-Z0-9]/_/g'`
-ARTICLEINDEX=`next_index $BLOGDIR`
-
-ARTICLEDIR="$BLOGDIR/`date +%Y/%Y%m%d`_${ARTICLEINDEX}_$SUBJECT_PATH"
-
-mkdir -p $ARTICLEDIR
-echo "Subject: $SUBJECT" >> $ARTICLEDIR/article.data
-echo "" >> $ARTICLEDIR/article.data
-
-# get attachments
-munpack -C $ARTICLEDIR `pwd`/inmail >/dev/null || true
-
-DATANAME="`ls $ARTICLEDIR/*.desc || true`" 2>/dev/null
-if [ "$DATANAME" = "" ] ; then
- echo "$BODY" >> $ARTICLEDIR/article.data
-else
- cat "$DATANAME" >> $ARTICLEDIR/article.data
- rm "$DATANAME"
-fi
-
-chmod -R a+r $ARTICLEDIR
-chmod a+x $ARTICLEDIR
-
-(
-echo "Processed successfully."
-echo "ARTICLEDIR=$ARTICLEDIR"
-) | mutt -s "Bloginput: $SUBJECT_PATH" -- "$ADDR" >> ~/log 2>&1
-
-echo "User log:" >> ~/log
-cat body.txt >> ~/log
-
-ERRORMSG=""
-echo "Done successfully at `date`." >> ~/log 2>&1
-