Previous Page | Next Page

  1. Introduction
  2. Boot Process
  3. Init and System Initialization
  4. rc.sysinit script
  5. rc script
  6. functions script
  7. Services
  8. apm daemon
  9. network startup
  10. The network script file
  11. The network-functions file
  12. Portmap startup
  13. Random initialization
  14. Syslog initialization
  15. Gated
  16. Atd
  17. cron initialization
  18. pcmcia
  19. inetd daemon
  20. named daemon
  21. lpd daemon
  22. mars-nwe
  23. netfs startup
  24. dhcpd daemon
  25. autofs daemon
  26. keytable daemon
  27. sendmail daemon
  28. gpm daemon
  29. httpd daemon
  30. xfs startup
  31. smb startup
  32. innd startup
  33. linuxconf startup
  34. rc.local script
  35. Init, Getty, Login
  36. The shell
  37. Shutting down
  38. X
  39. Conclusions
  40. App A. rc.sysinit listing
  41. App B. functions listing
  42. App C. rc listing
  43. Credits

Linux PCMCIA

The PCMCIA startup script

#!/bin/sh
#
# rc.pcmcia 1.26 1999/04/15 03:02:41 (David Hinds)
#
# This is designed to work in BSD as well as SysV init setups.  See
# the HOWTO for customization instructions.
#
# chkconfig: 2345 45 96
# description: PCMCIA support is usually to support things like ethernet \
#              and modems in laptops.  It won't get started unless \
#              configured so it is safe to have it installed on machines \
#              that don't need it.
#

usage()
{
    echo "Usage: $0 {start|stop|restart}"
}

cleanup()
{
    while read SN CLASS MOD INST DEV EXTRA ; do
	if [ "$SN" != "Socket" ] ; then
	    /etc/pcmcia/$CLASS stop $DEV 2> /dev/null
	fi
    done
}

# Allow environment variables to override all options
if [ "$PCMCIA" ] ; then readonly PCMCIA ; fi
if [ "$PCIC" ] ; then readonly PCIC ; fi
if [ "$PCIC_OPTS" ] ; then readonly PCIC_OPTS ; fi
if [ "$CORE_OPTS" ] ; then readonly CORE_OPTS ; fi
if [ "$CARDMGR_OPTS" ] ; then readonly CARDMGR_OPTS ; fi
if [ "$SCHEME" ] ; then readonly SCHEME ; fi

# Source PCMCIA configuration, if available
if [ -f /etc/pcmcia.conf ] ; then
    . /etc/pcmcia.conf
elif [ -f /etc/sysconfig/pcmcia ] ; then
    . /etc/sysconfig/pcmcia
else
    # Should be either i82365 or tcic
    PCIC=i82365
    # Put socket driver timing parameters here
    PCIC_OPTS=
    # Put pcmcia_core options here
    CORE_OPTS=
    # Put cardmgr options here
    CARDMGR_OPTS=
    # To set the PCMCIA scheme at startup...
    SCHEME=
fi
if [ "$PCMCIA" -a "$PCMCIA" != "yes" ] ; then exit 0 ; fi

EXITCODE=1
for x in "1" ; do

    if [ "$PCIC" = "" ] ; then
	echo "PCIC not defined in rc.pcmcia!"
	break
    fi

    if [ $# -lt 1 ] ; then usage ; break ; fi
    action=$1

    case "$action" in

    'start')
	echo -n "Starting PCMCIA services:"
	SC=/var/run/pcmcia-scheme
	if [ -L $SC -o ! -O $SC ] ; then rm -f $SC ; fi
	if [ ! -f $SC ] ; then umask 022 ; touch $SC ; fi
	if [ "$SCHEME" ] ; then umask 022 ; echo $SCHEME > $SC ; fi
	fgrep -q pcmcia /proc/devices
	if [ $? -ne 0 ] ; then
	    if [ -d /lib/modules/preferred ] ; then
		PC=/lib/modules/preferred/pcmcia
	    else
		PC=/lib/modules/`uname -r`/pcmcia
	    fi
	    if [ -d $PC ] ; then
		echo -n " modules"
		/sbin/insmod $PC/pcmcia_core.o $CORE_OPTS
		/sbin/insmod $PC/$PCIC.o $PCIC_OPTS
		/sbin/insmod $PC/ds.o
	    else
		echo " module directory $PC not found."
		break
	    fi
	fi
	if [ -s /var/run/cardmgr.pid ] && \
	    kill -0 `cat /var/run/cardmgr.pid` 2>/dev/null ; then
	    echo " cardmgr is already running."
	else
	    if [ -r /var/run/stab ] ; then
		cat /var/run/stab | cleanup
	    fi
	    echo " cardmgr."
	    /sbin/cardmgr $CARDMGR_OPTS
	fi
	if [ -d /var/lock/subsys ] ; then
	    touch /var/lock/subsys/pcmcia
	fi
	;;

    'stop')
	echo -n "Shutting down PCMCIA services:"
	PID=`cat /var/run/cardmgr.pid`
	kill $PID
	echo -n " cardmgr"
	# Give cardmgr a few seconds to handle the signal
	kill -0 $PID 2>/dev/null && sleep 2 && \
	kill -0 $PID 2>/dev/null && sleep 2 && \
	kill -0 $PID 2>/dev/null && sleep 2 && \
	kill -0 $PID 2>/dev/null 
	if fgrep -q "ds  " /proc/modules ; then
	    echo -n " modules"
	    /sbin/rmmod ds
	    /sbin/rmmod $PCIC
	    /sbin/rmmod pcmcia_core
	fi
	echo "."
	rm -f /var/lock/subsys/pcmcia
	EXITCODE=0
	;;

    'restart')
	$0 stop
	$0 start
	EXITCODE=0
	;;

    *)
	usage
	;;

    esac

done

# Only exit if we're in our own subshell
if [ "${0##*/}" = "rc.pcmcia" ] ; then
    exit $EXITCODE
fi