65 lines
1.3 KiB
Bash
Executable File
65 lines
1.3 KiB
Bash
Executable File
#! /bin/sh
|
|
|
|
while true
|
|
do
|
|
echo "`date` checking"
|
|
|
|
imapfilter -c fetchmsg.lua
|
|
|
|
for m in `find . -name "message*.txt"`
|
|
do
|
|
|
|
ID=`(date;echo $$;echo $m)|sha256sum|sed 's/ *-//'`
|
|
|
|
mkdir $ID
|
|
cd $ID
|
|
munpack ../$m
|
|
|
|
ls -l
|
|
|
|
TXT=`ls *.desc`
|
|
|
|
if [ "$TXT" = "" ]
|
|
then
|
|
echo "message $m didn't contain any image";
|
|
(
|
|
formail -r <../$m
|
|
echo ""
|
|
echo "the message could not be decoded, this is usually an issue with the MIME format"
|
|
echo "like a mail with text/plain and text/html format"
|
|
) | /usr/sbin/sendmail -t
|
|
else
|
|
mkdir ~/gemini-site/capsule/posts/$ID
|
|
|
|
cat $TXT >~/gemini-site/capsule/posts/$ID/post.gmi
|
|
echo "" >>~/gemini-site/capsule/posts/$ID/post.gmi
|
|
|
|
rm -f $TXT
|
|
|
|
for img in `find . -name "*.jpg" -o -name "*.gif" -o -name "*.png" -o -name "*.webp" -o -name "*.JPG" -o -name "*.GIF" -o -name "*.PNG" -o -name "*.WEBP"`
|
|
do
|
|
echo "=> $img" >> ~/gemini-site/capsule/posts/$ID/post.gmi
|
|
chmod 644 $img
|
|
mv $img ~/gemini-site/capsule/posts/$ID
|
|
done
|
|
|
|
(
|
|
formail -r <../$m
|
|
echo ""
|
|
echo "your post has been created with the url"
|
|
echo ""
|
|
echo "gemini://gemini.lehmann.cx/posts/$ID/post.gmi"
|
|
) | /usr/sbin/sendmail -t
|
|
fi
|
|
|
|
cd ..
|
|
|
|
rmdir $ID
|
|
|
|
rm $m
|
|
done
|
|
|
|
echo "`date` finished processing"
|
|
done
|
|
|