[yum-commits] Branch 'yum-3_2_X' - 9 commits - yum-cron/TODO yum-cron/yum-cleanup.cron.sh yum-cron/yum-cron.sh yum-cron/yum-cron.sysconfig yum-cron/yum-cron.sysvinit yum-cron/yum-update.cron.sh

James Antill james at osuosl.org
Fri Jul 29 16:10:57 UTC 2011


 yum-cron/TODO                |   19 +++++
 yum-cron/yum-cleanup.cron.sh |   11 ++-
 yum-cron/yum-cron.sh         |  150 ++++++++++++++++++++++++++-----------------
 yum-cron/yum-cron.sysconfig  |  124 +++++++++++++++++++++--------------
 yum-cron/yum-cron.sysvinit   |   19 ++---
 yum-cron/yum-update.cron.sh  |   13 ++-
 6 files changed, 212 insertions(+), 124 deletions(-)

New commits:
commit bbb296dd2081d5b838106a5b1b2a4336591b39e6
Author: Matthew Miller <mattdm at mattdm.org>
Date:   Thu Jul 28 21:54:54 2011 -0400

    Add a TODO list for yum-cron

diff --git a/yum-cron/TODO b/yum-cron/TODO
new file mode 100644
index 0000000..28e1964
--- /dev/null
+++ b/yum-cron/TODO
@@ -0,0 +1,19 @@
+Logging:
+- Add basic syslog support (success or failure; number of updates)
+
+Documentation:
+- Write a man page
+- Write a readme file
+
+Mail:
+- Use a different subject for success and failure mail
+- Make receiving mail when nothing happens optional
+
+General:
+- Break out check-updates and download-updates into their own actions;
+  move that logic to the cron scripts
+- Re-do the lockfile bit so failures can be reported without resorting to
+  relying on cron's output handler.
+- Figure out what to do with systemd
+- Update rpm, glibc, yum, python, specially?
+- Check if we're running as root; exit nicely.
commit 08bda0a94b3f1f8a2324c7467f3e2501414fd90f
Author: Matthew Miller <mattdm at mattdm.org>
Date:   Thu Jul 28 21:54:53 2011 -0400

    Fix possible endless loop in yum-cron
    
    In the unlikely but possible case where LOCKDIR contained files _other_ than
    the PIDFILE being tested for, rmdir wouldn't remove it, causing the lock to
    persist and then rapidly be tested over and over as the script respawns.
    
    Now uses rm -rf to zap the LOCKDIR (as is done at other points in the code).

diff --git a/yum-cron/yum-cron.sh b/yum-cron/yum-cron.sh
index de1608e..d549471 100755
--- a/yum-cron/yum-cron.sh
+++ b/yum-cron/yum-cron.sh
@@ -71,7 +71,7 @@ else
   # happened.  We can't know the process name, so, clean up the old lockdir
   # and restart.
   if [[ ! -f $PIDFILE ]]; then
-    rmdir $LOCKDIR 2>/dev/null
+    rm -rf "${LOCKDIR}"
     echo "yum-cron: no lock PID, clearing and restarting myself" >&2
     exec $0 "$@"
   fi
commit b0640415564a2538b86b3c2b00bd3adff730d631
Author: Matthew Miller <mattdm at mattdm.org>
Date:   Thu Jul 28 21:54:52 2011 -0400

    Change internal variable LOCKFILE (which it isn't) to PIDFILE (which it is).

diff --git a/yum-cron/yum-cron.sh b/yum-cron/yum-cron.sh
index 5ba3be4..de1608e 100755
--- a/yum-cron/yum-cron.sh
+++ b/yum-cron/yum-cron.sh
@@ -10,7 +10,7 @@
 # abruptly shutting down mid-transaction. Therefore, you shouldn't change
 # them without changing that.
 LOCKDIR=/var/lock/yum-cron.lock
-LOCKFILE=$LOCKDIR/pidfile
+PIDFILE=$LOCKDIR/pidfile
 TSLOCK=$LOCKDIR/ts.lock
 
 
@@ -62,20 +62,20 @@ touch $YUMTMP
 if mkdir $LOCKDIR 2>/dev/null; then
   # Store the current process ID in the lock directory so we can check for
   # staleness later.
-  echo "$$" >"${LOCKFILE}"
+  echo "$$" >"${PIDFILE}"
   # And, clean up locks and tempfile when the script exits or is killed.
-  trap "{ rm -f $LOCKFILE $TSLOCK; rmdir $LOCKDIR 2>/dev/null; rm -f $YUMTMP; exit 255; }" INT TERM EXIT
+  trap "{ rm -f $PIDFILE $TSLOCK; rmdir $LOCKDIR 2>/dev/null; rm -f $YUMTMP; exit 255; }" INT TERM EXIT
 else
   # Lock failed -- check if a running process exists.  
   # First, if there's no PID file in the lock directory, something bad has
   # happened.  We can't know the process name, so, clean up the old lockdir
   # and restart.
-  if [[ ! -f $LOCKFILE ]]; then
+  if [[ ! -f $PIDFILE ]]; then
     rmdir $LOCKDIR 2>/dev/null
     echo "yum-cron: no lock PID, clearing and restarting myself" >&2
     exec $0 "$@"
   fi
-  OTHERPID="$(cat "${LOCKFILE}")"
+  OTHERPID="$(cat "${PIDFILE}")"
   # if cat wasn't able to read the file anymore, another instance probably is
   # about to remove the lock -- exit, we're *still* locked
   if [[ $? != 0 ]]; then
@@ -92,7 +92,7 @@ else
     # Remove lockfiles more than a day old -- they must be stale.
     find $LOCKDIR -type f -name 'pidfile' -amin +1440 -exec rm -rf $LOCKDIR \;
     # If it's still there, it *wasn't* too old. Bail!
-    if [[ -f $LOCKFILE ]]; then
+    if [[ -f $PIDFILE ]]; then
       # Lock is valid and OTHERPID is active -- exit, we're locked!
       echo "yum-cron: lock failed, PID ${OTHERPID} is active" >&2
       exit 0
commit 6c1e80d1521291086227b888e5a9f7447e77222c
Author: Matthew Miller <mattdm at mattdm.org>
Date:   Thu Jul 28 21:54:51 2011 -0400

    Change "[" builtins in yum-cron to use bash "[[ ]]" compound commands.
    
    This is for consistency, and because the script is bash-specific anyway.

diff --git a/yum-cron/yum-cron.sh b/yum-cron/yum-cron.sh
index 83dc7f6..5ba3be4 100755
--- a/yum-cron/yum-cron.sh
+++ b/yum-cron/yum-cron.sh
@@ -19,7 +19,7 @@ TSLOCK=$LOCKDIR/ts.lock
 SCRIPTDIR=/usr/share/yum-cron/
 
 # If no command line options were given, exit with a usage message.
-if [ -z "$1" ]; then
+if [[ -z "$1" ]]; then
   echo "Usage: yum-cron {update|cleanup|...}"
   exit 1
 else
@@ -28,30 +28,28 @@ fi
 
 # If a command line option was given, it must match a yum script.
 YUMSCRIPT=${SCRIPTDIR}/${ACTION}.yum
-if [ ! -r $YUMSCRIPT ]; then
+if [[ ! -r $YUMSCRIPT ]]; then
   echo "Script for action \"$ACTION\" is not readable in $SCRIPTDIR."
   exit 1
 fi  
 
 # Read the settings from our config file.
-if [ -f /etc/sysconfig/yum-cron ]; then
+if [[ -f /etc/sysconfig/yum-cron ]]; then
   source /etc/sysconfig/yum-cron
 fi
 
 # If no system name is set, use the hostname.
-[ -z "$SYSTEMNAME" ]  && SYSTEMNAME=$( hostname ) 
+[[ -z "$SYSTEMNAME" ]] && SYSTEMNAME=$( hostname ) 
 
 # If DOWNLOAD_ONLY is set, then we force CHECK_ONLY too.
 # Gotta check for updates before we can possibly download them.
-if [ "$DOWNLOAD_ONLY" == "yes" ]; then
-  CHECK_ONLY=yes
-fi
+[[ "$DOWNLOAD_ONLY" == "yes" ]] && CHECK_ONLY=yes
 
 # This holds the output from the "meat" of this script, so that it can
 # be nicely mailed to the configured destination when we're done.
 YUMTMP=$(mktemp /var/run/yum-cron.XXXXXX)
 touch $YUMTMP 
-[ -x /sbin/restorecon ] && /sbin/restorecon $YUMTMP
+[[ -x /sbin/restorecon ]] && /sbin/restorecon $YUMTMP
 
 # Here is the gigantic block of lockfile logic.
 #
@@ -72,7 +70,7 @@ else
   # First, if there's no PID file in the lock directory, something bad has
   # happened.  We can't know the process name, so, clean up the old lockdir
   # and restart.
-  if [ ! -f $LOCKFILE ]; then
+  if [[ ! -f $LOCKFILE ]]; then
     rmdir $LOCKDIR 2>/dev/null
     echo "yum-cron: no lock PID, clearing and restarting myself" >&2
     exec $0 "$@"
@@ -80,7 +78,7 @@ else
   OTHERPID="$(cat "${LOCKFILE}")"
   # if cat wasn't able to read the file anymore, another instance probably is
   # about to remove the lock -- exit, we're *still* locked
-  if [ $? != 0 ]; then
+  if [[ $? != 0 ]]; then
     echo "yum-cron: lock failed, PID ${OTHERPID} is active" >&2
     exit 0
   fi
@@ -94,7 +92,7 @@ else
     # Remove lockfiles more than a day old -- they must be stale.
     find $LOCKDIR -type f -name 'pidfile' -amin +1440 -exec rm -rf $LOCKDIR \;
     # If it's still there, it *wasn't* too old. Bail!
-    if [ -f $LOCKFILE ]; then
+    if [[ -f $LOCKFILE ]]; then
       # Lock is valid and OTHERPID is active -- exit, we're locked!
       echo "yum-cron: lock failed, PID ${OTHERPID} is active" >&2
       exit 0
@@ -122,7 +120,7 @@ fi
         #   nothing special -- just do it
         # Note that in all cases, yum is updated first, and then 
         # everything else.
-        if [ "$CHECK_ONLY" == "yes" ]; then
+        if [[ "$CHECK_ONLY" == "yes" ]]; then
           # TSLOCK is used by the safe-shutdown code in the init script.
           touch $TSLOCK
           /usr/bin/yum $YUM_PARAMETER -e 0 -d 0 -y check-update 1> /dev/null 2>&1
@@ -130,13 +128,13 @@ fi
             1)   exit 1;;
             100) echo "New updates available for host $SYSTEMNAME";
                  /usr/bin/yum $YUM_PARAMETER -e ${ERROR_LEVEL:-0} -d ${DEBUG_LEVEL:-0} -y -C check-update
-                 if [ "$DOWNLOAD_ONLY" == "yes" ]; then
+                 if [[ "$DOWNLOAD_ONLY" == "yes" ]]; then
                      /usr/bin/yum $YUM_PARAMETER -e ${ERROR_LEVEL:-0} -d ${DEBUG_LEVEL:-0} -y --downloadonly update
                      echo "Updates downloaded. Use \"yum -C update\" manually to install them."
                  fi
                  ;;
           esac
-        elif [ "$CHECK_FIRST" == "yes" ]; then
+        elif [[ "$CHECK_FIRST" == "yes" ]]; then
           # Don't run if we can't access the repos -- if this is set, 
           # and there's a problem, we exit silently (but return an error
           # code).
@@ -162,9 +160,9 @@ fi
 
 } >> $YUMTMP 2>&1
 
-if [ ! -z "$MAILTO" ] && [ -x /bin/mail ]; then 
+if [[ ! -z "$MAILTO" && -x /bin/mail ]]; then 
 # If MAILTO is set, use mail command for prettier output.
-  [ -s "$YUMTMP" ] && mail -s "System update: $SYSTEMNAME" $MAILTO < $YUMTMP 
+  [[ -s "$YUMTMP" ]] && mail -s "System update: $SYSTEMNAME" $MAILTO < $YUMTMP 
 else 
 # The default behavior is to use cron's internal mailing of output.
   cat $YUMTMP
commit d2c190021c63e8c742ffcc8657f7a45fe36c5a34
Author: Matthew Miller <mattdm at mattdm.org>
Date:   Thu Jul 28 21:54:50 2011 -0400

    Fix a random mis-indent in yum-cron.sh
    
    No code changes -- just whitespace.

diff --git a/yum-cron/yum-cron.sh b/yum-cron/yum-cron.sh
index 7238416..83dc7f6 100755
--- a/yum-cron/yum-cron.sh
+++ b/yum-cron/yum-cron.sh
@@ -80,31 +80,31 @@ else
   OTHERPID="$(cat "${LOCKFILE}")"
   # if cat wasn't able to read the file anymore, another instance probably is
   # about to remove the lock -- exit, we're *still* locked
-    if [ $? != 0 ]; then
+  if [ $? != 0 ]; then
+    echo "yum-cron: lock failed, PID ${OTHERPID} is active" >&2
+    exit 0
+  fi
+  if ! kill -0 $OTHERPID &>/dev/null; then
+    # Lock is stale. Remove it and restart.
+    echo "yum-cron: removing stale lock of nonexistant PID ${OTHERPID}" >&2
+    rm -rf "${LOCKDIR}"
+    echo "yum-cron: restarting myself" >&2
+    exec $0 "$@"
+  else
+    # Remove lockfiles more than a day old -- they must be stale.
+    find $LOCKDIR -type f -name 'pidfile' -amin +1440 -exec rm -rf $LOCKDIR \;
+    # If it's still there, it *wasn't* too old. Bail!
+    if [ -f $LOCKFILE ]; then
+      # Lock is valid and OTHERPID is active -- exit, we're locked!
       echo "yum-cron: lock failed, PID ${OTHERPID} is active" >&2
       exit 0
-    fi
-    if ! kill -0 $OTHERPID &>/dev/null; then
-      # Lock is stale. Remove it and restart.
-      echo "yum-cron: removing stale lock of nonexistant PID ${OTHERPID}" >&2
-      rm -rf "${LOCKDIR}"
+    else
+      # Lock was invalid. Restart.
+      echo "yum-cron: removing stale lock belonging to stale PID ${OTHERPID}" >&2
       echo "yum-cron: restarting myself" >&2
       exec $0 "$@"
-    else
-      # Remove lockfiles more than a day old -- they must be stale.
-      find $LOCKDIR -type f -name 'pidfile' -amin +1440 -exec rm -rf $LOCKDIR \;
-      # If it's still there, it *wasn't* too old. Bail!
-      if [ -f $LOCKFILE ]; then
-        # Lock is valid and OTHERPID is active -- exit, we're locked!
-        echo "yum-cron: lock failed, PID ${OTHERPID} is active" >&2
-        exit 0
-      else
-        # Lock was invalid. Restart.
-        echo "yum-cron: removing stale lock belonging to stale PID ${OTHERPID}" >&2
-        echo "yum-cron: restarting myself" >&2
-        exec $0 "$@"
-      fi
     fi
+  fi
 fi
 
 # Now, do the actual work.
commit f0db8bd6003021adb6a6850d1266dab02ad6125f
Author: Matthew Miller <mattdm at mattdm.org>
Date:   Thu Jul 28 21:54:49 2011 -0400

    Add comments to yum-cron.sh
    
    No code changes -- just comments.

diff --git a/yum-cron/yum-cron.sh b/yum-cron/yum-cron.sh
index d1a32ec..7238416 100755
--- a/yum-cron/yum-cron.sh
+++ b/yum-cron/yum-cron.sh
@@ -1,10 +1,24 @@
 #!/bin/bash
 
+# This script is designed to be run from cron to automatically keep your
+# system up to date with the latest security patches and bug fixes. It
+# can download and/or apply package updates as configured in
+# /etc/sysconfig/yum-cron.
+
+
+# These are used by /etc/init.d/yum-cron on shutdown to protect against
+# abruptly shutting down mid-transaction. Therefore, you shouldn't change
+# them without changing that.
 LOCKDIR=/var/lock/yum-cron.lock
 LOCKFILE=$LOCKDIR/pidfile
 TSLOCK=$LOCKDIR/ts.lock
+
+
+# This is the home of the yum scripts which power the various actions the
+# yum-cron system performs.
 SCRIPTDIR=/usr/share/yum-cron/
 
+# If no command line options were given, exit with a usage message.
 if [ -z "$1" ]; then
   echo "Usage: yum-cron {update|cleanup|...}"
   exit 1
@@ -12,41 +26,52 @@ else
   ACTION=$1
 fi
 
+# If a command line option was given, it must match a yum script.
 YUMSCRIPT=${SCRIPTDIR}/${ACTION}.yum
 if [ ! -r $YUMSCRIPT ]; then
   echo "Script for action \"$ACTION\" is not readable in $SCRIPTDIR."
   exit 1
 fi  
 
-# Grab config settings
+# Read the settings from our config file.
 if [ -f /etc/sysconfig/yum-cron ]; then
   source /etc/sysconfig/yum-cron
 fi
-# set default for SYSTEMNAME
+
+# If no system name is set, use the hostname.
 [ -z "$SYSTEMNAME" ]  && SYSTEMNAME=$( hostname ) 
 
-# if DOWNLOAD_ONLY is set then we force CHECK_ONLY too.
-# Gotta check before one can download!
+# If DOWNLOAD_ONLY is set, then we force CHECK_ONLY too.
+# Gotta check for updates before we can possibly download them.
 if [ "$DOWNLOAD_ONLY" == "yes" ]; then
   CHECK_ONLY=yes
 fi
 
+# This holds the output from the "meat" of this script, so that it can
+# be nicely mailed to the configured destination when we're done.
 YUMTMP=$(mktemp /var/run/yum-cron.XXXXXX)
 touch $YUMTMP 
 [ -x /sbin/restorecon ] && /sbin/restorecon $YUMTMP
 
-# Note - the lockfile code doesn't try and use YUMTMP to email messages nicely.
-# Too many ways to die, this gets handled by normal cron error mailing.
-# Try mkdir for the lockfile, will test for and make it in one atomic action
+# Here is the gigantic block of lockfile logic.
+#
+# Note: the lockfile code doesn't currently try and use YUMTMP to email
+# messages nicely, so this gets handled by normal cron error mailing.
+#
+
+# We use mkdir for the lockfile, as this will test for and if possible
+# create the lock in one atomic action. (So there's no race condition.)
 if mkdir $LOCKDIR 2>/dev/null; then
-  # store the current process ID in there so we can check for staleness later
+  # Store the current process ID in the lock directory so we can check for
+  # staleness later.
   echo "$$" >"${LOCKFILE}"
-  # and clean up locks and tempfile if the script exits or is killed  
+  # And, clean up locks and tempfile when the script exits or is killed.
   trap "{ rm -f $LOCKFILE $TSLOCK; rmdir $LOCKDIR 2>/dev/null; rm -f $YUMTMP; exit 255; }" INT TERM EXIT
 else
-  # lock failed, check if process exists.  First, if there's no PID file
-  # in the lock directory, something bad has happened, we can't know the
-  # process name, so clean up the old lockdir and restart
+  # Lock failed -- check if a running process exists.  
+  # First, if there's no PID file in the lock directory, something bad has
+  # happened.  We can't know the process name, so, clean up the old lockdir
+  # and restart.
   if [ ! -f $LOCKFILE ]; then
     rmdir $LOCKDIR 2>/dev/null
     echo "yum-cron: no lock PID, clearing and restarting myself" >&2
@@ -60,21 +85,21 @@ else
       exit 0
     fi
     if ! kill -0 $OTHERPID &>/dev/null; then
-      # lock is stale, remove it and restart
+      # Lock is stale. Remove it and restart.
       echo "yum-cron: removing stale lock of nonexistant PID ${OTHERPID}" >&2
       rm -rf "${LOCKDIR}"
       echo "yum-cron: restarting myself" >&2
       exec $0 "$@"
     else
-      # Remove stale (more than a day old) lockfiles
+      # Remove lockfiles more than a day old -- they must be stale.
       find $LOCKDIR -type f -name 'pidfile' -amin +1440 -exec rm -rf $LOCKDIR \;
-      # if it's still there, it wasn't too old, bail
+      # If it's still there, it *wasn't* too old. Bail!
       if [ -f $LOCKFILE ]; then
-        # lock is valid and OTHERPID is active - exit, we're locked!
+        # Lock is valid and OTHERPID is active -- exit, we're locked!
         echo "yum-cron: lock failed, PID ${OTHERPID} is active" >&2
         exit 0
       else
-        # lock was invalid, restart
+        # Lock was invalid. Restart.
         echo "yum-cron: removing stale lock belonging to stale PID ${OTHERPID}" >&2
         echo "yum-cron: restarting myself" >&2
         exec $0 "$@"
@@ -82,15 +107,23 @@ else
     fi
 fi
 
-# Now, do the actual work; we special case "update" because it has
-# complicated conditionals; for everything else we just run yum with the
-# right parameters and corresponding script.  Right now, that's just
-# "cleanup" but theoretically there could be other actions.
+# Now, do the actual work.
 
+# We special case "update" because it has complicated conditionals; for
+# everything else we just run yum with the right parameters and
+# corresponding script.  Right now, that's just "cleanup" but theoretically
+# there could be other actions.
 {
   case "$ACTION" in
     update)
+        # There's three broad possibilties here:
+        #   CHECK_ONLY (possibly with DOWNLOAD_ONLY)
+        #   CHECK_FIRST (exits _silently_ if we can't access the repos)
+        #   nothing special -- just do it
+        # Note that in all cases, yum is updated first, and then 
+        # everything else.
         if [ "$CHECK_ONLY" == "yes" ]; then
+          # TSLOCK is used by the safe-shutdown code in the init script.
           touch $TSLOCK
           /usr/bin/yum $YUM_PARAMETER -e 0 -d 0 -y check-update 1> /dev/null 2>&1
           case $? in
@@ -104,7 +137,9 @@ fi
                  ;;
           esac
         elif [ "$CHECK_FIRST" == "yes" ]; then
-          # Don't run if we can't access the repos
+          # Don't run if we can't access the repos -- if this is set, 
+          # and there's a problem, we exit silently (but return an error
+          # code).
           touch $TSLOCK
           /usr/bin/yum $YUM_PARAMETER -e 0 -d 0 check-update 2>&-
           case $? in
@@ -114,6 +149,7 @@ fi
                  ;;
           esac
         else
+          # and here's the "just do it".
           touch $TSLOCK
           /usr/bin/yum $YUM_PARAMETER -e ${ERROR_LEVEL:-0} -d ${DEBUG_LEVEL:-0} -y update yum
           /usr/bin/yum $YUM_PARAMETER -e ${ERROR_LEVEL:-0} -d ${DEBUG_LEVEL:-0} -y shell $YUMSCRIPT
@@ -127,10 +163,10 @@ fi
 } >> $YUMTMP 2>&1
 
 if [ ! -z "$MAILTO" ] && [ -x /bin/mail ]; then 
-# if MAILTO is set, use mail command (ie better than standard mail with cron output) 
+# If MAILTO is set, use mail command for prettier output.
   [ -s "$YUMTMP" ] && mail -s "System update: $SYSTEMNAME" $MAILTO < $YUMTMP 
 else 
-# default behavior is to use cron's internal mailing of output from cron-script
+# The default behavior is to use cron's internal mailing of output.
   cat $YUMTMP
 fi 
 rm -f $YUMTMP 
commit 2ae33b95314d80b411a103adb639f748f0d8ce02
Author: Matthew Miller <mattdm at mattdm.org>
Date:   Thu Jul 28 21:54:47 2011 -0400

    Add comments documenting options in sysconfig file.
    
    No changes to keys or values. File is reordered to group parameters by which
    part of the system they affect.

diff --git a/yum-cron/yum-cron.sysconfig b/yum-cron/yum-cron.sysconfig
index 5b40237..df1bcfc 100644
--- a/yum-cron/yum-cron.sysconfig
+++ b/yum-cron/yum-cron.sysconfig
@@ -1,64 +1,92 @@
-# Pass any given paramter to yum, as run in all the scripts invoked
-# by this package.  Be aware that this is global, and yum is invoked in 
-# several modes by these scripts for which your own parameter might not
-# be appropriate
+# This is the configuration file for yum-cron, a simple system for
+# keeping your machine up to date. These options are used variously by
+# the main script, by the cron scripts, and by the init script.
+
+# Main Options
+#--------------------------------------------------------------------------
+
+# Pass any given parameter to yum, as run in all the scripts invoked by
+# this package. Be aware that this is global, and yum is invoked in
+# several modes by these scripts, and your parameter might not be
+# appropriate in all cases.
 YUM_PARAMETER=
 
-# Don't install, just check (valid: yes|no)
+# Don't install; just check and report. 
+# (Valid options: yes|no)
 CHECK_ONLY=no
 
-# Check to see if you can reach the repos before updating (valid: yes|no)
+# Don't install; just check for and download any pending updates. This
+# implies CHECK_ONLY=yes, as we've gotta check first to see what to
+# download.
+# (Valid options: yes|no)
+DOWNLOAD_ONLY=no
+
+# Check to see if we can reach the repos before attempting an update.
+# If there is an error, exit silently with no output. You might want
+# this if you know your network connectivity is sporadic.
+# (Valid options: yes|no)
 CHECK_FIRST=no
 
-# Don't install, just check and download (valid: yes|no)
-# Implies CHECK_ONLY=yes (gotta check first to see what to download)
-DOWNLOAD_ONLY=no
 
-# Error level, practical range 0-10, 0 means print only critical errors which
-# you must be told, 1 means print all errors, even ones that are not important
-# Level 0 is the default
-# ERROR_LEVEL=0
-
-# Debug level, practical range 0-10, higher number means more output
-# Level 1 is a useful level if you want to see what's been done and
-# don't want to read /var/log/yum.log
-# Level 0 is the default
-# DEBUG_LEVEL=1
-
-# Wait a random time before applying updates.
-# With a value of 60, yum-cron will waits random time from 1 to 60 minutes.
-# The value must not be zero
-# Note that this parameter affects the daily cron script; if you change that
-# file or run yum-cron in a different way it will have no effect.
-RANDOMWAIT="60"
-
-# if MAILTO is set and the mail command is available, the mail command 
-# is used to deliver yum output
-
-# by default MAILTO is unset, so crond mails the output by itself
-# example:  MAILTO=root
-MAILTO= 
-
-# you may set SYSTEMNAME if you want your yum emails tagged differently
-# default is output of hostname command 
-# this variable is used only if MAILTO is set too
+# Yum error level. The practical range is 0-10, where 0 means print
+# only critical errors, and 10 means print all errors, even ones that
+# are not important. Level 0 is the default if nothing is set.
+ERROR_LEVEL=0
+
+# Yum debug level. The practical range is 0-10; a higher number means
+# more output. Level 1 is a useful level if you want to see what's been
+# done and don't want to read /var/log/yum.log. Level 0 is the default
+# if no value is set here.
+DEBUG_LEVEL=0
+
+# If MAILTO is set and the /bin/mail command is available, the mail
+# command is used to deliver yum output. If MAILTO is unset, crond will
+# send the output by itself, usually to root (but with a less useful
+# subject line).
+MAILTO=
+
+# The reports generated by this command generally use the hostname of
+# the system as reported by the hostname command. If you'd prefer to
+# use something else, you can set that here.
 #SYSTEMNAME="" 
 
-# you may set DAYS_OF_WEEK to the days of the week you want to run 
-# default is every day 
-# Note that this parameter affects the daily cron script; if you change that
-# file or run yum-cron in a different way it will have no effect.
+# Scheduling Options (used by the default cron scripts,
+# /etc/cron.daily/yum-cleanup.cron and /etc/cron.daily/yum-update.cron)
+# 
+#   Note that if you use a different cron configuration (for example,
+#   removing the default scripts and adding an entry in /etc/cron.d),
+#   these values will have no effect -- unless you read and act on them
+#   in your new configuration.
+#--------------------------------------------------------------------------
+
+# Wait for a random time up to the given number of minutes before
+# applying updates. With a value of 60, yum-cron will delay between 1
+# and 60 minutes. A value of 0 will result in no delay, which is handy
+# if you want to ensure that updates happen at a known time, but could
+# be bad for update servers to be hit by all clients at exactly the
+# same time.
+RANDOMWAIT=60
+
+# You may set DAYS_OF_WEEK to the numeric days of the week you want to
+# run, where 0 is Sunday and 6 is Saturday. The default is to run every
+# day.
 #DAYS_OF_WEEK="0123456" 
 
-# which day should it do cleanup on?  defaults to 0 (Sunday).  If this day isn't in the 
-# DAYS_OF_WEEK above, it'll never happen
-# Note that this parameter affects the daily cron script; if you change that
-# file or run yum-cron in a different way it will have no effect.
+# The cleanup task (which clears the package cache) can run on a subset
+# of the days above. (If the value chosen here doesn't appear in
+# DAYS_OF_WEEK, the cleanup task will never happen.)
 CLEANDAY="0"
 
-# set to yes to make the yum-cron service to wait for transactions to complete
+# Init System Options (used by /etc/init.d/yum-cron)
+#--------------------------------------------------------------------------
+
+# If SERVICE_WAITS is set to "yes", and a transaction is in progress
+# when the yum-cron service is stopped, the init script will wait 
+# up to SERVICE_WAIT_TIME seconds before killing the task. Without
+# this, system shutdown continues as normal, potentially breaking
+# in-progress transactions.
+# (Valid options: yes|no)
 SERVICE_WAITS=yes
 
-# set maximum time period (in seconds) for the yum-cron service to wait for
-# transactions to complete.  The default is 300 seconds (5 minutes)
+# 300 is the default.
 SERVICE_WAIT_TIME=300
commit c077f9e3d4ee0398b0a233408e243dfe73cb48dd
Author: Matthew Miller <mattdm at mattdm.org>
Date:   Thu Jul 28 21:54:46 2011 -0400

    Cosmetic changes to init script.
    
    No code changes. Added description in comments, changed "nightly" to
    "scheduled" in echoed statements.
    
    I also removed the "Author" line, out of no disrepect to Seth, but just
    'cause it's not in the Fedora spec for sysvinit files.

diff --git a/yum-cron/yum-cron.sysvinit b/yum-cron/yum-cron.sysvinit
index 63c5ec0..084dd32 100755
--- a/yum-cron/yum-cron.sysvinit
+++ b/yum-cron/yum-cron.sysvinit
@@ -1,12 +1,13 @@
 #!/bin/bash
 #
-# yum-cron           This shell script enables the automatic use of YUM
-#
-# Author:       Seth Vidal <skvidal at phy.duke.edu>
+# yum-cron      Enable or disable scheduled yum system updates.
 #
 # chkconfig:	- 50 01
 #
-# description:  Enable daily run of yum, a program updater.
+# description:  This controls whether yum-cron runs. If this service is \
+#               off, the yum-cron scripts in /etc/cron.daily exit \
+#               immediately; otherwise, they download and/or apply package \
+#               updates as configured in /etc/sysconfig/yum-cron.
 # processname:  yum-cron
 # config: /etc/yum/yum-daily.yum
 #
@@ -23,14 +24,14 @@ yumcronpid=/var/lock/yum-cron.lock/pidfile
 RETVAL=0
 
 start() {
-	echo -n $"Enabling nightly yum update: "
+	echo -n $"Enabling scheduled yum updates: "
 	touch "$lockfile" && success || failure
 	RETVAL=$?
 	echo
 }
 
 stop() {
-	echo -n $"Disabling nightly yum update: "
+	echo -n $"Disabling scheduled yum updates: "
 	if [ -f "$yumcronpid" -a "$SERVICE_WAITS" = "yes" ]; then
 	  yum_done=0
 	  if [ ! -f $tslock ]; then
@@ -39,7 +40,7 @@ stop() {
 	    yum_done=1
 	  fi
 	  if [ $yum_done -eq 0 ]; then
-	    echo -n $"Waiting for yum "
+	    echo -n $"Waiting for in-progress yum transaction "
 	    if [ -z "$SERVICE_WAIT_TIME" ]; then
 	      SERVICE_WAIT_TIME=300
 	    fi
@@ -87,10 +88,10 @@ case "$1" in
 	;;
   status)
 	if [ -f $lockfile ]; then
-		echo $"Nightly yum update is enabled."
+		echo $"Scheduled yum updates are enabled."
 		RETVAL=0
 	else
-		echo $"Nightly yum update is disabled."
+		echo $"Scheduled yum updates are disabled."
 		RETVAL=3
 	fi
 	;;
commit 6ff6cfa3ffe5501ec3794fbca31e0136de58554b
Author: Matthew Miller <mattdm at mattdm.org>
Date:   Thu Jul 28 21:54:45 2011 -0400

    Better comments for the cron scripts.
    
    No code changes -- everything is behind a "#".

diff --git a/yum-cron/yum-cleanup.cron.sh b/yum-cron/yum-cleanup.cron.sh
index 0842135..e38e80f 100755
--- a/yum-cron/yum-cleanup.cron.sh
+++ b/yum-cron/yum-cleanup.cron.sh
@@ -1,23 +1,26 @@
 #!/bin/bash
 
-# Only run if this flag file is set (by /etc/rc.d/init.d/yum-cron)
+# Only run if this flag is set. The flag is created by the yum-cron init
+# script when the service is started -- this allows one to use chkconfig and
+# the standard "service stop|start" commands to enable or disable yum-cron.
 if [[ ! -f /var/lock/subsys/yum-cron ]]; then
   exit 0
 fi
 
-# Grab config settings
+# Read configuration settings from the sysconfig directory.
 if [[ -f /etc/sysconfig/yum-cron ]]; then
   source /etc/sysconfig/yum-cron
 fi
 
-# Only run on certain days of the week 
+# Only run on certain days of the week, based on the
+# settings in the above-mentioned sysconfig file.
 dow=`date +%w` 
 DAYS_OF_WEEK=${DAYS_OF_WEEK:-0123456} 
 if [[ "${DAYS_OF_WEEK/$dow/}" == "${DAYS_OF_WEEK}" ]]; then 
   exit 0 
 fi 
 
-# And only _clean_ on a subset of that
+# And only _clean_ on a subset of the configured days.
 CLEANDAY=${CLEANDAY:-0}
 if [[ "${CLEANDAY/$dow/}" == "${CLEANDAY}" ]]; then
   exit 0
diff --git a/yum-cron/yum-update.cron.sh b/yum-cron/yum-update.cron.sh
index 1801a11..c439ad3 100755
--- a/yum-cron/yum-update.cron.sh
+++ b/yum-cron/yum-update.cron.sh
@@ -1,25 +1,28 @@
 #!/bin/bash
 
-# Only run if this flag file is set (by /etc/rc.d/init.d/yum-cron)
+# Only run if this flag is set. The flag is created by the yum-cron init
+# script when the service is started -- this allows one to use chkconfig and
+# the standard "service stop|start" commands to enable or disable yum-cron.
 if [[ ! -f /var/lock/subsys/yum-cron ]]; then
   exit 0
 fi
 
-# Grab config settings
+# Read configuration settings from the sysconfig directory.
 if [[ -f /etc/sysconfig/yum-cron ]]; then
   source /etc/sysconfig/yum-cron
 fi
 
-# Only run on certain days of the week 
+# Only run on certain days of the week, based on the
+# settings in the above-mentioned sysconfig file.
 dow=`date +%w` 
 DAYS_OF_WEEK=${DAYS_OF_WEEK:-0123456} 
 if [[ "${DAYS_OF_WEEK/$dow/}" == "${DAYS_OF_WEEK}" ]]; then 
   exit 0 
 fi 
 
-# Random wait
+# Wait a random number of minutes, again based on
+# the setting in the sysconfig file.
 [[ $RANDOMWAIT -gt 0 ]] && sleep $(( $RANDOM % ($RANDOMWAIT * 60) + 1 ))
 
 # Action!
 exec /usr/sbin/yum-cron update
-


More information about the Yum-commits mailing list