#!/bin/sh
update-rc.d ipmasq start 41 S . >/dev/null
if [ "$1" = "configure" ]; then
    case $2 in
    2*)    # version 2.x
	if [ -e /etc/ipmasq.conf ]; then
	    echo "The configuration file /etc/ipmasq.conf is no longer used and the"
	    echo "information it contains is determined automatically by ipmasq.  Should"
	    echo -n "I delete the file /etc/ipmasq.conf? [Y/n] "
	    read answer
	    case $answer in
		[Nn]*)	;;
		*)	rm -f /etc/ipmasq.conf;;
	    esac
	fi
	;;
    3.[01]*)    # version 3.0, 3.1.x
	if [ -e /etc/ipmasq.rules ]; then
	    echo "Should I move your /etc/ipmasq.rules into the /etc/ipmasq/rules"
	    echo -n "directory? [Y/n] "
	    read answer
	    case $answer in
		[Nn]*)	;;
		*)	mv /etc/ipmasq.rules /etc/ipmasq/rules/Z99ipmasqrules.rul;;
	    esac
	fi
	;;
    esac

    if [ ! -e /etc/ipmasq/ppp ]; then
	echo "Do you wish to have ipmasq recompute the firewall rules when"
	echo -n "pppd brings up or takes down a link? [Y/n] "
	read ppp
	case $ppp in
	    [Nn]*)  echo "This feature may be turned on by creating an empty file /etc/ipmasq/ppp";;
	    *)	    touch /etc/ipmasq/ppp
		    echo "This feature may be turned off by deleting the empty file /etc/ipmasq/ppp";;
	esac
	echo -n "Press ENTER to continue."
	read
    fi

    echo -n "Should I start IP Masquerading? [Y/n] "
    read startme
    case $startme in
	[Nn]*)	;;
	*)	/etc/init.d/ipmasq start;;
    esac
fi
