Created an update notification script

194 views
Skip to first unread message

Ted W.

unread,
Mar 8, 2012, 10:01:05 AM3/8/12
to reposado
I got the idea for this script from Bill Lummis's post here: http://goo.gl/Nepj1.
I expanded on his idea and made the script a little more generic and
flexible. Currently, I have this running as a nightly cron but you
could set it up however you like. Hope someone else can you use this.
If you would like, I also have it on my github account here under
"reposado_helpers": https://github.com/k4k/pub-scripts
---------------------
#!/bin/bash

#
# This script assumes you have a dedicated user for reposado.
# It also makes the assumption that the repo_sync and repoutil files
# exist in ~/code (as if reposado's ~/ were the git repo root).
# I've included some sections which are commented out if your setup is
different
#

# Reposado user, change if necessary
RUSER=reposado
# Change user....@website.com to to be a space seperated list of
email addresses to receive update notifications
RECIPIENTS="user....@website.com user....@website.com
user....@website.com"

# If the user above's home directory is not root of the reposado root
directory
# switch out the following lines and set the directory manually.
#
# REPOSADOROOTDIR=/path/to/code/directory
REPOSADOROOTDIR=$(getent passwd $RUSER | cut -d: -f6)

###################################
### DO NOT EDIT BELOW THIS LINE ###

# Check for updates first
$REPOSADOROOTDIR/code/repo_sync

$REPOSADOROOTDIR/code/repoutil --updates | /bin/cut -d[ -f1 >
$REPOSADOROOTDIR/newupdate.txt

if [ ! -f $REPOSADOROOTDIR/previousupdate.txt ]; then
echo -e "$REPOSADOROOTDIR/previousupdate.txt does not exist. Please
run: \n\t\t$REPOSADOROOTDIR/code/repoutil --updates | cut -d[ -f1 >
$REPOSADOROOTDIR/previousupdate.txt"
exit 1
fi

$REPOSADOROOTDIR/code/repoutil --updates | cut -d[ -f1 >
$REPOSADOROOTDIR/newupdate.txt

if ! diff $REPOSADOROOTDIR/newupdate.txt $REPOSADOROOTDIR/
previousupdate.txt > $REPOSADOROOTDIR/availableupdates.txt ; then
for ADDR in $RECIPIENTS; do
/bin/mail -s "New Mac Updates Downloaded" $ADDR < $REPOSADOROOTDIR/
availableupdates.txt
done
fi

rm -f $REPOSADOROOTDIR/previousupdate.txt

mv $REPOSADOROOTDIR/newupdate.txt $REPOSADOROOTDIR/previousupdate.txt
Reply all
Reply to author
Forward
0 new messages