author | Florian Pose <fp@igh-essen.com> |
Wed, 17 May 2006 10:52:14 +0000 | |
changeset 243 | f288d557854c |
parent 197 | b9a6e2c22745 |
child 244 | c302a846ab12 |
permissions | -rwxr-xr-x |
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
#!/bin/sh |
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
|
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
#------------------------------------------------------------------------------ |
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
# |
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
# EtherCAT rc script |
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
# |
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
# $Id$ |
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
# |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
9 |
# Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
10 |
# |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
11 |
# This file is part of the IgH EtherCAT Master. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
12 |
# |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
13 |
# The IgH EtherCAT Master is free software; you can redistribute it |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
14 |
# and/or modify it under the terms of the GNU General Public License |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
15 |
# as published by the Free Software Foundation; version 2 of the License. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
16 |
# |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
17 |
# The IgH EtherCAT Master is distributed in the hope that it will be |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
18 |
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
19 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
20 |
# GNU General Public License for more details. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
21 |
# |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
22 |
# You should have received a copy of the GNU General Public License |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
23 |
# along with the IgH EtherCAT Master; if not, write to the Free Software |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
24 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
174
diff
changeset
|
25 |
# |
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
#------------------------------------------------------------------------------ |
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
|
243 | 28 |
### BEGIN INIT INFO |
29 |
# Provides: EtherCAT |
|
30 |
# Required-Start: |
|
31 |
# Should-Start: |
|
32 |
# Required-Stop: |
|
33 |
# Should-Stop: |
|
34 |
# Default-Start: 3 5 |
|
35 |
# Default-Stop: 0 1 2 6 |
|
36 |
# Short-Description: EtherCAT master driver and network device |
|
37 |
# Description: |
|
38 |
### END INIT INFO |
|
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
|
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
#------------------------------------------------------------------------------ |
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
|
243 | 42 |
ETHERCAT_CONFIG=/etc/sysconfig/ethercat |
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
|
243 | 44 |
test -r $ETHERCAT_CONFIG || { echo "$ETHERCAT_CONFIG not existing"; |
45 |
if [ "$1" = "stop" ]; then exit 0; |
|
46 |
else exit 6; fi; } |
|
47 |
||
48 |
. $ETHERCAT_CONFIG |
|
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
|
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
#------------------------------------------------------------------------------ |
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
|
243 | 52 |
# Shell functions sourced from /etc/rc.status: |
53 |
# rc_check check and set local and overall rc status |
|
54 |
# rc_status check and set local and overall rc status |
|
55 |
# rc_status -v be verbose in local rc status and clear it afterwards |
|
56 |
# rc_status -v -r ditto and clear both the local and overall rc status |
|
57 |
# rc_status -s display "skipped" and exit with status 3 |
|
58 |
# rc_status -u display "unused" and exit with status 3 |
|
59 |
# rc_failed set local and overall rc status to failed |
|
60 |
# rc_failed <num> set local and overall rc status to <num> |
|
61 |
# rc_reset clear both the local and overall rc status |
|
62 |
# rc_exit exit appropriate to overall rc status |
|
63 |
# rc_active checks whether a service is activated by symlinks |
|
64 |
. /etc/rc.status |
|
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
|
243 | 66 |
# Reset status of this service |
67 |
rc_reset |
|
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
68 |
|
243 | 69 |
# Return values acc. to LSB for all commands but status: |
70 |
# 0 - success |
|
71 |
# 1 - generic or unspecified error |
|
72 |
# 2 - invalid or excess argument(s) |
|
73 |
# 3 - unimplemented feature (e.g. "reload") |
|
74 |
# 4 - user had insufficient privileges |
|
75 |
# 5 - program is not installed |
|
76 |
# 6 - program is not configured |
|
77 |
# 7 - program is not running |
|
78 |
# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) |
|
79 |
# |
|
80 |
# Note that starting an already running service, stopping |
|
81 |
# or restarting a not-running service as well as the restart |
|
82 |
# with force-reload (in case signaling is not supported) are |
|
83 |
# considered a success. |
|
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
|
243 | 85 |
case "$1" in |
86 |
start) |
|
87 |
echo -n "Starting EtherCAT master... " |
|
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
|
243 | 89 |
# remove incompatible modules |
90 |
for mod in 8139too 8139cp; do |
|
91 |
if lsmod | grep "^$mod " > /dev/null; then |
|
92 |
if ! rmmod $mod; then |
|
93 |
/bin/false |
|
94 |
rc_status -v |
|
95 |
rc_exit |
|
96 |
fi; |
|
97 |
fi; |
|
98 |
done |
|
174
99907332ff1e
Restart action in RC script
Florian Pose <fp@igh-essen.com>
parents:
169
diff
changeset
|
99 |
|
243 | 100 |
modprobe ec_8139too ec_device_index=$DEVICEINDEX |
174
99907332ff1e
Restart action in RC script
Florian Pose <fp@igh-essen.com>
parents:
169
diff
changeset
|
101 |
|
243 | 102 |
rc_status -v |
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
;; |
174
99907332ff1e
Restart action in RC script
Florian Pose <fp@igh-essen.com>
parents:
169
diff
changeset
|
104 |
|
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
stop) |
243 | 106 |
echo -n "Shutting down EtherCAT master... " |
107 |
||
108 |
for mod in ec_8139too ec_master; do |
|
109 |
if lsmod | grep "^$mod " > /dev/null; then |
|
110 |
if ! rmmod $mod; then |
|
111 |
/bin/false |
|
112 |
rc_status -v |
|
113 |
rc_exit |
|
114 |
fi; |
|
115 |
fi; |
|
116 |
done |
|
117 |
||
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
if ! modprobe 8139too; then |
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
echo "Warning: Failed to restore 8139too module." |
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
fi |
243 | 121 |
|
122 |
rc_status -v |
|
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
;; |
174
99907332ff1e
Restart action in RC script
Florian Pose <fp@igh-essen.com>
parents:
169
diff
changeset
|
124 |
|
243 | 125 |
restart) |
126 |
$0 stop |
|
127 |
$0 start |
|
128 |
||
129 |
rc_status |
|
130 |
;; |
|
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
esac |
243 | 132 |
rc_exit |
169
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
|
b3ecbec2c487
Better installer and startup scripts.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
#------------------------------------------------------------------------------ |