1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/borg_ynh.git synced 2024-09-03 18:16:05 +02:00

Added option to chose when to receive email alerts, on errors only, never or always.

This commit is contained in:
squeak 2021-05-09 13:46:51 +02:00 committed by ljf (zamentur)
parent 658e255ac5
commit d26ca69558
3 changed files with 13 additions and 2 deletions

View file

@ -73,10 +73,11 @@ fi
# Send mail on backup (partially) failed
domain=$(hostname)
repository="$(sudo yunohost app setting ${borg_id} repository)"
if [ ! -z "$errors" ]; then
mailalert="$(sudo yunohost app setting ${borg_id} mailalert)"
if [[ ! -z "$errors" && $mailalert != "never" ]]; then
cat <(echo -e "$errors\n\n\n") "$log_file" "$err_file" | mail -s "[borg] Backup failed from $domain onto $repository" root
exit 1
else
else if [ $mailalert == "always" ]
cat $log_file | mail -s "[borg] Backup succeed from $domain onto $repository" root
exit 0
fi

View file

@ -85,6 +85,15 @@
},
"example": "Monthly or Weekly or Daily or Hourly or 4:00 or 5,17:00 or Sat --1..7 18:00:00",
"default": "Daily"
},
{
"name": "mailalert",
"type": "string",
"ask": {
"en": "Do you want admin to receive mail notifications on backups ?",
"fr": "Souhaitez-vous recevoir des notifications par mail à chaque sauvegarde ?"
},
"choices": ["always", "errors_only", "never"]
}
]
}

View file

@ -23,6 +23,7 @@ export on_calendar="$(ynh_app_setting_get $app on_calendar)"
export conf="$(ynh_app_setting_get $app conf)"
export data="$(ynh_app_setting_get $app data)"
export apps="$(ynh_app_setting_get $app apps)"
export mailalert="$(ynh_app_setting_get $app mailalert)"
#=================================================
# CHECK IF AN UPGRADE IS NEEDED