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