Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
etherlabmaster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ICS Control System Infrastructure
etherlabmaster
Commits
aceb0793
Commit
aceb0793
authored
18 years ago
by
Florian Pose
Browse files
Options
Downloads
Patches
Plain Diff
Enhancements and bugfixes on bridging script.
parent
9edf7b8c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
script/ethercat.sh
+96
-61
96 additions, 61 deletions
script/ethercat.sh
with
96 additions
and
61 deletions
script/ethercat.sh
+
96
−
61
View file @
aceb0793
...
...
@@ -59,6 +59,80 @@ test -r $ETHERCAT_CONFIG || { echo "$ETHERCAT_CONFIG not existing";
#------------------------------------------------------------------------------
#
# Function for setting up the EoE bridge
#
build_eoe_bridge
()
{
if
[
-z
"
$EOE_BRIDGE
"
]
;
then return
;
fi
EOE_INTERFACES
=
`
/sbin/ifconfig
-a
|
grep
-o
-E
"^eoe[0-9]+ "
`
# add bridge, if it does not already exist
if
!
/sbin/brctl show |
grep
-E
-q
"^
$EOE_BRIDGE
"
;
then
if
!
/sbin/brctl addbr
$EOE_BRIDGE
;
then
/bin/false
rc_status
-v
rc_exit
fi
fi
# check if specified interfaces are bridged
for
interf
in
$EOE_INTERFACES
$EOE_EXTRA_INTERFACES
;
do
# interface is already part of the bridge
if
/sbin/brctl show
$EOE_BRIDGE
|
grep
-E
-q
$interf
then continue
fi
# clear IP address and open interface
if
!
/sbin/ifconfig
$interf
0.0.0.0 up
;
then
/bin/false
rc_status
-v
rc_exit
fi
# add interface to the bridge
if
!
/sbin/brctl addif
$EOE_BRIDGE
$interf
;
then
/bin/false
rc_status
-v
rc_exit
fi
done
# configure IP on bridge
if
[
-n
"
$EOE_IP_ADDRESS
"
-a
-n
"
$EOE_IP_NETMASK
"
]
;
then
if
!
/sbin/ifconfig
$EOE_BRIDGE
$EOE_IP_ADDRESS
\
netmask
$EOE_IP_NETMASK
;
then
/bin/false
rc_status
-v
rc_exit
fi
fi
# open bridge
if
!
/sbin/ifconfig
$EOE_BRIDGE
up
;
then
/bin/false
rc_status
-v
rc_exit
fi
# install new default gateway
if
[
-n
"
$EOE_GATEWAY
"
]
;
then
while
/sbin/route
-n
|
grep
-E
-q
"^0.0.0.0"
;
do
if
!
/sbin/route del default
;
then
echo
"Failed to remove route!"
1>&2
/bin/false
rc_status
-v
rc_exit
fi
done
if
!
/sbin/route add default gw
$EOE_GATEWAY
;
then
/bin/false
rc_status
-v
rc_exit
fi
fi
}
#------------------------------------------------------------------------------
.
/etc/rc.status
rc_reset
...
...
@@ -77,6 +151,7 @@ case "$1" in
EOE_DEVICES
=
0
fi
# unload conflicting modules at first
for
mod
in
8139too 8139cp
;
do
if
lsmod |
grep
"^
$mod
"
>
/dev/null
;
then
if
!
rmmod
$mod
;
then
...
...
@@ -87,78 +162,22 @@ case "$1" in
fi
done
# load master module
if
!
modprobe ec_master
ec_eoe_devices
=
$EOE_DEVICES
;
then
/bin/false
rc_status
-v
rc_exit
fi
# load device module
if
!
modprobe ec_8139too
ec_device_index
=
$DEVICE_INDEX
;
then
/bin/false
rc_status
-v
rc_exit
fi
# Build EoE bridge
if
[
-n
"
$EOE_BRIDGE
"
]
;
then
EOE_INTERFACES
=
`
/sbin/ifconfig
-a
|
grep
-o
-E
"^eoe[0-9]+ "
`
# add bridge, if it does not already exist
if
!
/sbin/brctl show |
grep
-E
-q
"^
$EOE_BRIDGE
"
;
then
if
!
/sbin/brctl addbr
$EOE_BRIDGE
;
then
/bin/false
rc_status
-v
rc_exit
fi
fi
# free all interfaces of their addresses and add them to the bridge
for
interface
in
$EOE_INTERFACES
$EOE_EXTRA_INTERFACES
;
do
if
!
/sbin/ifconfig
$interface
0.0.0.0 up
;
then
/bin/false
rc_status
-v
rc_exit
fi
if
!
/sbin/brctl show |
grep
-E
-q
"^
$EOE_BRIDGE
.*
$interface
"
;
then
if
!
/sbin/brctl addif
$EOE_BRIDGE
$interface
;
then
/bin/false
rc_status
-v
rc_exit
fi
fi
done
if
[
-n
"
$EOE_IP_ADDRESS
"
-a
-n
"
$EOE_IP_NETMASK
"
]
;
then
if
!
/sbin/ifconfig
$EOE_BRIDGE
$EOE_IP_ADDRESS
\
netmask
$EOE_IP_NETMASK
;
then
/bin/false
rc_status
-v
rc_exit
fi
fi
if
!
/sbin/ifconfig
$EOE_BRIDGE
up
;
then
/bin/false
rc_status
-v
rc_exit
fi
# install new default gateway
if
[
-n
"
$EOE_GATEWAY
"
]
;
then
while
/sbin/route
-n
|
grep
-E
-q
"^0.0.0.0"
;
do
if
!
/sbin/route del default
;
then
echo
"Failed to remove default route!"
1>&2
/bin/false
rc_status
-v
rc_exit
fi
done
if
!
/sbin/route add default gw
$EOE_GATEWAY
;
then
/bin/false
rc_status
-v
rc_exit
fi
fi
fi
# build EoE bridge
build_eoe_bridge
rc_status
-v
;;
...
...
@@ -166,6 +185,7 @@ case "$1" in
stop
)
echo
-n
"Shutting down EtherCAT master "
# unload modules
for
mod
in
ec_8139too ec_master
;
do
if
lsmod |
grep
"^
$mod
"
>
/dev/null
;
then
if
!
rmmod
$mod
;
then
...
...
@@ -176,6 +196,7 @@ case "$1" in
fi
;
done
# reload previous modules
if
!
modprobe 8139too
;
then
echo
"Warning: Failed to restore 8139too module."
fi
...
...
@@ -184,7 +205,7 @@ case "$1" in
;;
restart
)
$0
stop
$0
stop
||
exit
1
$0
start
rc_status
...
...
@@ -197,10 +218,24 @@ case "$1" in
master_running
=
$?
lsmod |
grep
"^ec_8139too "
>
/dev/null
device_running
=
$?
# master module and device module loaded?
test
$master_running
-eq
0
-a
$device_running
-eq
0
rc_status
-v
;;
bridge
)
echo
-n
"Building EoE bridge "
build_eoe_bridge
rc_status
-v
;;
*
)
echo
"USAGE:
$0
{start|stop|restart|status|bridge}"
;;
esac
rc_exit
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment