script/ifup-eoe.sh
author Florian Pose <fp@igh-essen.com>
Thu, 20 Sep 2007 12:33:58 +0000
changeset 747 ac8a822c3e5b
parent 703 daaa2e8ae232
child 1326 ef907b0b5125
permissions -rwxr-xr-x
Minor comment change.
703
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
#!/bin/bash
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
#------------------------------------------------------------------------------
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
#
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
#  $Id$
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
#
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
#  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
#
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
#  This file is part of the IgH EtherCAT Master.
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
#
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
#  The IgH EtherCAT Master is free software; you can redistribute it
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
#  and/or modify it under the terms of the GNU General Public License
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
#  as published by the Free Software Foundation; either version 2 of the
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
#  License, or (at your option) any later version.
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
#
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
#  The IgH EtherCAT Master is distributed in the hope that it will be
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
#  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
#  GNU General Public License for more details.
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
#
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
#  You should have received a copy of the GNU General Public License
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
#  along with the IgH EtherCAT Master; if not, write to the Free Software
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
#
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
#  The right to use EtherCAT Technology is granted and comes free of
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
#  charge under condition of compatibility of product made by
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
#  Licensee. People intending to distribute/sell products based on the
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
#  code, have to sign an agreement to guarantee that products using
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
#  software based on IgH EtherCAT master stay compatible with the actual
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
#  EtherCAT specification (which are released themselves as an open
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#  standard) as the (only) precondition to have the right to use EtherCAT
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
#  Technology, IP and trade marks.
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
#
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
#------------------------------------------------------------------------------
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
# this ifup.d script adds special network interfaces to a network bridge
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
CFGNAME=${1}
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
IFNAME=${2}
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
# customize here
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
BRNAME="eoebr0"
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
INTERFACES=""
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
BRCTL="/sbin/brctl"
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
LOGGER="logger -t ifup-eoe"
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
# if the current interface in the list of interfaces to bridge?
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
if ! echo ${INTERFACES} | grep -qw ${IFNAME}; then
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
    exit 0;
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
fi
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
# does the EoE bridge already exist?
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
if ! ${BRCTL} show | grep -q "^${BRNAME}"; then
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
	${LOGGER} Creating ${BRNAME}
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
	${BRCTL} addbr ${BRNAME} # create it
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
fi
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
${LOGGER} Adding ${IFNAME} to ${BRNAME}
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
ip link set ${IFNAME} down
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
ip addr flush dev ${IFNAME}
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
${BRCTL} addif ${BRNAME} ${IFNAME}
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
ip link set ${IFNAME} up
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
#------------------------------------------------------------------------------