script/ifup-eoe.sh
author Edouard Tisserant <edouard.tisserant@gmail.com>
Tue, 09 Oct 2018 09:22:53 +0200
branchstable-1.5
changeset 2727 32c9a2dea9ed
parent 2421 bc2d4bf9cbe5
permissions -rwxr-xr-x
devices/rtdmnet.c : fixed indentation and error handling.
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
#
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 703
diff changeset
     7
#  Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH
703
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
#
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 703
diff changeset
    11
#  The IgH EtherCAT Master is free software; you can redistribute it and/or
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 703
diff changeset
    12
#  modify it under the terms of the GNU General Public License version 2, as
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 703
diff changeset
    13
#  published by the Free Software Foundation.
703
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
#
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 703
diff changeset
    15
#  The IgH EtherCAT Master is distributed in the hope that it will be useful,
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 703
diff changeset
    16
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 703
diff changeset
    17
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 703
diff changeset
    18
#  Public License for more details.
703
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
#
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 703
diff changeset
    20
#  You should have received a copy of the GNU General Public License along
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 703
diff changeset
    21
#  with the IgH EtherCAT Master; if not, write to the Free Software
703
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
#  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
    23
#
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    24
#  ---
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
    25
#
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    26
#  The license mentioned above concerns the source code only. Using the EtherCAT
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    27
#  technology and brand is only permitted in compliance with the industrial
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    28
#  property and similar rights of Beckhoff Automation GmbH.
703
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
#
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    30
#  vim: expandtab
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    31
#
703
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
#------------------------------------------------------------------------------
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
# 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
    35
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
CFGNAME=${1}
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
IFNAME=${2}
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
# customize here
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
BRNAME="eoebr0"
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
INTERFACES=""
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
BRCTL="/sbin/brctl"
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
LOGGER="logger -t ifup-eoe"
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
# if the current interface in the list of interfaces to bridge?
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
if ! echo ${INTERFACES} | grep -qw ${IFNAME}; then
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
    exit 0;
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
fi
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
# does the EoE bridge already exist?
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
if ! ${BRCTL} show | grep -q "^${BRNAME}"; then
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    52
    ${LOGGER} Creating ${BRNAME}
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    53
    ${BRCTL} addbr ${BRNAME} # create it
703
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
fi
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
${LOGGER} Adding ${IFNAME} to ${BRNAME}
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
ip link set ${IFNAME} down
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
ip addr flush dev ${IFNAME}
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
${BRCTL} addif ${BRNAME} ${IFNAME}
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
ip link set ${IFNAME} up
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
daaa2e8ae232 Added EoE helpers.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
#------------------------------------------------------------------------------