script/ethercat.sh
author Florian Pose <fp@igh-essen.com>
Thu, 03 Aug 2006 12:59:01 +0000
branchstable-1.1
changeset 1715 e675450f2174
parent 289 3c121228ebe9
child 1723 492767ba685a
permissions -rwxr-xr-x
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
169
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
#!/bin/sh
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
#------------------------------------------------------------------------------
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
#
247
d1f0cff6f57f Minor changes in init script.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
     5
#  Init script for EtherCAT
169
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
#
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
#  $Id$
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
#
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
     9
#  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    10
#
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    11
#  This file is part of the IgH EtherCAT Master.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    12
#
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    13
#  The IgH EtherCAT Master is free software; you can redistribute it
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    14
#  and/or modify it under the terms of the GNU General Public License
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 245
diff changeset
    15
#  as published by the Free Software Foundation; either version 2 of the
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 245
diff changeset
    16
#  License, or (at your option) any later version.
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    17
#
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    18
#  The IgH EtherCAT Master is distributed in the hope that it will be
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    19
#  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    20
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    21
#  GNU General Public License for more details.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    22
#
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    23
#  You should have received a copy of the GNU General Public License
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    24
#  along with the IgH EtherCAT Master; if not, write to the Free Software
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    25
#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 174
diff changeset
    26
#
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 245
diff changeset
    27
#  The right to use EtherCAT Technology is granted and comes free of
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 245
diff changeset
    28
#  charge under condition of compatibility of product made by
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 245
diff changeset
    29
#  Licensee. People intending to distribute/sell products based on the
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 245
diff changeset
    30
#  code, have to sign an agreement to guarantee that products using
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 245
diff changeset
    31
#  software based on IgH EtherCAT master stay compatible with the actual
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 245
diff changeset
    32
#  EtherCAT specification (which are released themselves as an open
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 245
diff changeset
    33
#  standard) as the (only) precondition to have the right to use EtherCAT
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 245
diff changeset
    34
#  Technology, IP and trade marks.
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 245
diff changeset
    35
#
169
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
#------------------------------------------------------------------------------
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
243
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    38
### BEGIN INIT INFO
248
f5e94773472d Minor changes in init script 2.
Florian Pose <fp@igh-essen.com>
parents: 247
diff changeset
    39
# Provides:          ethercat
245
100a0c3f5e6e Added dependencies to RC script.
Florian Pose <fp@igh-essen.com>
parents: 244
diff changeset
    40
# Required-Start:    $local_fs $syslog $network
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    41
# Should-Start:      $time ntp
245
100a0c3f5e6e Added dependencies to RC script.
Florian Pose <fp@igh-essen.com>
parents: 244
diff changeset
    42
# Required-Stop:     $local_fs $syslog $network
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    43
# Should-Stop:       $time ntp
243
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    44
# Default-Start:     3 5
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    45
# Default-Stop:      0 1 2 6
247
d1f0cff6f57f Minor changes in init script.
Florian Pose <fp@igh-essen.com>
parents: 246
diff changeset
    46
# Short-Description: IgH EtherCAT master modules
243
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    47
# Description:
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    48
### END INIT INFO
169
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
#------------------------------------------------------------------------------
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
243
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    52
ETHERCAT_CONFIG=/etc/sysconfig/ethercat
169
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    54
if [ ! -r $ETHERCAT_CONFIG ]; then
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    55
	echo "$ETHERCAT_CONFIG not existing";
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    56
	if [ "$1" = "stop" ]; then
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    57
		exit 0
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    58
	else
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    59
		exit 6
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    60
	fi
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    61
fi
243
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    62
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    63
. $ETHERCAT_CONFIG
169
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
#------------------------------------------------------------------------------
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
289
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
    67
#
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
    68
#  Function for setting up the EoE bridge
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
    69
#
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    70
build_eoe_bridge()
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    71
{
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    72
	if [ -z "$EOE_BRIDGE" ]; then return; fi
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    73
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    74
	EOEIF=`/sbin/ifconfig -a | grep -o -E "^eoe[0-9]+ "`
289
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
    75
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
    76
	# add bridge, if it does not already exist
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
    77
	if ! /sbin/brctl show | grep -E -q "^$EOE_BRIDGE"; then
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    78
		if ! /sbin/brctl addbr $EOE_BRIDGE; then
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    79
			/bin/false
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    80
			rc_status -v
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    81
			rc_exit
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    82
		fi
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    83
	fi
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    84
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    85
    # check if specified interfaces are bridged
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    86
	for interf in $EOEIF $EOE_EXTRA_INTERFACES; do
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    87
	    # interface is already part of the bridge
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    88
		if /sbin/brctl show $EOE_BRIDGE | grep -E -q $interf
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    89
			then continue
289
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
    90
		fi
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
    91
		# clear IP address and open interface
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
    92
		if ! /sbin/ifconfig $interf 0.0.0.0 up; then
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    93
			/bin/false
289
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
    94
			rc_status -v
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
    95
			rc_exit
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
    96
		fi
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
    97
		# add interface to the bridge
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
    98
		if ! /sbin/brctl addif $EOE_BRIDGE $interf; then
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
    99
			/bin/false
289
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   100
			rc_status -v
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   101
			rc_exit
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   102
		fi
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   103
	done
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   104
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   105
	# configure IP on bridge
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   106
	if [ -n "$EOE_IP_ADDRESS" -a -n "$EOE_IP_NETMASK" ]; then
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   107
		if ! /sbin/ifconfig $EOE_BRIDGE $EOE_IP_ADDRESS \
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   108
			netmask $EOE_IP_NETMASK; then
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   109
			/bin/false
289
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   110
			rc_status -v
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   111
			rc_exit
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   112
		fi
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   113
	fi
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   114
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   115
	# open bridge
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   116
	if ! /sbin/ifconfig $EOE_BRIDGE up; then
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   117
		/bin/false
289
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   118
		rc_status -v
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   119
		rc_exit
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   120
	fi
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   121
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   122
	# install new default gateway
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   123
	if [ -n "$EOE_GATEWAY" ]; then
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   124
		while /sbin/route -n | grep -E -q "^0.0.0.0"; do
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   125
			if ! /sbin/route del default; then
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   126
				echo "Failed to remove route!" 1>&2
289
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   127
				/bin/false
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   128
				rc_status -v
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   129
				rc_exit
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   130
			fi
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   131
		done
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   132
		if ! /sbin/route add default gw $EOE_GATEWAY; then
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   133
			/bin/false
289
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   134
			rc_status -v
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   135
			rc_exit
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   136
		fi
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   137
	fi
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   138
}
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   139
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   140
#------------------------------------------------------------------------------
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   141
243
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   142
. /etc/rc.status
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   143
rc_reset
169
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
243
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   145
case "$1" in
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   146
243
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   147
    start)
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   148
		echo -n "Starting EtherCAT master "
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   149
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   150
		if [ -z "$DEVICE_INDEX" ]; then
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   151
			echo "ERROR: DEVICE_INDEX not set!"
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   152
			/bin/false
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   153
			rc_status -v
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   154
			rc_exit
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   155
		fi
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   156
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   157
		if [ -z "$EOE_INTERFACES" ]; then
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   158
			if [ -n "$EOE_DEVICES" ]; then # support legacy sysconfig files
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   159
				EOE_INTERFACES=$EOE_DEVICES
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   160
			else
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   161
				EOE_INTERFACES=0
250
440ae5f6d2c3 Created scripts directory and improved install and init scripts.
Florian Pose <fp@igh-essen.com>
parents: 248
diff changeset
   162
			fi
440ae5f6d2c3 Created scripts directory and improved install and init scripts.
Florian Pose <fp@igh-essen.com>
parents: 248
diff changeset
   163
		fi
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   164
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   165
	    # unload conflicting modules at first
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   166
		for mod in 8139too; do
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   167
			if lsmod | grep "^$mod " > /dev/null; then
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   168
				if ! rmmod $mod; then
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   169
					/bin/false
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   170
					rc_status -v
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   171
					rc_exit
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   172
				fi
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   173
			fi
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   174
		done
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   175
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   176
	    # load master module
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   177
		if ! modprobe ec_master ec_eoeif_count=$EOE_INTERFACES; then
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   178
			modprobe 8139too
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   179
			/bin/false
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   180
			rc_status -v
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   181
			rc_exit
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   182
		fi
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   183
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   184
        # load device module
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   185
		if ! modprobe ec_8139too ec_device_index=$DEVICE_INDEX; then
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   186
			rmmod ec_master
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   187
			modprobe 8139too
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   188
			/bin/false
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   189
			rc_status -v
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   190
			rc_exit
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   191
		fi
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   192
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   193
        # build EoE bridge
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   194
		build_eoe_bridge
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   195
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   196
		rc_status -v
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   197
		;;
174
99907332ff1e Restart action in RC script
Florian Pose <fp@igh-essen.com>
parents: 169
diff changeset
   198
169
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
    stop)
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   200
		echo -n "Shutting down EtherCAT master "
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   201
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   202
	    # unload modules
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   203
		for mod in ec_8139too ec_master; do
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   204
			if lsmod | grep "^$mod " > /dev/null; then
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   205
				if ! rmmod $mod; then
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   206
					/bin/false
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   207
					rc_status -v
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   208
					rc_exit
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   209
				fi;
243
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   210
			fi;
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   211
		done
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   212
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   213
		sleep 1
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   214
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   215
	    # reload previous modules
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   216
		if ! modprobe 8139too; then
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   217
			echo "Warning: Failed to restore 8139too module."
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   218
		fi
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   219
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   220
		rc_status -v
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   221
		;;
174
99907332ff1e Restart action in RC script
Florian Pose <fp@igh-essen.com>
parents: 169
diff changeset
   222
243
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   223
    restart)
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   224
		$0 stop || exit 1
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   225
		sleep 1
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   226
		$0 start
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   227
		rc_status
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   228
		;;
244
c302a846ab12 Added status function to RC script.
Florian Pose <fp@igh-essen.com>
parents: 243
diff changeset
   229
c302a846ab12 Added status function to RC script.
Florian Pose <fp@igh-essen.com>
parents: 243
diff changeset
   230
    status)
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   231
		echo -n "Checking for EtherCAT "
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   232
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   233
		lsmod | grep "^ec_master " > /dev/null
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   234
		master_running=$?
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   235
		lsmod | grep "^ec_8139too " > /dev/null
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   236
		device_running=$?
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   237
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   238
	    # master module and device module loaded?
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   239
		test $master_running -eq 0 -a $device_running -eq 0
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   240
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   241
		rc_status -v
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   242
		;;
289
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   243
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   244
    bridge)
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   245
		echo -n "Building EoE bridge "
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   246
		build_eoe_bridge
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   247
		rc_status -v
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   248
		;;
289
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   249
3c121228ebe9 Enhancements and bugfixes on bridging script.
Florian Pose <fp@igh-essen.com>
parents: 285
diff changeset
   250
    *)
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   251
		echo "USAGE: $0 {start|stop|restart|status|bridge}"
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   252
		;;
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   253
169
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
esac
1715
e675450f2174 MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents: 289
diff changeset
   255
243
f288d557854c Better RC script.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   256
rc_exit
169
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
b3ecbec2c487 Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
#------------------------------------------------------------------------------