Last active
September 23, 2022 12:19
-
-
Save kescherCode/f29c9d4945feb2fcaf4ba7c6103a83f3 to your computer and use it in GitHub Desktop.
A script for Arch Linux-based machines to send update notifications via mail.
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 | |
sudouser="kescher" | |
aur_helper="yay" | |
last_update_notification="/usr/local/etc/last_update_notification" | |
subjectline="Update notification for $(hostname -s)" | |
fromaddress="Update Notification <[email protected]>" | |
toaddress="Jeremy Kescher <[email protected]>" | |
repo=$(checkupdates) | |
aur=$(sudo -u "$sudouser" "$aur_helper" -Qu --aur | sort) | |
update="" | |
if [[ -n "$repo" && -n "$aur" ]]; then | |
update="Repo:"$'\n'"$repo"$'\n'"AUR:"$'\n'"$aur" | |
elif [[ -n "$repo" ]]; then | |
update="Repo:"$'\n'"$repo" | |
elif [[ -n "$aur" ]]; then | |
update="AUR:"$'\n'"$aur" | |
else :>"$last_update_notification" && exit | |
fi | |
[[ "$(cat "$last_update_notification")" == "$update" ]] && exit | |
echo "$update" | mail -s "$subjectline" -r "$fromaddress" "$toaddress" | |
echo "$update" > "$last_update_notification" |
okay
okay
okay
okay
okay
okay
okay
okay
okay
okay
okay
okay
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
okay