-
Notifications
You must be signed in to change notification settings - Fork 1
/
wwan
executable file
·46 lines (43 loc) · 1.03 KB
/
wwan
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
#!/bin/sh -e
case "$2" in
start)
until timeout 10 mbim "$1" open; do
[ $? -ne 124 ] && exit 1
done
mbim "$1" subscriber >/dev/null
mbim "$1" connect "${3:-internet}" "${@:4}" >/dev/null
mbim "$1" config | while read -r KEY VALUE; do
case "$KEY" in
interface)
IF=$VALUE
ip address flush "$IF" scope global
ip link set "$IF" up
;;
address)
[ -n "$IF" ] && ip address add "$VALUE" dev "$IF"
;;
gateway)
[ -n "$IF" ] && ip route add default via "$VALUE"
;;
mtu)
[ -n "$IF" ] && ip link set "$IF" mtu "$VALUE"
;;
esac
done
;;
stop)
mbim "$1" interface 2>/dev/null | while read -r KEY VALUE; do
case "$KEY" in
interface)
ip address flush "$VALUE" scope global
ip link set "$VALUE" down
;;
esac
done
timeout 1 mbim "$1" close
;;
*)
echo "Usage: $(basename "$0") DEVICE start|stop" >&2
exit 64
;;
esac