Created scripts directory and improved install and init scripts.

This commit is contained in:
Florian Pose
2006-05-19 09:56:55 +00:00
parent 1ff86791ee
commit c821aa3f6d
6 changed files with 86 additions and 52 deletions

View File

@@ -33,34 +33,32 @@
#
#------------------------------------------------------------------------------
ifneq ($(KERNELRELEASE),)
#------------------------------------------------------------------------------
# kbuild section
ifneq ($(KERNELRELEASE),)
obj-m := master/ devices/
#------------------------------------------------------------------------------
# default section
else
#------------------------------------------------------------------------------
# default section
ifneq ($(wildcard ethercat.conf),)
include ethercat.conf
else
KERNEL := `uname -r`
DEVICEINDEX := 99
KERNEL := $(shell uname -r)
endif
KERNELDIR := /lib/modules/$(KERNEL)/build
KERNEL_DIR := /lib/modules/$(KERNEL)/build
CURRENT_DIR := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=`pwd`
$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR)
clean: cleandoc
$(MAKE) -C $(KERNELDIR) M=`pwd` clean
$(MAKE) -C $(KERNEL_DIR) M=$(CURRENT_DIR) clean
doc:
doxygen Doxyfile
@@ -69,7 +67,7 @@ cleandoc:
@rm -rf doc
install:
@./install.sh $(KERNEL) $(DEVICEINDEX)
@script/install.sh $(KERNEL)
#------------------------------------------------------------------------------

View File

@@ -9,10 +9,9 @@
#
#------------------------------------------------------------------------------
#
# The kernel to compile the EtherCAT sources against
#
KERNEL := `uname -r`
# PCI index of the EtherCAT device
DEVICEINDEX := 99
#------------------------------------------------------------------------------

View File

@@ -64,7 +64,14 @@ rc_reset
case "$1" in
start)
echo -n "Starting EtherCAT master... "
echo -n "Starting EtherCAT master "
if [ ! $DEVICE_INDEX ]; then
echo "ERROR: DEVICE_INDEX not set!"
/bin/false
rc_status -v
rc_exit
fi
for mod in 8139too 8139cp; do
if lsmod | grep "^$mod " > /dev/null; then
@@ -72,17 +79,17 @@ case "$1" in
/bin/false
rc_status -v
rc_exit
fi;
fi;
fi
fi
done
modprobe ec_8139too ec_device_index=$DEVICEINDEX
modprobe ec_8139too ec_device_index=$DEVICE_INDEX
rc_status -v
;;
stop)
echo -n "Shutting down EtherCAT master... "
echo -n "Shutting down EtherCAT master "
for mod in ec_8139too ec_master; do
if lsmod | grep "^$mod " > /dev/null; then
@@ -109,7 +116,7 @@ case "$1" in
;;
status)
echo -n "Checking for EtherCAT... "
echo -n "Checking for EtherCAT "
lsmod | grep "^ec_master " > /dev/null
master_running=$?

View File

@@ -35,71 +35,80 @@
#
#------------------------------------------------------------------------------
CONFIGFILE=/etc/sysconfig/ethercat
# Fetch parameters
#------------------------------------------------------------------------------
# install function
install()
{
echo " $1"
if ! cp $1 $INSTALLDIR; then exit 1; fi
}
#------------------------------------------------------------------------------
# Fetch parameter
if [ $# -ne 2 ]; then
if [ $# -ne 1 ]; then
echo "This script is called by \"make\". Run \"make install\" instead."
exit 1
fi
KERNEL=$1
DEVICEINDEX=$2
INSTALLDIR=/lib/modules/$KERNEL/kernel/drivers/net
echo "EtherCAT installer - Kernel: $KERNEL"
if [ ! -d /lib/modules/$KERNEL ]; then
echo "Kernel \"$KERNEL\" does not exist in /lib/modules!"
exit 1
fi
#------------------------------------------------------------------------------
# Copy files
echo " installing modules..."
install master/ec_master.ko
install devices/ec_8139too.ko
INSTALLDIR=/lib/modules/$KERNEL/kernel/drivers/net
MODULES=(master/ec_master.ko devices/ec_8139too.ko)
echo "EtherCAT installer - Kernel: $KERNEL"
echo " Installing modules"
for mod in ${MODULES[*]}; do
echo " $mod"
cp $mod $INSTALLDIR || exit 1
done
#------------------------------------------------------------------------------
# Update dependencies
echo " building module dependencies..."
echo " Building module dependencies"
depmod
#------------------------------------------------------------------------------
# Create configuration file
if [ -f $CONFIGFILE ]; then
echo " notice: using existing configuration file."
CONFIGFILE=/etc/sysconfig/ethercat
if [ -s $CONFIGFILE ]; then
echo " Note: Using existing configuration file."
else
echo " creating $CONFIGFILE..."
echo "DEVICEINDEX=$DEVICEINDEX" > $CONFIGFILE || exit 1
echo " Creating $CONFIGFILE"
cp script/sysconfig $CONFIGFILE || exit 1
echo " Note: Please edit DEVICE_INDEX in $CONFIGFILE!"
fi
#------------------------------------------------------------------------------
# Install rc script
echo " installing startup script..."
cp ethercat.sh /etc/init.d/ethercat || exit 1
echo " Installing startup script"
cp script/ethercat.sh /etc/init.d/ethercat || exit 1
chmod +x /etc/init.d/ethercat || exit 1
if [ ! -L /usr/sbin/rcethercat ]; then
ln -s /etc/init.d/ethercat /usr/sbin/rcethercat || exit 1
fi
#------------------------------------------------------------------------------
# Install tools
echo " installing tools..."
cp tools/ec_list.pl /usr/local/bin/ec_list || exit 1
echo " Installing tools"
cp script/ec_list.pl /usr/local/bin/ec_list || exit 1
chmod +x /usr/local/bin/ec_list || exit 1
#------------------------------------------------------------------------------
# Finish
echo "EtherCAT installer done."
echo "Done"
exit 0
#------------------------------------------------------------------------------

21
script/sysconfig Normal file
View File

@@ -0,0 +1,21 @@
#------------------------------------------------------------------------------
#
# EtherCAT sysconfig file
#
# $Id$
#
#------------------------------------------------------------------------------
#
# PCI index of the (RTL8139-)EtherCAT device
# Setting this is mandatory for the EtherCAT init script!
#
#DEVICE_INDEX=99
#
# Number of Ethernet-over-EtherCAT devices the master shall create
# on startup. Default is 0.
#
#EOE_DEVICES=0
#------------------------------------------------------------------------------