summaryrefslogtreecommitdiff
path: root/debian/apt.cron.daily
diff options
context:
space:
mode:
authorMichael Vogt <egon@bottom>2008-03-14 15:22:48 +0100
committerMichael Vogt <egon@bottom>2008-03-14 15:22:48 +0100
commitd2f3195a03a718ffb56924282727700f02ca9c49 (patch)
tree33f33e7218de1dd271266dc4984356e1821597c8 /debian/apt.cron.daily
parent2658c8073dfb92db9fa70dae39d93c6e5989f158 (diff)
parent85bd111a9b0778ba6e2b8950d369aeca192f9555 (diff)
* merge from the mvo branch
Diffstat (limited to 'debian/apt.cron.daily')
-rw-r--r--debian/apt.cron.daily26
1 files changed, 26 insertions, 0 deletions
diff --git a/debian/apt.cron.daily b/debian/apt.cron.daily
index 7af689e1f..ec53a7f2f 100644
--- a/debian/apt.cron.daily
+++ b/debian/apt.cron.daily
@@ -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