1 #!/bin/sh |
|
2 |
|
3 #------------------------------------------------------------------------------ |
|
4 # |
|
5 # Init script for EtherCAT |
|
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; either version 2 of the |
|
16 # License, or (at your option) any later version. |
|
17 # |
|
18 # The IgH EtherCAT Master is distributed in the hope that it will be |
|
19 # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 # GNU General Public License for more details. |
|
22 # |
|
23 # You should have received a copy of the GNU General Public License |
|
24 # along with the IgH EtherCAT Master; if not, write to the Free Software |
|
25 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
26 # |
|
27 # The right to use EtherCAT Technology is granted and comes free of |
|
28 # charge under condition of compatibility of product made by |
|
29 # Licensee. People intending to distribute/sell products based on the |
|
30 # code, have to sign an agreement to guarantee that products using |
|
31 # software based on IgH EtherCAT master stay compatible with the actual |
|
32 # EtherCAT specification (which are released themselves as an open |
|
33 # standard) as the (only) precondition to have the right to use EtherCAT |
|
34 # Technology, IP and trade marks. |
|
35 # |
|
36 #------------------------------------------------------------------------------ |
|
37 |
|
38 ### BEGIN INIT INFO |
|
39 # Provides: ethercat |
|
40 # Required-Start: $local_fs $syslog $network |
|
41 # Should-Start: $time |
|
42 # Required-Stop: $local_fs $syslog $network |
|
43 # Should-Stop: $time |
|
44 # Default-Start: 3 5 |
|
45 # Default-Stop: 0 1 2 6 |
|
46 # Short-Description: IgH EtherCAT master modules |
|
47 # Description: |
|
48 ### END INIT INFO |
|
49 |
|
50 #------------------------------------------------------------------------------ |
|
51 |
|
52 ETHERCAT_CONFIG=/etc/sysconfig/ethercat |
|
53 |
|
54 test -r $ETHERCAT_CONFIG || { echo "$ETHERCAT_CONFIG not existing"; |
|
55 if [ "$1" = "stop" ]; then exit 0; |
|
56 else exit 6; fi; } |
|
57 |
|
58 . $ETHERCAT_CONFIG |
|
59 |
|
60 #------------------------------------------------------------------------------ |
|
61 |
|
62 . /etc/rc.status |
|
63 rc_reset |
|
64 |
|
65 case "$1" in |
|
66 start) |
|
67 echo -n "Starting EtherCAT master... " |
|
68 |
|
69 for mod in 8139too 8139cp; do |
|
70 if lsmod | grep "^$mod " > /dev/null; then |
|
71 if ! rmmod $mod; then |
|
72 /bin/false |
|
73 rc_status -v |
|
74 rc_exit |
|
75 fi; |
|
76 fi; |
|
77 done |
|
78 |
|
79 modprobe ec_8139too ec_device_index=$DEVICEINDEX |
|
80 |
|
81 rc_status -v |
|
82 ;; |
|
83 |
|
84 stop) |
|
85 echo -n "Shutting down EtherCAT master... " |
|
86 |
|
87 for mod in ec_8139too ec_master; do |
|
88 if lsmod | grep "^$mod " > /dev/null; then |
|
89 if ! rmmod $mod; then |
|
90 /bin/false |
|
91 rc_status -v |
|
92 rc_exit |
|
93 fi; |
|
94 fi; |
|
95 done |
|
96 |
|
97 if ! modprobe 8139too; then |
|
98 echo "Warning: Failed to restore 8139too module." |
|
99 fi |
|
100 |
|
101 rc_status -v |
|
102 ;; |
|
103 |
|
104 restart) |
|
105 $0 stop |
|
106 $0 start |
|
107 |
|
108 rc_status |
|
109 ;; |
|
110 |
|
111 status) |
|
112 echo -n "Checking for EtherCAT... " |
|
113 |
|
114 lsmod | grep "^ec_master " > /dev/null |
|
115 master_running=$? |
|
116 lsmod | grep "^ec_8139too " > /dev/null |
|
117 device_running=$? |
|
118 test $master_running -eq 0 -a $device_running -eq 0 |
|
119 |
|
120 rc_status -v |
|
121 ;; |
|
122 esac |
|
123 rc_exit |
|
124 |
|
125 #------------------------------------------------------------------------------ |
|