#!/bin/sh
# Load debconf variables
. /usr/share/debconf/confmodule
conffile=/etc/popularity-contest.conf
set -e
if [ -e $conffile ] ; then
# Fetch current values.
. $conffile
fi
# Get this setting from debconf. It was set based on the content of
# /etc/popularity-contest.conf in the 'config' script, so it should be
# safe to ignore the value fetched by loading the file above. This
# should allow for using debconf to reconfigure the package.
db_get popularity-contest/participate || true
if [ "$RET" = "yes" ] || [ "$RET" = "YES" ] || [ "$RET" = "true" ]; then
PARTICIPATE="yes"
else
PARTICIPATE="no"
fi
# The md5 sum of an empty file
EMPTYID="d41d8cd98f00b204e9800998ecf8427e"
generate_id() {
if which uuidgen >/dev/null 2>&1; then
MY_HOSTID=`uuidgen -r | tr -d -`
elif test -r /proc/sys/kernel/random/uuid; then
MY_HOSTID=`tr -d - < /proc/sys/kernel/random/uuid`
else
MY_HOSTID=`od -x -An -N16 /dev/urandom | tr -d ' '`
fi;
}
# Select a random day to submit on, to spread the load over time, unless it is already set.
select_random_day() {
DAY=`bash -c 'echo $(($RANDOM % 7))'`
}
generate_crond() {
MIN=`bash -c 'echo $(($RANDOM % 60))'`
HOUR=`bash -c 'echo $(($RANDOM % 24))'`
FILE=/etc/cron.daily/popularity-contest
cat > /etc/cron.d/popularity-contest <