summaryrefslogtreecommitdiff
path: root/sendmailadvanced
diff options
context:
space:
mode:
Diffstat (limited to 'sendmailadvanced')
-rwxr-xr-xsendmailadvanced61
1 files changed, 47 insertions, 14 deletions
diff --git a/sendmailadvanced b/sendmailadvanced
index 12a327c..3c3122d 100755
--- a/sendmailadvanced
+++ b/sendmailadvanced
@@ -1,14 +1,25 @@
#!/bin/bash
verwendung() {
- >&2 echo 'sendmailadvanced [-h|--hook param-for-hooks] [-i|--inline file] [-e|--encrypt] [-s|--stamp] [-t] [--no-hooks]'
+ >&2 echo 'sendmailadvanced [(-h|--hook) hook] [(-i|--inline) file | -t|--no-inline] [-e|--[no-]encrypt] [-s|--[no-]stamp]'
+ >&2 echo ' -h|--hook: activate hook'
+ >&2 echo ' -i|--inline: enhance email file in situ'
+ >&2 echo ' "--inline -" has the same effect as "-t"'
+ >&2 echo ' conflicts with -t|--no-inline'
+ >&2 echo ' -t|--no-inline: enhance email from stdin to stdout'
+ >&2 echo ' conflicts with -i|--inline'
+ >&2 echo ' -e|--[no-]encrypt: do (not) encrypt'
+ >&2 echo ' -s|--[no-]stamp: do (not) stamp'
exit 1
}
datei=""
-encrypt=false
-stamp=false
-applyHooks=true
+encrypt=true
+stamp=true
+
+dForced=false
+eForced=false
+sForced=false
if [ -x /etc/sendmailadvanced.conf ]
then
@@ -22,8 +33,10 @@ else
done
fi
+gpg --list-keys "${gpg_recipient}" &> /dev/null || encrypt=false
+which hashcash &> /dev/null || stamp=false
-eval set -- "$(getopt -o eh:i:st --long encrypt,hook:,inline:,no-hooks,stamp -n "$(basename "$0")" -- "$@")"
+eval set -- "$(getopt -o eh:i:st --long encrypt,no-encrypt,hook:,inline:,no-inline,stamp,no-stamp -n "$(basename "$0")" -- "$@" || echo verwendung)"
while true
do
@@ -33,22 +46,36 @@ do
hooks[${#hooks[@]}]="$1"
;;
-i|--inline)
- echo "inline erkannt"
+ ${dForced} && verwendung
shift
datei="$1"
+ [ "${datei}" == "-" ] && datei=""
+ dForced=true
+ ;;
+ -t|--no-inline)
+ ${dForced} && verwendung
+ datei=""
+ dForced=true
;;
-e|--encrypt)
+ ${eForced} && verwendung
encrypt=true
+ eForced=true
+ ;;
+ --no-encrypt)
+ ${eForced} && verwendung
+ encrypt=false
+ eForced=true
;;
-s|--stamp)
+ ${sForced} && verwendung
stamp=true
+ sForced=true
;;
- --no-hooks)
- applyHooks=false
- ;;
- -t)
- encrypt=true
- stamp=true
+ --no-stamp)
+ ${sForced} && verwendung
+ stamp=false
+ sForced=true
;;
--)
shift
@@ -121,9 +148,15 @@ fi
echo "${zeile}"
(
- ${applyHooks} && body_header_hook "${hooks[@]}"
+ for hookParam in "${hooks[@]}"
+ do
+ body_header_hook "${hookParam}"
+ done
cat
- ${applyHooks} && body_footer_hook "${hooks[@]}"
+ for hookParam in "${hooks[@]}"
+ do
+ body_footer_hook "${hookParam}"
+ done
) | \
(
${encrypt} && gpg -e -a -s -r ${gpg_recipient} || cat