summaryrefslogtreecommitdiff
blob: 83756aab750fb24332d678579aa548290de53e00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/sbin/runscript
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/pcmcia-cs/files/pcmcia.rc,v 1.3 2003/02/14 23:26:37 vapier Exp $

RUN=/var/run
SC=${RUN}/pcmcia-scheme

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

start() {
	local code
	# Scheme is set for the /etc/pcmcia/shared script
	if [ -n "${SCHEME}" ] ; then umask 022 ; echo $SCHEME > ${SC}
	else umask 022 ; touch ${SC}
	fi

	# clean up any old interfaces
	if [ -r ${RUN}/stab ] ; then
		cat ${RUN}/stab | cleanup
	fi
	# if /var/lib/pcmcia exists (and sometimes it gets created accidentally
	# if you run pcmcia-cs apps w/out the proper flags), then it will really
	# confuse the process
	if [ -d /var/lib/pcmcia ] ; then
		rm -rf /var/lib/pcmcia
	fi

	if [ -z `fgrep "ds " /proc/modules | head -1 | cut -c1` ] ; then
		/sbin/modprobe pcmcia_core $CORE_OPTS 2> /dev/null
		/sbin/modprobe $PCIC $PCIC_OPTS 2> /dev/null
		/sbin/modprobe ds
	fi

	ebegin "Starting pcmcia"
	start-stop-daemon --start --quiet --exec /sbin/cardmgr -- -s ${RUN}/stab ${CARDMGR_OPTS}
	code=$?	
	if [ $code -gt 0 ] ; then
		einfo "cardmgr failed to start.  Make sure that you have PCMCIA"
		einfo "modules built or support compiled into the kernel"
	fi
	eend $code
}

stop() {
	local code

	if [ -w ${SC} ] ; then rm -f ${SC} ; fi

	ebegin "Stopping pcmcia"
	start-stop-daemon --stop --quiet --pidfile /var/run/cardmgr.pid --retry 5
	code=$?	

	if [ -n `fgrep "ds " /proc/modules | head -1 | cut -c1` ]; then
		/sbin/rmmod ds 2> /dev/null
		/sbin/rmmod $PCIC 2> /dev/null
		/sbin/rmmod pcmcia_core 2> /dev/null
	fi
	
	eend $code
}