summaryrefslogtreecommitdiff
blob: 4743e6b0ade244b5325bdf44ea4ffcc0e33654b5 (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
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-dialup/speedtouch/files/speedtouch.rc7,v 1.2 2004/09/28 01:23:20 swegener Exp $

depend() {
	need localmount modules
}

start() {
	ebegin "Starting Speedtouch ADSL Modem..."

	ps -e | grep -q modem_run
	if [ $? -eq 0 ]; then
		einfo "Firmware already loaded, skipping load"
	else

		einfo "Loading firmware..."

		if [ -z "${MICROCODE}" ]; then
			eend 1 "Please define \$MICROCODE in /etc/conf.d/speedtouch"
			return 1
		fi
		if [ ! -f ${MICROCODE} ]; then
			eend 1 "Failed to find the microcode."
			return 1
		fi
		# usbdevfs is up ?
		if [ ! -f /proc/bus/usb/devices ]; then
			eend 1 "usbdevfs not mounted"
			return 1
		fi

		modem_run -v $VERBOSE $MODEM_RUN_EXTRAOPTS -f $MICROCODE
		if [ $? -ne 0 ]; then		# modem_run CAN'T run
			eerror "Can't load the microcode !!" 
			eerror "Please detach and attach again your modem to the USB port to unload the microcode."
			eerror "Then run '/etc/init.d/speedtouch start'"
			eend 1 "Speedtouch firmward load failed"
			return 1 
		fi

		
		einfo "Speedtouch firmware loaded"
		eend 0
	fi

	if [ ! -f "/etc/ppp/peers/$PEER" ]; then
		eend 1 "Failed to find peer configuration"
		return 1
	fi

	einfo "Launching the PPP daemon..."
	rm -f /var/run/pppoa*.pid
	start-stop-daemon --start \
		--exec /usr/sbin/pppd call $PEER &>/dev/null

	eend $? "Failed to start the PPP daemon"
}

stop() {
	ebegin "Shutting down the SpeedTouch ADSL Modem..."

	start-stop-daemon --stop --pidfile /var/run/ppp0.pid pppd

	eend $? "Failed to stop 'pppd'."
}