#!/bin/sh

set -e

pkg=$(basename $0 .postinst)

if [ "$1" = "configure" ]; then
	test -e /etc/lvmtab || touch /etc/lvmtab
	test -x /usr/sbin/update-devfsd && /usr/sbin/update-devfsd
	update-modules

	if [ -d /usr/doc -a ! -e /usr/doc/$pkg -a -d /usr/share/doc/$pkg ] ; then
		ln -s ../share/doc/$pkg /usr/doc/$pkg
	fi

	update-rc.d lvm start 25 S . start 50 0 6 . > /dev/null
	/usr/sbin/lvm-bin-scan
fi

# older versions had '/etc/cron.d/lvm', which wasn't removed.
# Check for this on upgrade, and remove it.
if [ "$1" = "upgrade" ]; then
	if [ -e /etc/cron.d/lvm ] ; then
		rm -f /etc/cron.d/lvm
	fi
fi

# if upgrading, and '/etc/cron.d/lvm-common' exists, remove it.
if [ "$1" = "upgrade" ]; then
	if [ -e /etc/cron.d/lvm-common ] ; then
		rm -f /etc/cron.d/lvm-common
	fi
fi

exit 0

