From 233afd3efd0139bd24435e40896b5ed13a5d5312 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 21 Oct 2023 10:11:51 +0100 Subject: [PATCH] feat: add backup alert functionality This commit adds a new function `fn_alert_backup` to the `alert.sh` module. This function sends an alert when the system has been backed up. The alert includes a message, action, emoji, sound, and color. In addition, this commit modifies the `command_backup.sh` module to trigger the backup alert by setting the variable `alert` to "backup" and calling `alert.sh`. The purpose of these changes is to provide notifications when backups are created. Co-authored-by: AI Assistant --- lgsm/modules/alert.sh | 13 +++++++++++++ lgsm/modules/command_backup.sh | 2 ++ 2 files changed, 15 insertions(+) diff --git a/lgsm/modules/alert.sh b/lgsm/modules/alert.sh index 5e06f84d6..68486f233 100644 --- a/lgsm/modules/alert.sh +++ b/lgsm/modules/alert.sh @@ -130,6 +130,17 @@ fn_alert_update_linuxgsm() { alertcolourdec="52480" } +fn_alert_backup() { + fn_script_log_info "Sending alert: ${selfname} has been backed up" + alertaction="Backed Up" + alertemoji="📂" + alertsound="1" + alertmessage="${selfname} has been backed up." + # Green + alertcolourhex="#00cd00" + alertcolourdec="52480" +} + fn_alert_permissions() { fn_script_log_info "Sending alert: ${selfname} has permissions issues" alertaction="Checked Permissions" @@ -204,6 +215,8 @@ elif [ "${alert}" == "restarted" ]; then fn_alert_restarted elif [ "${alert}" == "update-linuxgsm" ]; then fn_alert_update_linuxgsm +elif [ "${alert}" == "backup" ]; then + fn_alert_backup else fn_print_fail_nl "Missing alert type" fn_script_log_fatal "Missing alert type" diff --git a/lgsm/modules/command_backup.sh b/lgsm/modules/command_backup.sh index fac5dc38b..55981e19e 100644 --- a/lgsm/modules/command_backup.sh +++ b/lgsm/modules/command_backup.sh @@ -138,6 +138,8 @@ fn_backup_compression() { fn_print_ok_eol fn_print_ok_nl "Completed: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')" fn_script_log_pass "Backup created: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')" + alert="backup" + alert.sh fi }