summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-10-10 09:53:38 +0200
committerErich Eckner <git@eckner.net>2019-10-10 09:53:38 +0200
commitad12c709f026e480d9cd3cc6662c2d826d58f57a (patch)
treeb0d78449c5d8b2bc4ae8385fe607e9a60479964e
parentaae2b4b2711e6343e3e2f52ed0a7e595ce4ffb1d (diff)
downloadsendmailadvanced-ad12c709f026e480d9cd3cc6662c2d826d58f57a.tar.xz
put hooks into /etc/sendmailadvances.hooks/
-rw-r--r--Makefile1
-rwxr-xr-xsendmailadvanced.conf40
-rwxr-xr-xsendmailadvanced.in16
3 files changed, 13 insertions, 44 deletions
diff --git a/Makefile b/Makefile
index 138fbde..6a2ecfb 100644
--- a/Makefile
+++ b/Makefile
@@ -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