34 # Technology, IP and trade marks. |
34 # Technology, IP and trade marks. |
35 # |
35 # |
36 #------------------------------------------------------------------------------ |
36 #------------------------------------------------------------------------------ |
37 |
37 |
38 ### BEGIN INIT INFO |
38 ### BEGIN INIT INFO |
39 # Provides: EtherCAT |
39 # Provides: IgH EtherCAT master |
40 # Required-Start: $local_fs $syslog $network |
40 # Required-Start: $local_fs $syslog $network |
41 # Should-Start: $time |
41 # Should-Start: $time |
42 # Required-Stop: $local_fs $syslog $network |
42 # Required-Stop: $local_fs $syslog $network |
43 # Should-Stop: $time |
43 # Should-Stop: $time |
44 # Default-Start: 3 5 |
44 # Default-Start: 3 5 |
45 # Default-Stop: 0 1 2 6 |
45 # Default-Stop: 0 1 2 6 |
46 # Short-Description: EtherCAT master driver and network device |
46 # Short-Description: IgH EtherCAT master modules |
47 # Description: |
47 # Description: |
48 ### END INIT INFO |
48 ### END INIT INFO |
49 |
49 |
50 #------------------------------------------------------------------------------ |
50 #------------------------------------------------------------------------------ |
51 |
51 |
57 |
57 |
58 . $ETHERCAT_CONFIG |
58 . $ETHERCAT_CONFIG |
59 |
59 |
60 #------------------------------------------------------------------------------ |
60 #------------------------------------------------------------------------------ |
61 |
61 |
62 # Shell functions sourced from /etc/rc.status: |
|
63 # rc_check check and set local and overall rc status |
|
64 # rc_status check and set local and overall rc status |
|
65 # rc_status -v be verbose in local rc status and clear it afterwards |
|
66 # rc_status -v -r ditto and clear both the local and overall rc status |
|
67 # rc_status -s display "skipped" and exit with status 3 |
|
68 # rc_status -u display "unused" and exit with status 3 |
|
69 # rc_failed set local and overall rc status to failed |
|
70 # rc_failed <num> set local and overall rc status to <num> |
|
71 # rc_reset clear both the local and overall rc status |
|
72 # rc_exit exit appropriate to overall rc status |
|
73 # rc_active checks whether a service is activated by symlinks |
|
74 . /etc/rc.status |
62 . /etc/rc.status |
75 |
|
76 # Reset status of this service |
|
77 rc_reset |
63 rc_reset |
78 |
|
79 # Return values acc. to LSB for all commands but status: |
|
80 # 0 - success |
|
81 # 1 - generic or unspecified error |
|
82 # 2 - invalid or excess argument(s) |
|
83 # 3 - unimplemented feature (e.g. "reload") |
|
84 # 4 - user had insufficient privileges |
|
85 # 5 - program is not installed |
|
86 # 6 - program is not configured |
|
87 # 7 - program is not running |
|
88 # 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) |
|
89 # |
|
90 # Note that starting an already running service, stopping |
|
91 # or restarting a not-running service as well as the restart |
|
92 # with force-reload (in case signaling is not supported) are |
|
93 # considered a success. |
|
94 |
64 |
95 case "$1" in |
65 case "$1" in |
96 start) |
66 start) |
97 echo -n "Starting EtherCAT master... " |
67 echo -n "Starting EtherCAT master... " |
98 |
68 |
99 # remove incompatible modules |
|
100 for mod in 8139too 8139cp; do |
69 for mod in 8139too 8139cp; do |
101 if lsmod | grep "^$mod " > /dev/null; then |
70 if lsmod | grep "^$mod " > /dev/null; then |
102 if ! rmmod $mod; then |
71 if ! rmmod $mod; then |
103 /bin/false |
72 /bin/false |
104 rc_status -v |
73 rc_status -v |
140 ;; |
109 ;; |
141 |
110 |
142 status) |
111 status) |
143 echo -n "Checking for EtherCAT... " |
112 echo -n "Checking for EtherCAT... " |
144 |
113 |
145 # Return value is slightly different for the status command: |
|
146 # 0 - service up and running |
|
147 # 1 - service dead, but /var/run/ pid file exists |
|
148 # 2 - service dead, but /var/lock/ lock file exists |
|
149 # 3 - service not running (unused) |
|
150 # 4 - service status unknown :-( |
|
151 # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) |
|
152 |
|
153 lsmod | grep "^ec_master " > /dev/null |
114 lsmod | grep "^ec_master " > /dev/null |
154 master_running=$? |
115 master_running=$? |
155 lsmod | grep "^ec_8139too " > /dev/null |
116 lsmod | grep "^ec_8139too " > /dev/null |
156 device_running=$? |
117 device_running=$? |
157 test $master_running -eq 0 -a $device_running -eq 0 |
118 test $master_running -eq 0 -a $device_running -eq 0 |