#!/bin/sh -e
# post install script for the Debian modutils package

pkg=modutils
CFGFILE="/etc/modules.conf"
HEADER="### This file is automatically generated by update-modules"

set -e

if [ ! "$1" = "configure" ]; then
	exit 0
fi

# Create /var/log/ksymoops if this is an intial install. This allows
# a user to remove it to disable logging later on
if [ -z "$2" -a ! -d /var/log/ksymoops ] ; then
	mkdir /var/log/ksymoops
	chmod 755 /var/log/ksymoops
fi

# Create the /etc/modules file if it does not exist
if [ ! -e /etc/modules ] ; then
	cat <<EOF > /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file should contain the names of kernel modules that are
# to be loaded at boot time, one per line.  Comments begin with
# a "#", and everything on the line after them are ignored.

EOF
	chmod 644 /etc/modules
fi

# If $CFGFILE exists and is not generated print a big fat
# warning and inform people about the new system
if [ -f $CFGFILE ] && ! head -n1 $CFGFILE | grep -q "^$HEADER" ; then
	cat <<EOF

WARNING: you already have an $CFGFILE file which has not
been generated by update-modules. Debian now uses a new system which
uses multiple files in the /etc/modutils directory. See the manpage
for update-modules for more information on this setup.

Please check all changes you made in $CFGFILE and either
apply them to the provided files in /etc/modutils or add your own
files there. Then run update-modules.

EOF
	echo -n "Press [ENTER] to continue"
	read HITME
else
	update-modules
fi

exit 0

