Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / var / lib / dpkg / info / | server ip : 104.21.89.46 your ip : 172.70.126.107 H O M E |
Filename | /var/lib/dpkg/info/popularity-contest.postinst |
Size | 3.58 kb |
Permission | rwxr-xr-x |
Owner | root : root |
Create time | 27-Apr-2025 09:55 |
Last modified | 13-May-2013 18:06 |
Last accessed | 06-Jul-2025 22:16 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
#!/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 [ -x /usr/bin/uuidgen ] ; then
MY_HOSTID=`uuidgen | tr -d -`
else
MY_HOSTID=`dd if=/dev/urandom bs=1k count=1 2>/dev/null | md5sum | sed 's/ -//'''`
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_conffile() {
generate_id
select_random_day
cat <<-EOF >$conffile
# Config file for Debian's popularity-contest package.
#
# To change this file, use:
# dpkg-reconfigure popularity-contest
#
# You can also edit it by hand, if you so choose.
#
# See /usr/share/popularity-contest/default.conf for more info
# on the options.
MY_HOSTID="$MY_HOSTID"
PARTICIPATE="$PARTICIPATE"
USEHTTP="yes"
DAY="$DAY"
EOF
# preseeding is only allowed on first time install
db_get popularity-contest/submiturls || true
if [ -n "$RET" ] ; then
echo "SUBMITURLS=\"$RET\"" >> $conffile
fi
# Make sure user nobody can read the file.
chmod a+r $conffile
}
case "$1" in
configure)
if [ ! -e $conffile ]; then
generate_conffile
else
# If MY_HOSTID is not set, add it. This is useful when disk images are prepared
if [ -z "$MY_HOSTID" ] ; then
generate_id
echo "MY_HOSTID=\"$MY_HOSTID\"" >> $conffile
fi
OLDHOSTID="$MY_HOSTID";
case "$MY_HOSTID" in
# Workaround for bug #237874 triggered on hurd. The
# problem was fixed in version 1.15, 2004-03-20.
$EMPTYID) generate_id;;
# Workaround for bug #240603 triggered by md5sums change
# of behaviour with stdin. version 1.17, 2004-04-12.
*-) MY_HOSTID="${MY_HOSTID% -}";;
esac;
# If DAY is not set, add it.
if [ -z "$DAY" ] ; then
select_random_day
echo "DAY=\"$DAY\"" >> $conffile
fi
# Replace only if the content changed, to avoid changing the
# config file date when no change was done.
# Commenting out the obsolete addresses, to use the
# default config from /usr/share/ on hosts where
# the old default was unchanged. Replace the "empty" id.
sedopts=" \
s/^PARTICIPATE=.*$/PARTICIPATE=\"$PARTICIPATE\"/; \
s/^\(MAILTO=\"[email protected]\"\)$/#\1/; \
s/^\(MAILTO=\"[email protected]\"\)$/#\1/; \
s/^\(MAILTO=\"[email protected]\"\)$/#\1/; \
"
if [ "$OLDHOSTID" != "$MY_HOSTID" ]; then
sedopts="$sedopts \
s/^MY_HOSTID=\"\\?$OLDHOSTID\"\\?/MY_HOSTID=\"$MY_HOSTID\"/; \
"
fi
if sed "$sedopts" < $conffile > $conffile.new &&
! cmp $conffile $conffile.new > /dev/null; then
mv $conffile.new $conffile
# Make sure user nobody can read the file.
chmod a+r $conffile
else
rm $conffile.new
fi
fi
;;
*)
;;
esac
# 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 [ -x /usr/bin/uuidgen ] ; then
MY_HOSTID=`uuidgen | tr -d -`
else
MY_HOSTID=`dd if=/dev/urandom bs=1k count=1 2>/dev/null | md5sum | sed 's/ -//'''`
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_conffile() {
generate_id
select_random_day
cat <<-EOF >$conffile
# Config file for Debian's popularity-contest package.
#
# To change this file, use:
# dpkg-reconfigure popularity-contest
#
# You can also edit it by hand, if you so choose.
#
# See /usr/share/popularity-contest/default.conf for more info
# on the options.
MY_HOSTID="$MY_HOSTID"
PARTICIPATE="$PARTICIPATE"
USEHTTP="yes"
DAY="$DAY"
EOF
# preseeding is only allowed on first time install
db_get popularity-contest/submiturls || true
if [ -n "$RET" ] ; then
echo "SUBMITURLS=\"$RET\"" >> $conffile
fi
# Make sure user nobody can read the file.
chmod a+r $conffile
}
case "$1" in
configure)
if [ ! -e $conffile ]; then
generate_conffile
else
# If MY_HOSTID is not set, add it. This is useful when disk images are prepared
if [ -z "$MY_HOSTID" ] ; then
generate_id
echo "MY_HOSTID=\"$MY_HOSTID\"" >> $conffile
fi
OLDHOSTID="$MY_HOSTID";
case "$MY_HOSTID" in
# Workaround for bug #237874 triggered on hurd. The
# problem was fixed in version 1.15, 2004-03-20.
$EMPTYID) generate_id;;
# Workaround for bug #240603 triggered by md5sums change
# of behaviour with stdin. version 1.17, 2004-04-12.
*-) MY_HOSTID="${MY_HOSTID% -}";;
esac;
# If DAY is not set, add it.
if [ -z "$DAY" ] ; then
select_random_day
echo "DAY=\"$DAY\"" >> $conffile
fi
# Replace only if the content changed, to avoid changing the
# config file date when no change was done.
# Commenting out the obsolete addresses, to use the
# default config from /usr/share/ on hosts where
# the old default was unchanged. Replace the "empty" id.
sedopts=" \
s/^PARTICIPATE=.*$/PARTICIPATE=\"$PARTICIPATE\"/; \
s/^\(MAILTO=\"[email protected]\"\)$/#\1/; \
s/^\(MAILTO=\"[email protected]\"\)$/#\1/; \
s/^\(MAILTO=\"[email protected]\"\)$/#\1/; \
"
if [ "$OLDHOSTID" != "$MY_HOSTID" ]; then
sedopts="$sedopts \
s/^MY_HOSTID=\"\\?$OLDHOSTID\"\\?/MY_HOSTID=\"$MY_HOSTID\"/; \
"
fi
if sed "$sedopts" < $conffile > $conffile.new &&
! cmp $conffile $conffile.new > /dev/null; then
mv $conffile.new $conffile
# Make sure user nobody can read the file.
chmod a+r $conffile
else
rm $conffile.new
fi
fi
;;
*)
;;
esac