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

View File

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

View File

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

View File

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