From a9383c917528796d7b8774998963557f5c5157d2 Mon Sep 17 00:00:00 2001 From: tyrolyean Date: Fri, 1 May 2020 15:48:04 +0200 Subject: [PATCH] Added Documentation and cleanup shell skript Signed-off-by: tyrolyean --- README | 28 ++++++++++++++++++++++++++-- clean.sh | 22 ++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100755 clean.sh diff --git a/README b/README index a9fe3b2..07580dc 100644 --- a/README +++ b/README @@ -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. diff --git a/clean.sh b/clean.sh new file mode 100755 index 0000000..a554bac --- /dev/null +++ b/clean.sh @@ -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 +