#-----------------------------------------------------------------------------
# /etc/rc.d/masq - install masquerading modules
#
# Creation:	31.03.2000  fm
# Last Update:  23.09.2001  od
#-----------------------------------------------------------------------------

/usr/local/bin/colecho "installing masquerading modules ..." gn

if [ "$MASQ_DO_DEBUG" = yes ]
then
    set -x
fi

idx=1

while [ "$idx" -le "$MASQ_MODULE_N" ]	    # masquerading modules (ftp etc)
do
    eval drv='$MASQ_MODULE_'$idx

    case "$drv"
    in
        "udp_dloose")
            echo 1 > /proc/sys/net/ipv4/ip_masq_udp_dloose
            ;;
        "ftp")
            options=""
            delim="ports="
            port_idx=1
            while [ "$port_idx" -le "$MASQ_FTP_PORT_N" ]
            do
                eval newport='$MASQ_FTP_PORT_'$port_idx
                options="$options$delim$newport"
                delim=","
                port_idx=`/usr/bin/expr $port_idx + 1`
            done

            delim=" in_ports="
            port_idx=1
            while [ "$port_idx" -le "$MASQ_FTP_IN_PORT_N" ]
            do
                eval newport='$MASQ_FTP_IN_PORT_'$port_idx
                options="$options$delim$newport"
                delim=","
                port_idx=`/usr/bin/expr $port_idx + 1`
            done

            /sbin/insmod ip_masq_ftp $options
            ;;
        *)
            /sbin/insmod ip_masq_$drv
            ;;
    esac

    idx=`/usr/bin/expr $idx + 1`
done

set +x
