-
Notifications
You must be signed in to change notification settings - Fork 25
/
cron-pacmatic
executable file
·40 lines (32 loc) · 1.03 KB
/
cron-pacmatic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /bin/bash
. /usr/bin/pacmatic --as-lib
if [ $# -eq 0 ]; then
cat << END
Usage: $0 <[email protected]>
For this to work, you need to set the mail command correctly
See https://wiki.archlinux.org/index.php/Msmtp#Using_the_mail_command
END
exit
fi
init_fakeroot_db()
{
mkdir -p /tmp/localsync
ln -s /var/lib/pacman/local /tmp/localsync &>/dev/null
}
[ -d /tmp/localsync/ ] || init_fakeroot_db
pending_updates() # none : list of packages
{
pacman -Qqu --dbpath /tmp/localsync/ | egrep -vi '^(Checking|warning|Remove|Total)' | tr '\n' ' '
}
# Get pending updates in a safe directory
fakeroot pacman -Syy --dbpath /tmp/localsync/ &> /dev/null
packages=`pending_updates`
if [[ -n $packages ]]; then
mail_body=`mktemp`
check_news >> $mail_body
mail_summary >> $mail_body
echo "Recent ML chatter: $mail_counts" >> $mail_body
echo "Pacman updates: $packages" >> $mail_body
cat $mail_body |\
mail -s "Updates available on $(hostname)" $1
fi