[Yum] Additional script "yum-check" to run from /etc/cron.daily/yum.cron.

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

 



Hi!

In comp.os.linux.misc there came up a question yesterday:

"Yum -y updating of a PRODUCTION WebServer"

Someone pointed out an available "cron-apt" package only 
checking/mailing for apt updates. Nice idea, find my yum version below 
which should do the same using yum.

Added: 		/usr/bin/yum-check
Added: 		/etc/sysconfig/yum
Modified: 	/etc/cron.daily/yum.cron

Perhaps it's useful for people wanting to run yum manually without 
abandoning checking for updates from cron and receive alerts via mail, 
if there are patches available?


/usr/bin/yum-check:

#!/bin/bash
#
# Name:         yum-check
# Author:       Michael Heiming - 2005-03-11
# Function:     Run from cron to check for yum updates
#               and mail results
# Version:      0.7 (initial)
# Config:       /etc/sysconfig/yum

# Pull in sysconfig settings

. /etc/sysconfig/yum

maila=${MAILTO:=root}
yumdat="/tmp/yum-check-update.$$"
yumb="/usr/bin/yum"

#rm -f ${yumdat%%[0-9]*}*

$yumb check-update >& $yumdat

yumstatus="$?"

case $yumstatus in
         100)
                  cat $yumdat |\
                  mail -s "Alert ${HOSTNAME} updates available!" $maila
                  exit 0
;;
         0)
                 # Only send mail if debug is turned on
                 if [ ${CHECKWRK} = "yes" ];then
                 cat $yumdat |\
                 mail -s "Yum ${HOSTNAME} no patches available." $maila
                 fi
                 exit 0
;;
         *)
                 # Unexpected yum return status
                 (echo "Undefined, yum return status: ${yumstatus}" && \
                 [ -e "${yumdat}" ] && cat "${yumdat}" )|\
                 mail -s "Alert ${HOSTNAME} problems running yum." $maila
esac

# clean up

[ -e "${yumdat}" ] && rm ${yumdat}

### End /usr/bin/yum-check ####



/etc/cron.daily/yum.cron:

#!/bin/sh

# Pull in sysconfig settings

. /etc/sysconfig/yum


if [ -f /var/lock/subsys/yum ]; then

         if [ ${CHECKONLY} = "yes" ];then

                 /usr/bin/yum-check
         fi
         else


         /usr/bin/yum -R 10 -e 0 -d 0 -y update yum
         /usr/bin/yum -R 120 -e 0 -d 0 -y update
fi
### End /etc/cron.daily/yum.cron ###


/etc/sysconfig/yum:


# yes sets yum to check for updates/mail only if patches are available
# no does enable autoupdate if /var/lock/subsys/yum is available
CHECKONLY="yes"

# defaults to root, leave empty if .forward/alias in place for root
MAILTO=""

# Set to yes for debugging only! You get a mail for each run!
CHECKWRK="no"
### End /etc/sysconfig/yum: ###



This is an initial version, likely to need some improvement, but would 
be nice having integrated something in the lines.;)

Regards and keep the great work!

Michael Heiming


[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux