#!/bin/sh
. /etc/sysconfig/network

echo "Setting up ethernet"
/sbin/modprobe pcmcia_core
/sbin/modprobe i82365
/sbin/modprobe ds
/sbin/cardmgr
. /var/smoothwall/ethernet/settings

echo "Setting up ISDN"
. /etc/rc.d/rc.isdn

modprobe ppp

echo "Setting up loopback"
ifconfig lo localhost up

echo "Loading MASQ helper modules"
modprobe ip_masq_quake
modprobe ip_masq_irc
modprobe ip_masq_ftp
modprobe ip_masq_icq

# Remove possible leftover files
rm -f /var/smoothwall/red/*

for NIC in 0 1 2; do
	ETHX="eth${NIC}"
	if [ "$GREEN_DEV" = "$ETHX" ]; then
		if [ "$GREEN_DRIVER" != "" ]; then
			modprobe $GREEN_DRIVER $GREEN_DRIVER_OPTIONS
		fi
	fi
	if [ "$ORANGE_DEV" = "$ETHX" ]; then
		if [ "$ORANGE_DRIVER" != "" ]; then
			modprobe $ORANGE_DRIVER $ORANGE_DRIVER_OPTIONS
		fi
	fi
	if [ "$RED_DEV" = "$ETHX" ]; then
		if [ "$RED_DRIVER" != "" ]; then
			modprobe $RED_DRIVER $RED_DRIVER_OPTIONS
		fi
	fi
done

# Forwarding.  This is set here to shutup warnings from ipchains.
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/ip_always_defrag
echo 1 > /proc/sys/net/ipv4/ip_dynaddr
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses

echo "Bringing network up"
. /etc/rc.d/rc.netaddress.up

echo "Building inital network traffic graphs"
. /usr/local/bin/makegraphs

if [ "$RED_DEV" != "" ]; then
	echo "Registering this SmoothWall (background)"
#	/etc/rc.d/rc.machineregister &
fi