summaryrefslogtreecommitdiff
path: root/mail_apt_upgradable.sh
blob: 491addc4742f7f7ef867f7fa7ee95bb9e37572a6 (plain)
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
#!/bin/bash

# make sure sendmail works fine, E.g. ssmtp is very light and easy.
# crontab -e & add the following line to run every 6 hours:
# 0     */6   *   *   *     /home/miguel/bin/mail_apt_upgradable.sh

SUBJECT="$HOSTNAME : apt list --upgradeable"
MAIL="m.i@gmx.at"

if [ "$#" -ne 1 ]; then
    "$0" arg0 | sudo sendmail $MAIL
    exit
fi

echo "Subject: $SUBJECT"
echo "Hello Friend,"
echo 
echo "This is the automatic apt checker service."
echo 
sudo apt-get update  1> /dev/null 
echo "'apt update' exited with the return code: $?"
echo  
echo "'apt list --upgradable -a' produced the following output:"
echo 
echo "--- START ---"
apt list --upgradable -a  2>/dev/null
echo "--- END ---"
echo 
echo "Best regards,"
echo "Your FoolBot"