SourceForge.net Logo

B.17. /etc/init.d/gpio

#!/bin/ash
#
# GPL $Id: gpio,v 1.2 2005/10/09 16:39:04 cvonk Exp $
# system init for general purpose i/o (gpio)

DEVICE=gpio

. /etc/sysconfig/gpio.conf
if [ "$GPIO_TYPE" = "scx200" ] ; then
    #MODULE_MAIN=scx200 # will already have been loaded by watchdog
    MODULE_GPIO=scx200_gpio
fi

case "$1" in
    start)
	if [ "$GPIO_TYPE" = "scx200" ] ; then
	    RELEASE=`uname -r`
	    #insmod /lib/modules/${RELEASE}/kernel/arch/i386/kernel/${MODULE_MAIN}.ko
	    modprobe ${MODULE_GPIO}
	    rm -f /dev/${DEVICE}-*
	    MAJOR=`awk "\\$2==\"$MODULE_GPIO\" { print \\$1}" /proc/devices`
	    mknod /dev/${DEVICE}-led1  c $MAJOR 2
	    mknod /dev/${DEVICE}-led2  c $MAJOR 3
	    mknod /dev/${DEVICE}-led3  c $MAJOR 18
	    mknod /dev/${DEVICE}-reset c $MAJOR 40
	fi
        ;;
    restart)
	$0 stop
	$0 start
	;;
    stop)
	if [ "$GPIO_TYPE" = "scx200" ] ; then
	    rm -rf /dev/${DEVICE}-*
	    rmmod ${MODULE_GPIO}
	    #rmmod ${MODULE_MAIN}
	fi
        ;;
    status)
        lsmod | grep "$GPIO_TYPE"
        ;;
esac

Example B.17. /etc/init.d/gpio