[ifxmips]
[openwrt.git] / package / tapi_sip / files / telephony.init
1 #!/bin/sh /etc/rc.common
2 START=80
3
4 download_fw()
5 {
6         config_load telephony
7         config_get fw_url config fw_url
8         config_get fw_file config fw_file
9         wget $fw_url -O /tmp/$fw_file || {
10                 echo "failed to load $fw_url"
11                 exit 1
12         }
13 }
14
15 load_module()
16 {
17         M=`lsmod | grep vmmc`
18         [ -z "$M" ] || return
19         config_load telephony
20         config_get fw_file config fw_file
21         [ -z "fw_file" ] && exit 1
22         F=/lib/firmware/$fw_file
23         [ ! -f "$F" -a ! -L "$F" ] && {
24                 echo "missing firmware file"
25                 exit 1
26         }
27         [ -L "$F" -a -f /tmp/$fw_file ] && F=/tmp/$fw_file
28         insmod vmmc
29         sleep 3
30 }
31
32 stop()
33 {
34         killall tapi-sip 2>/dev/null
35 }
36
37 start()
38 {
39         stop
40         config_load telephony
41         config_get fw_url config fw_url
42         config_get fw_file config fw_file
43         config_get netdev config netdev
44         config_get disable config disable
45         [ "$disable" != "1" ]  && {
46                 [ ! -z "$fw_url" -a ! -f "/tmp/$fw_file" ] && download_fw
47                 load_module
48                 /usr/bin/tapi-sip $netdev &
49         }
50 }