equal
deleted
inserted
replaced
47 # Description: |
47 # Description: |
48 ### END INIT INFO |
48 ### END INIT INFO |
49 |
49 |
50 #------------------------------------------------------------------------------ |
50 #------------------------------------------------------------------------------ |
51 |
51 |
|
52 device="ecxml" |
|
53 |
|
54 #------------------------------------------------------------------------------ |
|
55 |
52 ETHERCAT_CONFIG=/etc/sysconfig/ethercat |
56 ETHERCAT_CONFIG=/etc/sysconfig/ethercat |
53 |
57 |
54 if [ ! -r $ETHERCAT_CONFIG ]; then |
58 if [ ! -r $ETHERCAT_CONFIG ]; then |
55 echo "$ETHERCAT_CONFIG not existing"; |
59 echo "$ETHERCAT_CONFIG not existing"; |
56 if [ "$1" = "stop" ]; then |
60 if [ "$1" = "stop" ]; then |
73 |
77 |
74 EOEIF=`/sbin/ifconfig -a | grep -o -E "^eoe[0-9]+ "` |
78 EOEIF=`/sbin/ifconfig -a | grep -o -E "^eoe[0-9]+ "` |
75 |
79 |
76 # add bridge, if it does not already exist |
80 # add bridge, if it does not already exist |
77 if ! /sbin/brctl show | grep -E -q "^$EOE_BRIDGE"; then |
81 if ! /sbin/brctl show | grep -E -q "^$EOE_BRIDGE"; then |
78 if ! /sbin/brctl addbr $EOE_BRIDGE; then |
82 if ! /sbin/brctl addbr $EOE_BRIDGE; then |
79 /bin/false |
83 /bin/false |
80 rc_status -v |
84 rc_status -v |
81 rc_exit |
85 rc_exit |
82 fi |
86 fi |
83 fi |
87 fi |
153 rc_status -v |
157 rc_status -v |
154 rc_exit |
158 rc_exit |
155 fi |
159 fi |
156 |
160 |
157 if [ -z "$EOE_INTERFACES" ]; then |
161 if [ -z "$EOE_INTERFACES" ]; then |
158 if [ -n "$EOE_DEVICES" ]; then # support legacy sysconfig files |
162 # support legacy sysconfig files |
|
163 if [ -n "$EOE_DEVICES" ]; then |
159 EOE_INTERFACES=$EOE_DEVICES |
164 EOE_INTERFACES=$EOE_DEVICES |
160 else |
165 else |
161 EOE_INTERFACES=0 |
166 EOE_INTERFACES=0 |
162 fi |
167 fi |
163 fi |
168 fi |
179 /bin/false |
184 /bin/false |
180 rc_status -v |
185 rc_status -v |
181 rc_exit |
186 rc_exit |
182 fi |
187 fi |
183 |
188 |
184 # load device module |
189 # remove stale device node |
|
190 rm -f /dev/${device}0 |
|
191 |
|
192 # get dynamic major number |
|
193 major=$(awk "\$2==\"EtherCAT\" {print \$1}" /proc/devices) |
|
194 |
|
195 # create character device |
|
196 mknod /dev/${device}0 c $major 0 |
|
197 |
|
198 # load device module |
185 if ! modprobe ec_8139too ec_device_index=$DEVICE_INDEX; then |
199 if ! modprobe ec_8139too ec_device_index=$DEVICE_INDEX; then |
186 rmmod ec_master |
200 rmmod ec_master |
187 modprobe 8139too |
201 modprobe 8139too |
188 /bin/false |
202 /bin/false |
189 rc_status -v |
203 rc_status -v |
190 rc_exit |
204 rc_exit |
191 fi |
205 fi |
192 |
206 |
193 # build EoE bridge |
207 # build EoE bridge |
194 build_eoe_bridge |
208 build_eoe_bridge |
195 |
209 |
196 rc_status -v |
210 rc_status -v |
197 ;; |
211 ;; |
198 |
212 |
199 stop) |
213 stop) |
200 echo -n "Shutting down EtherCAT master " |
214 echo -n "Shutting down EtherCAT master " |
201 |
215 |
202 # unload modules |
216 # unload modules |
203 for mod in ec_8139too ec_master; do |
217 for mod in ec_8139too ec_master; do |
204 if lsmod | grep "^$mod " > /dev/null; then |
218 if lsmod | grep "^$mod " > /dev/null; then |
205 if ! rmmod $mod; then |
219 if ! rmmod $mod; then |
206 /bin/false |
220 /bin/false |
207 rc_status -v |
221 rc_status -v |
208 rc_exit |
222 rc_exit |
209 fi; |
223 fi; |
210 fi; |
224 fi; |
211 done |
225 done |
212 |
226 |
|
227 # remove device node |
|
228 rm -f /dev/${device}0 |
|
229 |
213 sleep 1 |
230 sleep 1 |
214 |
231 |
215 # reload previous modules |
232 # reload previous modules |
216 if ! modprobe 8139too; then |
233 if ! modprobe 8139too; then |
217 echo "Warning: Failed to restore 8139too module." |
234 echo "Warning: Failed to restore 8139too module." |
218 fi |
235 fi |
219 |
236 |
220 rc_status -v |
237 rc_status -v |
233 lsmod | grep "^ec_master " > /dev/null |
250 lsmod | grep "^ec_master " > /dev/null |
234 master_running=$? |
251 master_running=$? |
235 lsmod | grep "^ec_8139too " > /dev/null |
252 lsmod | grep "^ec_8139too " > /dev/null |
236 device_running=$? |
253 device_running=$? |
237 |
254 |
238 # master module and device module loaded? |
255 # master module and device module loaded? |
239 test $master_running -eq 0 -a $device_running -eq 0 |
256 test $master_running -eq 0 -a $device_running -eq 0 |
240 |
257 |
241 rc_status -v |
258 rc_status -v |
242 ;; |
259 ;; |
243 |
260 |