File: init

package info (click to toggle)
pcmciautils 015-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 332 kB
  • ctags: 792
  • sloc: ansic: 3,812; sh: 279; lex: 219; makefile: 218; yacc: 104
file content (132 lines) | stat: -rw-r--r-- 2,331 bytes parent folder | download
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#! /bin/sh
#
### BEGIN INIT INFO
# Provides:          pcmcia
# Required-Start:    $local_fs
# Required-Stop:
# Should-Start:      udev
# X-Start-Before:    networking
# Default-Start:     S
# Default-Stop:
# Short-Description: PCMCIA support
# Description:       This service provides PCMCIA hardware support for
#                    systems running Linux >= 2.6.13-rc1.
### END INIT INFO

set -e

[ -f /sbin/pccardctl ] || exit 0

# If /lib/lsb/init-functions doesn't exist
# define them here, otherwise installer breaks
if [ -f /lib/lsb/init-functions ]; then
    . /lib/lsb/init-functions
else
    log_daemon_msg()
    {
	echo "$1: $2"
    }
    log_end_msg()
    {
	if [ "$1" = 0 ]; then
	    echo "done"
	else
	    echo "failed!"
	fi
	return $1
    }
    log_success_msg()
    {
	echo "$@"
    }
    log_failure_msg()
    {
	echo "$@"
    }
fi

[ -f /etc/default/pcmciautils ] && . /etc/default/pcmciautils

case $PCMCIA in
    no|false)
	exit 0
	;;
esac

[ -f /etc/default/rcS ] && . /etc/default/rcS

# Are we running from init?
run_by_init()
{
    ([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
}

if ls /sys/class/pcmcia_socket/* >/dev/null 2>&1; then
    if ! run_by_init; then
	log_success_msg "PCMCIA bridge driver already present in kernel"
    fi
    exit 0
fi

KERNEL_VERSION="$(uname -r | sed 's/-.*//')"

supported_kernel()
{
    case $KERNEL_VERSION in
	2.[012345].*|2.6.[0-9]|2.6.[0-9][!0-9]*) return 1 ;;
	2.6.1[012]|2.6.1[012][!0-9]*) return 1 ;;
    esac
    return 0
}

if ! supported_kernel; then
    log_failure_msg "pcmciautils requires Linux >= 2.6.13-rc1; use pcmcia-cs instead"
    exit 1
fi

if [ -z "$PCIC" ]; then
    if ! run_by_init; then
	log_failure_msg "No PCMCIA bridge module specified"
    fi
    exit 0
fi

if [ "$VERBOSE" = "no" ]; then
    MODPROBE_OPTIONS="$MODPROBE_OPTIONS -Q"
    export MODPROBE_OPTIONS
fi

case "$1" in
    start)
	log_daemon_msg "Loading PCMCIA bridge driver module" "$PCIC"

	if [ "$CORE_OPTS" ]; then
	    modprobe -qb pcmcia_core $CORE_OPTS
	fi
	
	modprobe -b $PCIC $PCIC_OPTS
	
	if ! [ -e /dev/.udev ]; then
	    modprobe -qb pcmcia
	fi

	log_end_msg $?
	;;

    stop)
	;;
    
    restart)
	$0 stop
	$0 start
	exit $?
	;;

    reload|force-reload)
	;;

    *)
	log_success_msg "Usage: $0 {start|stop|restart|reload|force-reload}"
	exit 2
	;;
esac