]> git.saurik.com Git - apt.git/commitdiff
* debian/apt.cron.daily:
authorMichael Vogt <michael.vogt@ubuntu.com>
Mon, 25 Feb 2008 18:08:19 +0000 (18:08 +0000)
committerMichael Vogt <michael.vogt@ubuntu.com>
Mon, 25 Feb 2008 18:08:19 +0000 (18:08 +0000)
  - sleep random amount of time (default within 0-30min) before
    starting the upate to hit the mirrors less hard

debian/apt.cron.daily
debian/changelog

index 7af689e1f670474dc7a93706538ca78759ec69f0..ec53a7f2f73b10c92044df358e91211cfd4390d8 100644 (file)
@@ -147,6 +147,25 @@ check_size_constraints()
     fi
 }
 
+# sleep for a random intervall of time (default 30min)
+# (some code taken from cron-apt, thanks)
+random_sleep()
+{
+    RandomSleep=1800
+    eval $(apt-config shell RandomSleep APT::Periodic::RandomSleep)
+    if [ $RandomSleep -eq 0 ]; then
+       return
+    fi
+    if [ -z "$RANDOM" ] ; then
+        # A fix for shells that do not have this bash feature.
+       RANDOM=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -c"1-5")
+    fi
+    TIME=$(($RANDOM % $RandomSleep))
+    sleep $TIME
+}
+
+# main
+
 if ! which apt-config >/dev/null; then
        exit 0
 fi
@@ -179,6 +198,13 @@ if ! apt-get check -q -q 2>/dev/null; then
     exit 1
 fi
 
+# sleep random amount of time
+random_sleep
+
+# check again if we can access the cache
+if ! apt-get check -q -q 2>/dev/null; then
+    exit 1
+fi
 
 UPDATE_STAMP=/var/lib/apt/periodic/update-stamp
 if check_stamp $UPDATE_STAMP $UpdateInterval; then
index 2c685b087ee6d9a3c4f2f1123f7c6174f204f4ec..b6b0ac835f251101a3d675d6697482acc5cee7b0 100644 (file)
@@ -17,6 +17,9 @@ apt (0.7.12) UNRELEASED; urgency=low
       is run
   * methods/connect.cc:
     - remember hosts with Resolve failures or connect Timeouts
+  * debian/apt.cron.daily:
+    - sleep random amount of time (default within 0-30min) before
+      starting the upate to hit the mirrors less hard
 
   [ Christian Perrier ]
   * Fix typos in manpages. Thanks to Daniel Leidert for the fixes