#!/bin/sh -e

# Source the debconf library only because it ensures our config script is
# run.
. /usr/share/debconf/confmodule

db_get debconf/preconfig
if [ "$RET" = "true" ]; then
	if [ ! -e /etc/apt/apt.conf ]; then
		mkdir -p /etc/apt/ 2>/dev/null || true
		touch /etc/apt/apt.conf
	fi
	if ! grep -q "dpkg-preconfigure --apt" /etc/apt/apt.conf; then
		echo '// Pre-configure all packages before they are installed.' >> /etc/apt/apt.conf
		echo "// (Automatically added by debconf.)" >> /etc/apt/apt.conf
		echo 'DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};' >> /etc/apt/apt.conf
	fi
fi

# Make sure the directory has safe permissions.
chmod 700 /var/lib/debconf

#DEBHELPER#
