#!/bin/sh # # rc.pcmcia 1.23 1998/07/18 18:49:26 (David Hinds) # # This is designed to work in BSD as well as SysV init setups. See # the HOWTO for customization instructions. 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 if [ "$PCMCIA" != "yes" ] ; then exit 0 ; fi else # Should be either i82365 or tcic. The "probe" option is a Slackware # addition which tries loading both modules; usually one or the other # will load if a PCMCIA subsystem is present. Of course, the correct # thing to do is to pick i82365 or tcic manually. PCIC=i82365 # PCIC=tcic # PCIC=probe # Put socket driver timing parameters here. # "poll_interval=100" will save an IRQ. PCIC_OPTS="do_scan=0 poll_interval=100" # Put pcmcia_core options here CORE_OPTS= # Put cardmgr options here CARDMGR_OPTS= # To set the PCMCIA scheme at startup... SCHEME= 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 ; echo > $SC ; fi if [ "$SCHEME" ] ; then umask 022 ; echo $SCHEME > $SC ; fi fgrep -q pcmcia /proc/devices if [ $? -ne 0 ] ; then PC=/lib/modules/`uname -r`/pcmcia if [ -d $PC ] ; then echo -n " modules" /sbin/insmod pcmcia_core $CORE_OPTS 2> /dev/null if [ "$PCIC" = "probe" ]; then # attempt to load both echo " " /sbin/insmod i82365 $PCIC_OPTS 2> /dev/null if [ ! $? = 0 ]; then # try tcic /sbin/insmod tcic $PCIC_OPTS 2> /dev/null fi else # PCIC has been selected manually /sbin/insmod $PCIC $PCIC_OPTS 2> /dev/null fi /sbin/insmod ds 2> /dev/null 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 if [ "$PCIC" = "probe" ]; then /sbin/rmmod i82365 /sbin/rmmod tcic else /sbin/rmmod $PCIC fi /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