Added Documentation and cleanup shell skript

Signed-off-by: tyrolyean <tyrolyean@tyrolyean.net>
This commit is contained in:
tyrolyean 2020-05-01 15:48:04 +02:00
parent 764ff918bd
commit a9383c9175
No known key found for this signature in database
GPG key ID: EDD105663B707C62
2 changed files with 48 additions and 2 deletions

28
README
View file

@ -21,10 +21,12 @@ You can specify the following command line options:
detected or not. If true, the mail will not be modified.
--in-port -i
The incoming smtp port/the port from which mail is received.
The incoming smtp port/the port from which mail is received. Defaults to
4269.
--out-port -o
The outgoing smtp port/the port to which mail ist passed through.
Defaults 4270
--directory -d
The directory inside of which the attachments will be stored in. Please
@ -59,4 +61,26 @@ postfix website.
This program needs to be started via it's own systemd service on system boot.
You need to add the in and oputput ports to your postfix queue as described in
the link above. More documentation is to a TODO
the link above. For example, a setup with the default values looks like this:
|-------| SMTP |-----------| SMTP |-------|
|POSTFIX| --> | MAILATTACH| --> |POSTFIX|
|-------| n 4269 |-----------| n 4270 |-------|
|
|
v
|-----------|
|Attachments|
|-----------|
DIRECTORY CLEANING
If you want to regularly purge old files from the directory, you can start the
shell script clean.sh in this repository via a chron job. It will by default
remove all files older than 10 days. If you want to write your own shell script
or let something else do the job for you, the directories where files are stored
are structured like this:
2020-01-01T1430-3893482323323
^DATE ^TIME^RANDOM NUMBER
The random number at the end consists of several signed integers, therefore it
sometimes has one or more - in it.

22
clean.sh Executable file
View file

@ -0,0 +1,22 @@
#!/bin/bash
if [ -z "$1" ]
then
echo "Cleaning in working directory!"
else
echo "Cleaning in $1!"
cd $1
fi
for d in */ ; do
DIR_DATE=$(echo $d| head -c 10)
expration_DATE=$(date -d "-10 days" --iso-8601)
echo $expration_DATE vs $DIR_DATE
if [[ "$expration_DATE" > "$DIR_DATE" ]]
then
echo "Purging old directory $d..."
rm -rf $d
fi
done