se505-buildsystem/stage2.skel/etc/init.d/S10network.sh

97 lines
1.6 KiB
Bash
Executable File

# start up network
[ "$NETWORK" != "yes" ] && exit 0
# loading needed drivers
insmod et
insmod wl
# starting devices
ifconfig eth0 up
ifconfig eth1 up
# create vlans
insmod 8021q
vconfig add eth0 0
vconfig add eth0 1
ifconfig eth0.0 up
ifconfig eth0.1 up
# create bridge on demand
if [ "$BRIDGE" != "" ]; then
insmod bridge
brctl addbr br0
brctl stp br0 off
brctl setfd br0 2
ifconfig br0 up
else
NET_BRIDGE=""
fi
# enslave bridge devices
for dev in $BRIDGE; do
case "$dev" in
LAN) echo "adding eth0.0 to br0"
NET_LAN=""
brctl addif br0 eth0.0
;;
WAN) echo "adding eth0.1 to br0"
NET_WAN=""
brctl addif br0 eth0.1
;;
WLAN) echo "adding eth1 to br0"
NET_WLAN=""
brctl addif br0 eth1
;;
*)
;;
esac
done
if [ "$NET_BRIDGE" != "" ]; then
echo "Setting up br0"
if [ "$NET_BRIDGE" = "dhcp" ]; then
DEFAULTGW=""
udhcpc -i br0 -b -q -s /etc/udhcpc.sh
else
ifconfig br0 $NET_BRIDGE up
fi
fi
if [ "$NET_LAN" != "" ]; then
echo "Setting up eth0.0"
if [ "$NET_LAN" = "dhcp" ]; then
DEFAULTGW=""
udhcpc -i eth0.0 -b -q -s /etc/udhcpc.sh
else
ifconfig eth0.0 $NET_LAN up
fi
fi
if [ "$NET_WAN" != "" ]; then
echo "Setting up eth0.1"
if [ "$NET_WAN" = "dhcp" ]; then
DEFAULTGW=""
udhcpc -i eth0.1 -b -q -s /etc/udhcpc.sh
else
ifconfig eth0.1 $NET_WAN up
fi
fi
if [ "$NET_WLAN" != "" ]; then
echo "Setting up eth1"
if [ "$NET_WLAN" = "dhcp" ]; then
DEFAULTGW=""
udhcpc -i eth1 -b -q -s /etc/udhcpc.sh
else
ifconfig eth1 $NET_WLAN up
fi
fi
if [ "$DEFAULTGW" != "" ]; then
echo "Setting up default gateway"
route add default gw $DEFAULTGW
fi