[PATCH 1/3] copy yum-cron.{service,sysvinit} to yum-cron-hourly.
Zdenek Pavlas
zpavlas at redhat.com
Wed Jan 15 09:34:06 UTC 2014
---
yum-cron/yum-cron-hourly.service | 11 ++++
yum-cron/yum-cron-hourly.sysvinit | 108 ++++++++++++++++++++++++++++++++++++++
2 files changed, 119 insertions(+)
create mode 100644 yum-cron/yum-cron-hourly.service
create mode 100644 yum-cron/yum-cron-hourly.sysvinit
diff --git a/yum-cron/yum-cron-hourly.service b/yum-cron/yum-cron-hourly.service
new file mode 100644
index 0000000..82f3e6b
--- /dev/null
+++ b/yum-cron/yum-cron-hourly.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Run automatic yum updates as a cron job
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/bin/touch /var/lock/subsys/yum-cron
+ExecStop=/bin/rm -f /var/lock/subsys/yum-cron
+
+[Install]
+WantedBy=multi-user.target
diff --git a/yum-cron/yum-cron-hourly.sysvinit b/yum-cron/yum-cron-hourly.sysvinit
new file mode 100644
index 0000000..ee531c6
--- /dev/null
+++ b/yum-cron/yum-cron-hourly.sysvinit
@@ -0,0 +1,108 @@
+#!/bin/bash
+#
+# yum-cron Enable or disable scheduled yum system updates.
+#
+# chkconfig: - 50 01
+#
+# 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
+#
+
+# source function library
+. /etc/rc.d/init.d/functions
+
+test -f /etc/sysconfig/yum-cron && . /etc/sysconfig/yum-cron
+
+lockfile=/var/lock/subsys/yum-cron
+
+# This is generated by /usr/sbin/yum-cron and will exist when that script
+# is running and not otherwise.
+pidfile=/var/lock/yum-cron.pid
+
+RETVAL=0
+
+start() {
+ echo -n $"Enabling scheduled yum updates: "
+ # The cron script exits silently if this file doesn't exist.
+ touch "$lockfile" && success || failure
+ RETVAL=$?
+ echo
+}
+
+stop() {
+ # Disabling this is just removing the so-called lock file. But we
+ # also have logic to delay shutdown if a transaction is in-progress.
+ # All that affects is the exit of _this_ script, which may be
+ # waited on by other things in the shutdown process.
+ echo -n $"Disabling scheduled yum updates: "
+ if [ "$SERVICE_WAITS" = "yes" ]; then
+ # if SERVICE_WAITS is yes, we check for an active pid
+ # file and recheck in 5 second increments up to
+ # SERVICE_WAIT_TIME before continuing.
+ if (set -o noclobber; ! echo "$$" > $pidfile ) 2>/dev/null; then
+ # yum-cron has the lock. Read the pid, and wait and then loop
+ # until it's done.
+ activepid="$(< $pidfile)" 2>/dev/null
+ if [ $? != 0 ]; then
+ echo; echo -n $"Stale yum-cron lock ignored. "
+ else
+ echo; echo -n $"Waiting for in-progress yum transaction"
+ end=$( expr $( date +%s ) + ${SERVICE_WAIT_TIME:-300} )
+ while checkpid $activepid 2>/dev/null ; do
+ echo -n "."
+ if [ $( date +%s ) -gt $end ]; then
+ echo -n " Timed out. "
+ break
+ fi
+ sleep 5
+ done
+ fi
+ else
+ # we got the lock. we don't really want it; remove and move on.
+ rm -f "$pidfile"
+ fi
+ fi
+ rm -f "$lockfile" && success || failure
+ RETVAL=$?
+ echo
+}
+
+restart() {
+ stop
+ start
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart|force-reload)
+ restart
+ ;;
+ reload)
+ ;;
+ condrestart)
+ [ -f "$lockfile" ] && restart
+ ;;
+ status)
+ if [ -f $lockfile ]; then
+ echo $"Scheduled yum updates are enabled."
+ RETVAL=0
+ else
+ echo $"Scheduled yum updates are disabled."
+ RETVAL=3
+ fi
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
+ exit 1
+esac
+
+exit $RETVAL
--
1.7.11.7
More information about the Yum-devel
mailing list