Ticket #34: p

File p, 1.7 KB (added by rysiek, 3 years ago)

pppd gsm muxer persistence hack

Line 
1#!/bin/sh
2# (C) 2008 Bearstech, LGPLv2, Marcus Bauer
3# "persistence" changes by Michał 'rysiek' Woźniak <rysiek@brama.elka.pw.edu.pl>
4#
5# The script starts the pppd.
6# The gsm modem must be registered to the network before
7# running it.
8
9#
10# look for providers in /etc/ppp/peers
11#
12PROVIDER="france-orange"
13
14#
15# if gsmd0710muxd is running this must be "yes"
16#
17MUX=yes
18PERSIST=yes
19
20# utility function - getting the muxed modem dev from the gsm muxer
21get_mux_dev() {
22        dbus-send  --system --print-reply --type=method_call --dest=org.pyneo.muxer /org/pyneo/Muxer org.freesmartphone.GSM.MUX.AllocChannel "string:GSM" | awk -F '"' '{ print $2 }'
23}
24
25# let the user know what's happening
26echo "The GSM must be registered to the network before starting pppd"
27echo "If it is not up in 20 seconds, kill it with Ctrl-C and start again"
28
29# muxed?
30if [ $MUX = no ]; then
31
32        # nope, just kill the gsmd and set the default modem dev
33        killall -9 gsmd
34        PPPDEV="/dev/ttySAC0"
35
36else
37
38        # aye, muxed - get the muxed modem dev
39        PPPDEV=`get_mux_dev`
40
41fi
42
43# some debug info
44echo "GSMMUX: $MUX; PERSISTENT: $PERSIST; ppp device: $PPPDEV"
45
46
47#
48# start pppd, by default it is France Orange
49#  see /etc/ppp/peers/france-orange as example
50#
51
52# are we supposed to persist?
53if [ $PERSIST = yes ]; then
54
55        # yes - looping, then
56        while true; do
57
58                # calling pppd and - after the connection dies - waiting some time for the modem to reset
59                pppd $PPPDEV call $PROVIDER
60                sleep 5
61
62                # do we need to get a new muxed modem dev every time?
63                if [ $MUX = yes ]; then
64                        # aye, we do!
65                        PPPDEV=`get_mux_dev`
66                        echo "GSMMUX: $MUX; PERSISTENT: $PERSIST; ppp device: $PPPDEV"
67                fi
68
69        done
70
71else
72
73        # nah, just connect once
74        pppd $PPPDEV call $PROVIDER
75
76fi