Created
August 19, 2020 10:18
-
-
Save eriknelson/b1a0a23ee746c38ce127c9fed5c26f4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# vim: set ft=bash: | |
update_lc=$(journalctl --since "yesterday" -t yum | tail -n +2 | wc -l) | |
if [[ $update_lc -gt 0 ]]; then | |
datestamp=$(date +%s) | |
scratch_file="{{ scratch_path }}/update-alert-${datestamp}.txt" | |
journalctl --since "yesterday" -t yum &> $scratch_file | |
grep -i kernel $scratch_file | |
restart_required=$? | |
if [[ $restart_required -eq 0 ]]; then | |
mail -Ssendwait -s "[Yum Updates Installed: RESTART]" \ | |
-r "{{ mg_smtp_username }}" "{{ mail_to }}" < $scratch_file | |
else | |
mail -Ssendwait -s "[Yum Updates Installed]" \ | |
-r "{{ mg_smtp_username }}" "{{ mail_to }}" < $scratch_file | |
fi | |
rm $scratch_file | |
else | |
echo "FIN" | mail -Ssendwait -s "[No Updates Installed]" \ | |
-r "{{ mg_smtp_username }}" "{{ mail_to }}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment