[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RE: Detect upgradable packages in shell script ran as a non-root user



Hi,

What I have been using for years is a little script to send me (and the servicedesk) a daily mail:

#!/bin/bash
# MAILREC is space separated
MAILREC="myemail@tio.nl helpdesk@tio.nl"
SUBJECT="Upgrade report voor $HOSTNAME"
TMPFILE=/tmp/upgradereport.tmp

# Step 1: update repositories...
apt-get update >/dev/null 2>&1

# Step 2: show upgrades
apt-get --dry-run upgrade | grep Inst > $TMPFILE
if egrep -q ^Inst $TMPFILE
then
  mail -s "$SUBJECT" $MAILREC < $TMPFILE
fi

rm $TMPFILE


This script simply gets called from crontab:
# Test once a day if there are any upgrades to be apllied
5 5 * * 0 root /usr/local/bin/upgradereport.sh

It does run as root but then why shouldn't it?
Add the -V switch to the apt-get upgrade line to see from which version to which version the upgrade is needed.
I just do not need that in my mail, I'll see that when I perform the upgrade.

Bonno Bloksma
 

Reply to: