| 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 | # |
|---|
| 12 | PROVIDER="france-orange" |
|---|
| 13 | |
|---|
| 14 | # |
|---|
| 15 | # if gsmd0710muxd is running this must be "yes" |
|---|
| 16 | # |
|---|
| 17 | MUX=yes |
|---|
| 18 | PERSIST=yes |
|---|
| 19 | |
|---|
| 20 | # utility function - getting the muxed modem dev from the gsm muxer |
|---|
| 21 | get_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 |
|---|
| 26 | echo "The GSM must be registered to the network before starting pppd" |
|---|
| 27 | echo "If it is not up in 20 seconds, kill it with Ctrl-C and start again" |
|---|
| 28 | |
|---|
| 29 | # muxed? |
|---|
| 30 | if [ $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 | |
|---|
| 36 | else |
|---|
| 37 | |
|---|
| 38 | # aye, muxed - get the muxed modem dev |
|---|
| 39 | PPPDEV=`get_mux_dev` |
|---|
| 40 | |
|---|
| 41 | fi |
|---|
| 42 | |
|---|
| 43 | # some debug info |
|---|
| 44 | echo "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? |
|---|
| 53 | if [ $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 | |
|---|
| 71 | else |
|---|
| 72 | |
|---|
| 73 | # nah, just connect once |
|---|
| 74 | pppd $PPPDEV call $PROVIDER |
|---|
| 75 | |
|---|
| 76 | fi |
|---|