blob: d08beda31c92fca80a1644bb84fb25cce2ee932f (
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
|
#!/bin/sh
[ "$IFACE" == "hso0" ] || exit 0
TTY=${IF_HSO_DEVICE:-/dev/ttyHS0}
# wait for card to initialize
COUNT=0
while [ $((COUNT++)) -lt 20 ]; do
[ -c "$TTY" ] && break
[ $COUNT -eq 20 ] && {
logger "$0: '$TTY' not found"
exit 1
}
sleep 1
done
if [ "$IF_PIN" ]; then
COMGTPIN="$IF_PIN" comgt -d "$TTY" PIN
fi
if [ "$IF_APN" ]; then
COMGTAPN="$IF_APN" comgt -d "$TTY" APN
fi
# only run once!
[ -f /tmp/hso-connect ] && exit 0
while :
do
# get connection status
STATUS=$(comgt -s -d "$TTY" /etc/comgt/hsostatus.comgt |
tr -d " " |
grep -v ^$ |
cut -d , -f 2)
# dial if connection status is disabled
if [ "$STATUS" -eq "0" ] ; then
comgt -s -d "$TTY" /etc/comgt/hsoconnect.comgt
DATA=$(comgt -s -d "$TTY" /etc/comgt/hsodata.comgt)
if [ "$?" -ne 0 ] ; then
continue
fi
DATA=$(echo $DATA |
tr -d " " |
grep -v ^$)
IP=$(echo $DATA | cut -d , -f 2)
NS1=$(echo $DATA | cut -d , -f 4)
NS2=$(echo $DATA | cut -d , -f 5)
ip address flush dev hso0 2> /dev/null
ip address add "$IP/32" dev hso0
ip link set hso0 up
def=$(ip route show |grep default | wc -l)
[ $def -eq 1 ] && ip route del default
ip route add default dev hso0
echo "nameserver $NS1" > /etc/resolv.conf
echo "nameserver $NS2" >> /etc/resolv.conf
. /etc/rc.conf
# get time via ntpclient if available
[ -x /usr/sbin/ntpclient ] && ntpclient -s -h pool.ntp.org
# get time via rdate if available
[ -x /usr/sbin/rdate ] && rdate -nv pool.ntp.org
# restart ntpd when enabled
test x"${ntpd:-NO}" = x"NO" || /etc/init.d/ntpd restart
fi
sleep 10
done &
echo $! > /tmp/hso-connect
|