#!/bin/sh

LOCKFILE=/var/lock/yum-cron.lock

# Only run if this flag file is set (by /etc/rc.d/init.d/yum-cron)
if [ ! -f /var/lock/subsys/yum-cron ]; then
  exit 0
fi

# Try mkdir for the lockfile, will test for and make it in one atomic action
mkdir $LOCKFILE 2>/dev/null || exit
# and clean up that lockfile if the script exits or is killed  
trap "{ rmdir $LOCKFILE 2>/dev/null ; exit 255; }" INT TERM EXIT

# Grab config settings
if [ -f /etc/sysconfig/yum-cron ]; then
  source /etc/sysconfig/yum-cron
fi

# and all that just to do this:
/usr/bin/yum -e 0 -d 0 clean packages

exit 0
