Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #175328

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

From Bonno Bloksma <b.bloksma@tio.nl>
Newsgroups linux.debian.user
Subject RE: Detect upgradable packages in shell script ran as a non-root user
Date 2016-12-02 12:40 +0100
Message-ID <sJUm5-3er-15@gated-at.bofh.it> (permalink)
References <sJeGd-7Ih-25@gated-at.bofh.it> <sJQVh-HL-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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
 

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Detect upgradable packages in shell script ran as a non-root user Martin T <m4rtntns@gmail.com> - 2016-11-30 16:10 +0100
  Re: Detect upgradable packages in shell script ran as a non-root user Greg Wooledge <wooledg@eeg.ccf.org> - 2016-11-30 16:20 +0100
    Re: Detect upgradable packages in shell script ran as a non-root user Shin Ice <shin.ice@shinice.net> - 2016-11-30 16:40 +0100
  Re: Detect upgradable packages in shell script ran as a non-root user Liam O'Toole <liam.p.otoole@gmail.com> - 2016-11-30 18:50 +0100
  Re: Detect upgradable packages in shell script ran as a non-root  user Joe <joe@jretrading.com> - 2016-11-30 19:40 +0100
  Re: Detect upgradable packages in shell script ran as a non-root user kushal@locationd.net - 2016-12-01 06:20 +0100
  Re: Detect upgradable packages in shell script ran as a non-root  user Tixy <tixy@yxit.co.uk> - 2016-12-02 09:00 +0100
    RE: Detect upgradable packages in shell script ran as a non-root  user Bonno Bloksma <b.bloksma@tio.nl> - 2016-12-02 12:40 +0100
  Re: Detect upgradable packages in shell script ran as a non-root user Jonathan Dowland <jmtd@debian.org> - 2016-12-02 12:50 +0100

csiph-web