summaryrefslogtreecommitdiff
path: root/package/tapi_sip/files/telephony.init
blob: 082024c236d1f5f937f6b29722b5394c257891e3 (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
#!/bin/sh /etc/rc.common
START=80

download_fw()
{
	config_load telephony
	config_get fw_url config fw_url
	config_get fw_file config fw_file
	wget $fw_url -O /tmp/$fw_file || {
		echo "failed to load $fw_url"
		exit 1
	}
}

load_module()
{
	M=`lsmod | grep vmmc`
	[ -z "$M" ] || return
	config_load telephony
	config_get fw_file config fw_file
	[ -z "fw_file" ] && exit 1
	F=/lib/firmware/$fw_file
	[ ! -f "$F" -a ! -L "$F" ] && {
		echo "missing firmware file"
		exit 1
	}
	[ -L "$F" -a -f /tmp/$fw_file ] && F=/tmp/$fw_file
	insmod vmmc
	sleep 3
}

stop()
{
	killall tapi-sip 2>/dev/null
}

start()
{
	stop
	config_load telephony
	config_get fw_url config fw_url
	config_get fw_file config fw_file
	config_get netdev config netdev
	config_get disable config disable
	[ "$disable" != "1" ]  && {
		[ ! -z "$fw_url" -a ! -f "/tmp/$fw_file" ] && download_fw
		load_module
		/usr/bin/tapi-sip $netdev &
	}
}