fp@703: #!/bin/bash
fp@703: 
fp@703: #------------------------------------------------------------------------------
fp@703: #
fp@703: #  $Id$
fp@703: #
fp@703: #  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
fp@703: #
fp@703: #  This file is part of the IgH EtherCAT Master.
fp@703: #
fp@703: #  The IgH EtherCAT Master is free software; you can redistribute it
fp@703: #  and/or modify it under the terms of the GNU General Public License
fp@703: #  as published by the Free Software Foundation; either version 2 of the
fp@703: #  License, or (at your option) any later version.
fp@703: #
fp@703: #  The IgH EtherCAT Master is distributed in the hope that it will be
fp@703: #  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
fp@703: #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
fp@703: #  GNU General Public License for more details.
fp@703: #
fp@703: #  You should have received a copy of the GNU General Public License
fp@703: #  along with the IgH EtherCAT Master; if not, write to the Free Software
fp@703: #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
fp@703: #
fp@703: #  The right to use EtherCAT Technology is granted and comes free of
fp@703: #  charge under condition of compatibility of product made by
fp@703: #  Licensee. People intending to distribute/sell products based on the
fp@703: #  code, have to sign an agreement to guarantee that products using
fp@703: #  software based on IgH EtherCAT master stay compatible with the actual
fp@703: #  EtherCAT specification (which are released themselves as an open
fp@703: #  standard) as the (only) precondition to have the right to use EtherCAT
fp@703: #  Technology, IP and trade marks.
fp@703: #
fp@703: #------------------------------------------------------------------------------
fp@703: 
fp@703: # this ifup.d script adds special network interfaces to a network bridge
fp@703: 
fp@703: CFGNAME=${1}
fp@703: IFNAME=${2}
fp@703: 
fp@703: # customize here
fp@703: BRNAME="eoebr0"
fp@703: INTERFACES=""
fp@703: BRCTL="/sbin/brctl"
fp@703: LOGGER="logger -t ifup-eoe"
fp@703: 
fp@703: # if the current interface in the list of interfaces to bridge?
fp@703: if ! echo ${INTERFACES} | grep -qw ${IFNAME}; then
fp@703:     exit 0;
fp@703: fi
fp@703: 
fp@703: # does the EoE bridge already exist?
fp@703: if ! ${BRCTL} show | grep -q "^${BRNAME}"; then
fp@703: 	${LOGGER} Creating ${BRNAME}
fp@703: 	${BRCTL} addbr ${BRNAME} # create it
fp@703: fi
fp@703: 
fp@703: ${LOGGER} Adding ${IFNAME} to ${BRNAME}
fp@703: ip link set ${IFNAME} down
fp@703: ip addr flush dev ${IFNAME}
fp@703: ${BRCTL} addif ${BRNAME} ${IFNAME}
fp@703: ip link set ${IFNAME} up
fp@703: 
fp@703: #------------------------------------------------------------------------------