#!/bin/sh
########################################################################
# Begin $network_devices/services/ipv4-static
#
# Description : IPV4 Static Boot Script
#
# Authors     : Nathan Coulson - nathan@linuxfromscratch.org
#		Kevin P. Fleming - kpfleming@linuxfromscratch.org
#
# Version     : 00.00
#
# Notes       :
#
########################################################################

. /etc/sysconfig/rc 
. ${rc_functions} 
. ${IFCONFIG}

if [ -n "${INTERFACE}" ]; then
	boot_mesg "INTERFACES variable missing from ${ifconfig},", ${FAILURE}
	echo_failure
	exit 1
fi

case "${2}" in
	up)
		boot_mesg "Creating the ${1} interface..."
		brctl addbr ${1}
		evaluate_retval
		for X in ${INTERFACES}; do
			boot_mesg "Adding ${X} to ${1}..."
			ip addr add 0.0.0.0 dev ${X} &&
			ip link set ${X} up &&
			brctl addif ${1} ${X}
			evaluate_retval
		done
	;;
	
	down)
		for X in ${INTERFACES}; do
			boot_mesg "Removing ${X} from ${1}..."
			ip link set ${X} down &&
			brctl delif ${1} ${X}
			evaluate_retval
		done
		boot_mesg "Bringing down the ${1} interface..."
                ip link set ${1} down
		brctl delbr ${1}
		evaluate_retval
	;;
	
	*)
		echo "Usage: ${0} [interface] {up|down}"
		exit 1
	;;
esac

# End $network_devices/services/ipv4-static
