[Dextrose] [PATCH] [dextrose-updater] Check daily updates hourly

Aleksey Lim alsroot at member.fsf.org
Wed Jan 19 05:27:23 EST 2011


---
 rpms/dextrose-updater/dextrose-updater.spec |   11 +++++---
 rpms/dextrose-updater/sbin/dextrose-update  |   38 +++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/rpms/dextrose-updater/dextrose-updater.spec b/rpms/dextrose-updater/dextrose-updater.spec
index bce8cb7..9e6709f 100644
--- a/rpms/dextrose-updater/dextrose-updater.spec
+++ b/rpms/dextrose-updater/dextrose-updater.spec
@@ -1,6 +1,6 @@
 Name:	dextrose-updater	
 Version:	1
-Release:	6%{?dist}
+Release:	7%{?dist}
 Summary:	A yum based updater for sugar-dextrose. Updates the sugar-dextrose related packages automatically and emits dbus messages (for the sugar notification system, if installed)
 
 Group:		Applications/Updating
@@ -31,7 +31,7 @@ A yum based updater for sugar-dextrose. Updates the sugar-dextrose related packa
 %install
 rm -rf $RPM_BUILD_ROOT
 
-mkdir -p $RPM_BUILD_ROOT/{etc/sysconfig,etc/cron.daily,usr/sbin}
+mkdir -p $RPM_BUILD_ROOT/{etc/sysconfig,etc/cron.hourly,usr/sbin}
 install -m755 $RPM_BUILD_DIR/%{name}-%{version}/sbin/dextrose-update \
 $RPM_BUILD_ROOT/usr/sbin
 
@@ -39,7 +39,7 @@ install -m755 $RPM_BUILD_DIR/%{name}-%{version}/sysconfig/dextrose-update \
 $RPM_BUILD_ROOT/etc/sysconfig
 
 ln -s /usr/sbin/dextrose-update \
-$RPM_BUILD_ROOT/etc/cron.daily/dextrose-update
+$RPM_BUILD_ROOT/etc/cron.hourly/dextrose-update
 
 %clean
 rm -rf $RPM_BUILD_ROOT
@@ -51,9 +51,12 @@ rm -rf $RPM_BUILD_DIR/%{name}-%{version}
 
 /usr/sbin/dextrose-update
 /etc/sysconfig/dextrose-update
-/etc/cron.daily/dextrose-update
+/etc/cron.hourly/dextrose-update
 
 %changelog
+* Wed Jan 19 2011 Aleksey Lim <alsroot at member.fsf.org> 1-7
+- Check daily updates hourly.
+
 * Mon Jan 10 2011 Anish Mangal <anish at sugarlabs.org> 1-6
 - Remove dextrose-py and change path of config file from /etc/default to /etc/sysconfig.
 
diff --git a/rpms/dextrose-updater/sbin/dextrose-update b/rpms/dextrose-updater/sbin/dextrose-update
index f6db502..0b682d5 100755
--- a/rpms/dextrose-updater/sbin/dextrose-update
+++ b/rpms/dextrose-updater/sbin/dextrose-update
@@ -5,6 +5,44 @@ name="dextrose-update"
 
 logfile="/var/log/${name}"
 
+while [ -n "$1" ] ; do
+    arg=$1
+    shift
+    case ${arg} in
+      	-f | --force)
+            force=1
+            ;;
+      	-h | --help)
+            echo "Usage: $0 [OPTION]"
+            echo ""
+            echo "Dextrose yum updater."
+            echo ""
+            echo "Options:"
+            echo "  -f, --force     update regarless already made daily check"
+            echo "  -h, --help      display this help and exit"
+            echo ""
+            echo "Configuration files:"
+            echo "  /etc/sysconfig/${name}"
+            echo ""
+            exit 0
+            ;;
+        *)
+            echo "Unknown argument $1"
+            exit 1
+            ;;
+    esac
+done
+
+if [ -z "${force}" -a -f ${logfile} ]; then
+    current_ts=$(date +%F)
+    check_ts=$(ls ${logfile} -l --time-style=+%F | awk '{print $6}')
+
+    if [ ${current_ts} == ${check_ts} ]; then
+        echo "Daily check already happened, pass --force to ignore it."
+        exit 0
+    fi
+fi
+
 echo "$(date)" >> $logfile
 echo -e "\tRepositories:" ${DEXTROSE_YUM_REPO} >> $logfile
 
-- 
1.7.3.4



More information about the Dextrose mailing list