#!/bin/sh -e

case "$1" in
    configure)
	. /usr/share/debconf/confmodule

	db_get ipod/ipaddress
	ipaddress="$RET"
	db_get ipod/mountpoint
	mountpoint="$RET"

	if [ "x$mountpoint" != "x" ]; then
	    if [ ! -d "$mountpoint" ]; then
	        mkdir -p $mountpoint
	    fi

	    chown root:fuse $mountpoint
	    chmod 775 $mountpoint
        fi	

	sed -i -e "
		s|^\(IPADDRESS\)=.*|\1=\"$ipaddress\"|;
		s|^\(MOUNTPOINT\)=.*|\1=\"$mountpoint\"|;
	" /etc/default/ipod-convenience

	;;
    abort-upgrade|abort-remove|abort-deconfigure)

	;;

    *)
	echo "postinst called with unknown argument \`$1'" >&2
	exit 1
	;;
esac

#DEBHELPER#

exit 0
