1 #!/bin/sh |
|
2 |
|
3 #------------------------------------------------------------------------------ |
|
4 # |
|
5 # EtherCAT rc script |
|
6 # |
|
7 # $Id$ |
|
8 # |
|
9 # Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
|
10 # |
|
11 # This file is part of the IgH EtherCAT Master. |
|
12 # |
|
13 # The IgH EtherCAT Master is free software; you can redistribute it |
|
14 # and/or modify it under the terms of the GNU General Public License |
|
15 # as published by the Free Software Foundation; version 2 of the License. |
|
16 # |
|
17 # The IgH EtherCAT Master is distributed in the hope that it will be |
|
18 # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 # GNU General Public License for more details. |
|
21 # |
|
22 # You should have received a copy of the GNU General Public License |
|
23 # along with the IgH EtherCAT Master; if not, write to the Free Software |
|
24 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
25 # |
|
26 #------------------------------------------------------------------------------ |
|
27 |
|
28 CONFIGFILE=/etc/sysconfig/ethercat |
|
29 |
|
30 #------------------------------------------------------------------------------ |
|
31 |
|
32 print_usage() |
|
33 { |
|
34 echo "Usage: $0 { start | stop | restart }" |
|
35 } |
|
36 |
|
37 unload_module() |
|
38 { |
|
39 if lsmod | grep ^$1 > /dev/null; then |
|
40 echo " unloading module \"$1\"..." |
|
41 rmmod $1 || exit 1 |
|
42 fi |
|
43 } |
|
44 |
|
45 #------------------------------------------------------------------------------ |
|
46 |
|
47 # Get parameters |
|
48 if [ $# -eq 0 ]; then |
|
49 print_usage |
|
50 exit 1 |
|
51 fi |
|
52 |
|
53 ACTION=$1 |
|
54 |
|
55 # Load configuration from sysconfig |
|
56 |
|
57 if [ -f $CONFIGFILE ]; then |
|
58 . $CONFIGFILE |
|
59 else |
|
60 echo "ERROR: Configuration file \"$CONFIGFILE\" not found!" |
|
61 exit 1 |
|
62 fi |
|
63 |
|
64 case $ACTION in |
|
65 start | restart) |
|
66 echo "Starting EtherCAT master..." |
|
67 |
|
68 # remove modules |
|
69 unload_module 8139too |
|
70 unload_module 8139cp |
|
71 unload_module ec_8139too |
|
72 unload_module ec_master |
|
73 |
|
74 echo " loading master modules..." |
|
75 if ! modprobe ec_8139too ec_device_index=$DEVICEINDEX; then |
|
76 echo "ERROR: Failed to load module!" |
|
77 exit 1 |
|
78 fi |
|
79 ;; |
|
80 |
|
81 stop) |
|
82 echo "Stopping EtherCAT master..." |
|
83 unload_module ec_8139too |
|
84 unload_module ec_master |
|
85 if ! modprobe 8139too; then |
|
86 echo "Warning: Failed to restore 8139too module." |
|
87 fi |
|
88 ;; |
|
89 |
|
90 *) |
|
91 print_usage |
|
92 exit 1 |
|
93 esac |
|
94 |
|
95 echo "done." |
|
96 exit 0 |
|
97 |
|
98 #------------------------------------------------------------------------------ |
|