Skip to content

Instantly share code, notes, and snippets.

@kescherCode
Last active September 23, 2022 12:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kescherCode/f29c9d4945feb2fcaf4ba7c6103a83f3 to your computer and use it in GitHub Desktop.
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.
#!/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 <no-reply@kescher.at>"
toaddress="Jeremy Kescher <jeremy@kescher.at>"
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"
@kescherCode
Copy link
Author

kescherCode commented Oct 13, 2020

Dependencies: pacman-contrib, yay or paru (needs adjustment of aur_helper variable), s-nail (or any other mailx provider)

@jonasgeiler
Copy link

okay

@kescherCode
Copy link
Author

okay

okay

@0x0verflow
Copy link

okay

okay

okay

@iraizo
Copy link

iraizo commented Apr 17, 2021

okay

okay

okay

okay

@q60
Copy link

q60 commented Aug 28, 2021

okay

okay

okay

okay

okay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment