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@169: CONFIGFILE=/etc/sysconfig/ethercat fp@169: fp@169: #------------------------------------------------------------------------------ fp@169: fp@169: print_usage() fp@169: { fp@174: echo "Usage: $0 { start | stop | restart }" fp@169: } fp@169: fp@169: unload_module() fp@169: { fp@169: if lsmod | grep ^$1 > /dev/null; then fp@169: echo " unloading module \"$1\"..." fp@169: rmmod $1 || exit 1 fp@169: fi fp@169: } fp@169: fp@169: #------------------------------------------------------------------------------ fp@169: fp@169: # Get parameters fp@169: if [ $# -eq 0 ]; then fp@169: print_usage fp@169: exit 1 fp@169: fi fp@169: fp@169: ACTION=$1 fp@169: fp@169: # Load configuration from sysconfig fp@169: fp@169: if [ -f $CONFIGFILE ]; then fp@169: . $CONFIGFILE fp@169: else fp@169: echo "ERROR: Configuration file \"$CONFIGFILE\" not found!" fp@169: exit 1 fp@169: fi fp@169: fp@169: case $ACTION in fp@174: start | restart) fp@169: echo "Starting EtherCAT master..." fp@174: fp@169: # remove modules fp@169: unload_module 8139too fp@169: unload_module 8139cp fp@169: unload_module ec_8139too fp@169: unload_module ec_master fp@174: fp@169: echo " loading master modules..." fp@169: if ! modprobe ec_8139too ec_device_index=$DEVICEINDEX; then fp@169: echo "ERROR: Failed to load module!" fp@169: exit 1 fp@169: fi fp@169: ;; fp@174: fp@169: stop) fp@169: echo "Stopping EtherCAT master..." fp@169: unload_module ec_8139too fp@169: unload_module ec_master fp@169: if ! modprobe 8139too; then fp@169: echo "Warning: Failed to restore 8139too module." fp@169: fi fp@169: ;; fp@174: fp@169: *) fp@169: print_usage fp@169: exit 1 fp@169: esac fp@169: fp@169: echo "done." fp@169: exit 0 fp@169: fp@169: #------------------------------------------------------------------------------