forked from danielewood/sierra-wireless-modems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsprint_fix.sh
51 lines (48 loc) · 1.49 KB
/
sprint_fix.sh
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
#!/bin/sh
rm -f /tmp/cellid
while [ ! -f /tmp/cellid ]
do
LCELL=`grep -m 1 "Cell ID" /tmp/atlog | cut -d "(" -f3 | cut -d ")" -f1`
if [[ ${#LCELL} -gt 1 ]]
then
echo $LCELL > /tmp/cellid
fi
sleep 5
done
while true
do
DATE=$(date +%c)
if grep -i -m 1 -q 'at!band=\d\d' /tmp/atlog
then
/sbin/ifdown wan1 ; /sbin/ifup wan1
echo "$DATE : Cell was changed manually." >> /usr/lib/rooter/log/connect.log
echo "$DATE : Reset WAN1 interface to restore connection." >> /usr/lib/rooter/log/connect.log
while grep -i -m 1 -q "at!band=\d\d" /tmp/atlog
do
sleep 5
done
LCELL=`grep -m 1 "Cell ID" /tmp/atlog | cut -d "(" -f3 | cut -d ")" -f1`
while [ ${#LCELL} -lt 4 ]
do
LCELL=`grep -m 1 "Cell ID" /tmp/atlog | cut -d "(" -f3 | cut -d ")" -f1`
sleep 5
done
ICELL=`cat /tmp/cellid`
if [[ "$ICELL" = "$LCELL" ]]
then
/sbin/ifdown wan1 ; /sbin/ifup wan1
fi
echo $LCELL > /tmp/cellid
else
LCELL=`cat /tmp/cellid`
ACELL=`grep -m 1 "Cell ID" /tmp/atlog | cut -d "(" -f3 | cut -d ")" -f1`
if [[ ${#ACELL} -gt 1 && "$ACELL" != "$LCELL" ]]
then
/sbin/ifdown wan1 ; /sbin/ifup wan1
echo "$DATE : Cell ID changed from $LCELL to $ACELL." >> /usr/lib/rooter/log/connect.log
echo "$DATE : Reset WAN1 interface to restore connection." >> /usr/lib/rooter/log/connect.log
echo $ACELL > /tmp/cellid
fi
fi
sleep 5
done