fp@169: #!/bin/sh fp@169: fp@169: #------------------------------------------------------------------------------ fp@169: # fp@169: # EtherCAT rc script fp@169: # fp@169: # $Id$ fp@169: # fp@197: # Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH fp@197: # fp@197: # This file is part of the IgH EtherCAT Master. fp@197: # fp@197: # The IgH EtherCAT Master is free software; you can redistribute it fp@197: # and/or modify it under the terms of the GNU General Public License fp@197: # as published by the Free Software Foundation; version 2 of the License. fp@197: # fp@197: # The IgH EtherCAT Master is distributed in the hope that it will be fp@197: # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of fp@197: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the fp@197: # GNU General Public License for more details. fp@197: # fp@197: # You should have received a copy of the GNU General Public License fp@197: # along with the IgH EtherCAT Master; if not, write to the Free Software fp@197: # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@197: # fp@169: #------------------------------------------------------------------------------ fp@169: fp@243: ### BEGIN INIT INFO fp@243: # Provides: EtherCAT fp@243: # Required-Start: fp@243: # Should-Start: fp@243: # Required-Stop: fp@243: # Should-Stop: fp@243: # Default-Start: 3 5 fp@243: # Default-Stop: 0 1 2 6 fp@243: # Short-Description: EtherCAT master driver and network device fp@243: # Description: fp@243: ### END INIT INFO fp@169: fp@169: #------------------------------------------------------------------------------ fp@169: fp@243: ETHERCAT_CONFIG=/etc/sysconfig/ethercat fp@169: fp@243: test -r $ETHERCAT_CONFIG || { echo "$ETHERCAT_CONFIG not existing"; fp@243: if [ "$1" = "stop" ]; then exit 0; fp@243: else exit 6; fi; } fp@243: fp@243: . $ETHERCAT_CONFIG fp@169: fp@169: #------------------------------------------------------------------------------ fp@169: fp@243: # Shell functions sourced from /etc/rc.status: fp@243: # rc_check check and set local and overall rc status fp@243: # rc_status check and set local and overall rc status fp@243: # rc_status -v be verbose in local rc status and clear it afterwards fp@243: # rc_status -v -r ditto and clear both the local and overall rc status fp@243: # rc_status -s display "skipped" and exit with status 3 fp@243: # rc_status -u display "unused" and exit with status 3 fp@243: # rc_failed set local and overall rc status to failed fp@243: # rc_failed set local and overall rc status to fp@243: # rc_reset clear both the local and overall rc status fp@243: # rc_exit exit appropriate to overall rc status fp@243: # rc_active checks whether a service is activated by symlinks fp@243: . /etc/rc.status fp@169: fp@243: # Reset status of this service fp@243: rc_reset fp@169: fp@243: # Return values acc. to LSB for all commands but status: fp@243: # 0 - success fp@243: # 1 - generic or unspecified error fp@243: # 2 - invalid or excess argument(s) fp@243: # 3 - unimplemented feature (e.g. "reload") fp@243: # 4 - user had insufficient privileges fp@243: # 5 - program is not installed fp@243: # 6 - program is not configured fp@243: # 7 - program is not running fp@243: # 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) fp@243: # fp@243: # Note that starting an already running service, stopping fp@243: # or restarting a not-running service as well as the restart fp@243: # with force-reload (in case signaling is not supported) are fp@243: # considered a success. fp@169: fp@243: case "$1" in fp@243: start) fp@243: echo -n "Starting EtherCAT master... " fp@169: fp@243: # remove incompatible modules fp@243: for mod in 8139too 8139cp; do fp@243: if lsmod | grep "^$mod " > /dev/null; then fp@243: if ! rmmod $mod; then fp@243: /bin/false fp@243: rc_status -v fp@243: rc_exit fp@243: fi; fp@243: fi; fp@243: done fp@174: fp@243: modprobe ec_8139too ec_device_index=$DEVICEINDEX fp@174: fp@243: rc_status -v fp@169: ;; fp@174: fp@169: stop) fp@243: echo -n "Shutting down EtherCAT master... " fp@243: fp@243: for mod in ec_8139too ec_master; do fp@243: if lsmod | grep "^$mod " > /dev/null; then fp@243: if ! rmmod $mod; then fp@243: /bin/false fp@243: rc_status -v fp@243: rc_exit fp@243: fi; fp@243: fi; fp@243: done fp@243: fp@169: if ! modprobe 8139too; then fp@169: echo "Warning: Failed to restore 8139too module." fp@169: fi fp@243: fp@243: rc_status -v fp@169: ;; fp@174: fp@243: restart) fp@243: $0 stop fp@243: $0 start fp@243: fp@243: rc_status fp@243: ;; fp@169: esac fp@243: rc_exit fp@169: fp@169: #------------------------------------------------------------------------------