#!/bin/sh
set -e

case "$1" in
    configure)
	install-info --description='Linux floppy utilities' \
	    --section "Disk Management" "Disk Management" \
	    --quiet /usr/info/fdutils.info.gz

	if command -v install-docs >/dev/null 2>&1; then
	    install-docs -i /usr/share/doc-base/fdutils
	    install-docs -i /usr/share/doc-base/fdutils-faq
	fi



	if dpkg --compare-versions "$2" lt "5.2.0.1998-07-01-3"; then
	    /usr/sbin/fdutilsconfig
	    echo
	    echo "Please note that you can run '/usr/sbin/fdutilsconfig' to change"
	    echo "fdmount setuid root settings."
	else
	    if grep -q "is_suid=yes" /etc/fdmount.conf; then
		if [ -e /etc/suid.conf -a -x /usr/sbin/suidregister ]; then
		    suidregister -s fdutils /usr/bin/fdmount root root 4755
		else
		    chown root.root /usr/bin/fdmount
		    chmod 4755 /usr/bin/fdmount
		fi
	    fi
	    echo "Keeping old fdmount setuid root settings.  Please note that"
	    echo "you can run '/usr/sbin/fdutilsconfig' to change them."
	fi

	if [ -e "/etc/fdprm" ]; then
	    echo " Fdutils-5.0 introduced two new configuration files: /etc/mediaprm and"
	    echo " /etc/driveprm.  They replace the old /etc/fdprm."
	    echo " Renaming old file /etc/fdprm to /etc/fdprm.obsolete ..."
	    mv -f /etc/fdprm /etc/fdprm.obsolete
	    echo
	fi

	# echo ' Running "/dev/MAKEDEV floppy-all" ...'
	# cd /dev && ./MAKEDEV floppy-all

	echo ' Running "/usr/sbin/MAKEFLOPPIES -g" ...'
	/usr/sbin/MAKEFLOPPIES -g

cat <<END
 If you prefer, you might like to run "/usr/sbin/MAKEFLOPPIES -g" or
 "/dev/MAKEDEV floppy-all" to (re-)create /dev/fd* floppy device files.

 Note: /usr/bin/fdformat is obsolete and is no longer available.
       Please use /usr/bin/superformat instead.  Also, there had been some
       major changes from version 4.x.  Please refer to the documentation.
END
	;;

    abort-upgrade|abort-remove|abort-deconfigure)
	;;
    *)
	echo "postinst called with unknown argument \`$1'" >&2
	;;
esac
