improve bash script
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Robert Kaussow 2020-02-12 19:36:08 +01:00
parent 065f900219
commit 1ad7900148

View File

@ -1,14 +1,16 @@
#jinja2: lstrip_blocks: True
#!/bin/bash
#!/usr/bin/env bash
{{ ansible_managed | comment }}
set -eo pipefail
FILEPATH=$1
FILENAME=$2
FROM_ADDR="{{ scan2mail_from_address }}"
TO_ADDRESS="`basename \"$FILEPATH\"`@{{ scan2mail_mail_domain }}"
ATTACHMENT="$1/$2"
TO_ADDRESS=$(basename "${FILEPATH}")@{{ scan2mail_mail_domain }}
ATTACHMENT="${FILEPATH}/${FILENAME}"
sleep 10
echo "{{ scan2mail_message | default('') }}" | mail -s "{{ scan2mail_subject }}" -a "From: ${FROM_ADDR}" -A ${ATTACHMENT} ${TO_ADDRESS}
echo "{{ scan2mail_message | default('') }}" | mail -s "{{ scan2mail_subject }}" -a "From: ${FROM_ADDR}" -A "${ATTACHMENT}" "${TO_ADDRESS}"