diff --git a/duplicati/monitor.backup.sh b/duplicati/monitor.backup.sh index 6823fbc..28f025d 100755 --- a/duplicati/monitor.backup.sh +++ b/duplicati/monitor.backup.sh @@ -54,7 +54,8 @@ readonly MIN_SIZE_INT_DEFAULT="10" readonly MIN_SIZE_UNIT_DEFAULT="MB" readonly MIN_SIZE_DEFAULT="${MIN_SIZE_INT_DEFAULT}${MIN_SIZE_UNIT_DEFAULT}" ## Default domain for email addresses -readonly USER_EMAIL_DOMAIN_DEFAULT=$(hostname -d) +USER_EMAIL_DOMAIN_DEFAULT=$(hostname -d) ; readonly USER_EMAIL_DOMAIN_DEFAULT +SENDER_EMAIL_ADDRESS_DEFAULT="duplicati@$(hostname --fqdn --)" ; readonly SENDER_EMAIL_ADDRESS_DEFAULT ## Colors readonly PURPLE='\033[1;35m' @@ -78,6 +79,12 @@ EXAMPLES : - Apply to a specific directory (/mnt/remote.duplicati) ${PROGNAME} --dir /mnt/remote.duplicati + - Use a specific email address for sender + ${PROGNAME} --sender "admin@domain.tld" + + - Use a specific email address and name for sender + ${PROGNAME} --sender "Duplicati no-reply " + OPTIONS : -d,--dir,--directory Path where users home directory are stored @@ -91,6 +98,10 @@ OPTIONS : Domain used to build user's email address. (default: ${USER_EMAIL_DOMAIN_DEFAULT}). + --sender,--mail-sender,--sender-mail + Email address used to send mails to users. + (default: ${SENDER_EMAIL_ADDRESS_DEFAULT}). + --debug Enable debug messages. @@ -195,6 +206,12 @@ define_vars() { # {{{ readonly user_email_domain="${USER_EMAIL_DOMAIN_DEFAULT}" fi ## }}} + ## If sender_email_address wasn't defined (argument) {{{ + if [ -z "${sender_email_address}" ]; then + ## Use default value + readonly sender_email_address="${SENDER_EMAIL_ADDRESS_DEFAULT}" + fi + ## }}} } # }}} @@ -441,7 +458,9 @@ main() { # {{{ Taille précédente pour cette sauvegarde/Previous size for this backup : ~${backup_dir_previous_size} ${min_size_unit} (compress). Taille actuelle pour cette sauvegarde/Current size for this backup : ~${backup_dir_current_size} ${min_size_unit} (compress). La différence de taille (~${backup_dir_compare_size} ${min_size_unit}) est inférieure au minimum attendu (${min_size}). + --- + The difference (~${backup_dir_compare_size} ${min_size_unit}) is bellow the minimum expected size (${min_size}). " >> "${user_email_template}" ### }}} @@ -479,7 +498,7 @@ Recorded informations from previous tests : ### }}} ### Send email {{{ debug_message "| Send email content (${user_email_template}) to user email address (${RED}${user_email_address}${COLOR_DEBUG})." - mail -r "duplicati@duplicati.$(hostname --domain)" -s "Duplicati backup warning" "${user_email_address}" < "${user_email_template}" \ + mail -a "From:${sender_email_address}" -s "Duplicati backup warning - ${user_dir}" "${user_email_address}" < "${user_email_template}" \ || error_message "Can't send content (${user_email_template}) by mail to user (${user_email_address}). See --debug option for more options." 23 ### }}} fi @@ -558,6 +577,12 @@ if [ ! "${NBARGS}" -eq "0" ]; then ## Define var readonly user_email_domain="${1}" ;; + --sender|--mail-sender|--sender-mail )## Define sender_email_address + ## Move to the next argument + shift + ## Define var + readonly sender_email_address="${1}" + ;; --debug ) ## debug DEBUG=0 debug_message "--- Manage argument BEGIN"