ethercat.sh
author Florian Pose <fp@igh-essen.com>
Fri, 07 Apr 2006 14:19:20 +0000
changeset 171 faa7d433239c
parent 169 b3ecbec2c487
child 174 99907332ff1e
permissions -rwxr-xr-x
Added README file and altered outputs of install.sh
#!/bin/sh

#------------------------------------------------------------------------------
#
#  EtherCAT rc script
#
#  $Id$
#
#------------------------------------------------------------------------------

CONFIGFILE=/etc/sysconfig/ethercat

#------------------------------------------------------------------------------

print_usage()
{
    echo "Usage $0 { start | stop }"
}

unload_module()
{
    if lsmod | grep ^$1 > /dev/null; then
	echo "  unloading module \"$1\"..."
	rmmod $1 || exit 1
    fi
}

#------------------------------------------------------------------------------

# Get parameters
if [ $# -eq 0 ]; then
    print_usage
    exit 1
fi

ACTION=$1

# Load configuration from sysconfig

if [ -f $CONFIGFILE ]; then
    . $CONFIGFILE
else
    echo "ERROR: Configuration file \"$CONFIGFILE\" not found!"
    exit 1
fi

case $ACTION in
    start)
	echo "Starting EtherCAT master..."
	# remove modules
	unload_module 8139too
	unload_module 8139cp
	unload_module ec_8139too
	unload_module ec_master
	echo "  loading master modules..."
	if ! modprobe ec_8139too ec_device_index=$DEVICEINDEX; then
	    echo "ERROR: Failed to load module!"
	    exit 1
	fi
	;;
    stop)
	echo "Stopping EtherCAT master..."
	unload_module ec_8139too
	unload_module ec_master
	if ! modprobe 8139too; then
	    echo "Warning: Failed to restore 8139too module."
	fi
	;;
    *)
	print_usage
	exit 1
esac

echo "done."
exit 0

#------------------------------------------------------------------------------