diff options
-rw-r--r-- | Makefile | 1 | ||||
-rwxr-xr-x | sendmailadvanced.conf | 40 | ||||
-rwxr-xr-x | sendmailadvanced.in | 16 |
3 files changed, 13 insertions, 44 deletions
@@ -49,6 +49,7 @@ install: all install -D -m0755 sendmailadvanced $(DESTDIR)$(BINDIR)/sendmailadvanced install -D -m0644 sendmailadvanced.1 $(DESTDIR)$(MANDIR)/man1/sendmailadvanced.1 install -D -m0644 sendmailadvanced.conf $(DESTDIR)$(ETCDIR)/sendmailadvanced.conf + install -d -m0755 $(DESTDIR)$(ETCDIR)/sendmailadvanced.hooks clean: ls -A | \ diff --git a/sendmailadvanced.conf b/sendmailadvanced.conf index 831c0e8..08b1a25 100755 --- a/sendmailadvanced.conf +++ b/sendmailadvanced.conf @@ -9,43 +9,3 @@ gpg_recipients=( # stamp value hashcash_bits=22 - -# things to put into head of (body of) email -body_header_hook() -{ - if [ "$(whoami)" == 'root' ]; then - [ "$1" == 'last-backups' ] && return 0 - [ "$1" == 'paccheck' ] && return 0 - fi - echo "Unkonwn header-hook: '$1'" -} - -# things to put into foot of email -body_footer_hook() -{ - if [ "$(whoami)" == 'root' ]; then - case "$1" in - 'last-backups') - echo '----------------------- Last Backups Begin -------------------------' - echo - last-backups - echo - echo '------------------------ Last Backups End --------------------------' - echo - return 0 - ;; - 'paccheck') - if command -v paccheck >/dev/null; then - echo '----------------------- Pacman Check Begin -------------------------' - echo - paccheck --list-broken --sha256sum - echo - echo '------------------------ Pacman Check End --------------------------' - echo - return 0 - fi - ;; - esac - fi - echo "Unknown footer-hook: '$1'" -} diff --git a/sendmailadvanced.in b/sendmailadvanced.in index 5904f46..5e5a58e 100755 --- a/sendmailadvanced.in +++ b/sendmailadvanced.in @@ -4,7 +4,7 @@ verwendung() { >&2 echo 'sendmailadvanced encrypts emails and generates stamps either in situ or in a pipe. For that it uses hashcash and gnupg.' >&2 echo '' >&2 echo 'Usage: sendmailadvanced [OPTIONS]' - >&2 echo ' -h,--hook=hook activate hook' + >&2 echo ' -h,--hook=hook activate hook; "ALL" chooses all available hooks' >&2 echo ' -i,--inline=file enhance email file in situ.' >&2 echo ' "--inline -" has the same effect as "-t".' >&2 echo ' Conflicts with -t|--no-inline.' @@ -108,7 +108,15 @@ while true; do case "$1" in -h|--hook) shift - hooks[${#hooks[@]}]="$1" + if [ "x$1" = 'xALL' ]; then + for hook in $(find '#ETCDIR#/sendmailadvanced.hooks' -type f); do + if [ -x "#ETCDIR#/sendmailadvanced.hooks/${hook}" ]; then + hooks[${#hooks[@]}]="${hook}" + fi + done + else + hooks[${#hooks[@]}]="$1" + fi ;; --help) verwendung 0 @@ -219,11 +227,11 @@ fi body=$( ( for hookParam in "${hooks[@]}"; do - body_header_hook "${hookParam}" + "#ETCDIR#/sendmailadvanced.hooks/${hookParam}" head done cat for hookParam in "${hooks[@]}"; do - body_footer_hook "${hookParam}" + "#ETCDIR#/sendmailadvanced.hooks/${hookParam}" foot done ) | \ if ${encrypt}; then |