aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2007-10-12 15:53:48 +0000
committerPetter Reinholdtsen <pere@hungry.com>2007-10-12 15:53:48 +0000
commit5d325d6c4049ebd1a93a2beb925d22e82d8233af (patch)
tree034741bf0124007c737bc4b41a986884fd4d8ab8
parent07bd61e122a7e79ff965a594bbfc63e691a89abe (diff)
downloadsitesummary-5d325d6c4049ebd1a93a2beb925d22e82d8233af.tar.gz
sitesummary-5d325d6c4049ebd1a93a2beb925d22e82d8233af.tar.bz2
sitesummary-5d325d6c4049ebd1a93a2beb925d22e82d8233af.tar.xz
* Move random sleep from the report script and into the cron script,
to make it possible to report imediately from a client.
-rw-r--r--debian/changelog2
-rw-r--r--debian/sitesummary-client.cron.daily32
-rw-r--r--sitesummary-client15
3 files changed, 33 insertions, 16 deletions
diff --git a/debian/changelog b/debian/changelog
index 5821205..9289246 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,8 @@ sitesummary (0.0.28) unstable; urgency=low
[ Petter Reinholdtsen ]
* Make sure the server cron job handle a removed but not purged
package. (Closes: #445604)
+ * Move random sleep from the report script and into the cron script,
+ to make it possible to report imediately from a client.
-- Petter Reinholdtsen <pere@debian.org> Fri, 12 Oct 2007 17:44:02 +0200
diff --git a/debian/sitesummary-client.cron.daily b/debian/sitesummary-client.cron.daily
index 9852f8b..5a94bed 100644
--- a/debian/sitesummary-client.cron.daily
+++ b/debian/sitesummary-client.cron.daily
@@ -2,5 +2,35 @@
#
# Author: Petter Reinholdtsen
+[ -x /usr/sbin/sitesummary-client ] || exit 0
+
+# Read the package default. Make sure this is identical to the code
+# in sitesummar-client
+[ -f /usr/share/sitesummary/sitesummary-client.conf ] && \
+ . /usr/share/sitesummary/sitesummary-client.conf
+for confdir in \
+ /usr/share/sitesummary/config.d \
+ /etc/sitesummary/config.d
+do
+ [ -d $confdir ] || continue
+ for config in $confdir/* ; do
+ [ -f $config ] && . $config
+ done
+done
+
+# Sleep a random number of seconds to avoid all clients connecting to
+# the server at the same time. Based on code from the cron-apt
+# package.
+if [ -n "$runsleep" ] ; then
+ if [ $runsleep -gt 0 ] ; then
+ 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 % $runsleep))
+ sleep $TIME
+ fi
+fi
+
# Run once a day to report the whereabouts of the machine
-[ -x /usr/sbin/sitesummary-client ] && nice /usr/sbin/sitesummary-client
+nice /usr/sbin/sitesummary-client
diff --git a/sitesummary-client b/sitesummary-client
index 44e416b..9e53e1f 100644
--- a/sitesummary-client
+++ b/sitesummary-client
@@ -53,21 +53,6 @@ do
done
done
-# Sleep a random number of seconds to avoid all clients connecting to
-# the server at the same time. Based on code from the cron-apt
-# package.
-if [ -n "$runsleep" ] ; then
- if [ $runsleep -gt 0 ] ; then
- 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 % $runsleep))
- sleep $TIME
- fi
-fi
-
-
mkdir $tmpdir && cd $tmpdir
for fragdir in $fragdirs ; do