[Slapt-get-devel] Slapt-get Update Notifier Script
SiegeX
siegex at atozcomp.com
Tue Oct 26 23:24:07 EDT 2004
I wasn't having much luck with the current slapt-get update notifier script when using it with -current so I decided to write my own in good 'ol bash. I believe it turned out very nice and it's as short, sweet and to the point as I could make it. It basically works by checking to see if the changelog has been modified since the last time the script was run. I do this by grabbing only the header info, not the entire file so its very easy on bandwidth. If the changelog has been modified it will update the changelog date and email you the names of the packages that have been updated as well as the additions to the changelog. Additionally, it will download those packages if you set DOWNLOAD="1". Toss this into a daily cron and you should be set. All questions, comments welcome.
-Sean
----------------------START CUT---------------------------
#!/bin/bash
###############################################
# CHANGE THESE VARIABLES #
###############################################
CHANGELOG="http://free.usc.edu/pub/linux/distributions/slackware/slackware-current/ChangeLog.txt"
MAIL_FROM="slaptget at atozcomp.com"
RCPT_TO="siegex at atozcomp.com"
DOWNLOAD="0"
###############################################
# DO NOT EDIT BELOW THIS LINE #
###############################################
if [ ! -f /etc/slapt-get/changelog ]; then
curl -s "${CHANGELOG}" --output /etc/slapt-get/changelog
curl -Is "${CHANGELOG}" | grep "Last-Modified:" > /etc/slapt-get/changelog.last
fi
curl -Is "${CHANGELOG}" | grep "Last-Modified:" > /tmp/changelog.last
if ! diff /tmp/changelog.last /etc/slapt-get/changelog.last; then
curl -s "${CHANGELOG}" --output /tmp/changelog
CHANGE_DATA=`comm -13 /etc/slapt-get/changelog /tmp/changelog`
slapt-get --update
PKG_UPDATES=`slapt-get --upgrade --simulate | grep "^The following packages will be upgraded:$" -A 1`
if [[ "${DOWNLOAD}" = "1" ]] ; then
slapt-get --upgrade --download-only
fi
mail -s "New Updates Available" -r "${MAIL_FROM}" "${RCPT_TO}" <<-EOF
${PKG_UPDATES}
#############################
# Changelog Excerpt
${CHANGE_DATA}
EOF
mv /tmp/changelog /etc/slapt-get/changelog
mv /tmp/changelog.last /etc/slapt-get/changelog.last
else
rm /tmp/changelog.last
fi
--------------------------END CUT-----------------------------------------
More information about the Slapt-get-devel
mailing list