Find the answer to your Linux question:
Results 1 to 2 of 2
I have mobile broadband working well with my Linux (xandros), when I plug in the dongle the following script automatically connect to the network. #!/bin/bash #connect to 3Mobile network when ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! spg666's Avatar
    Join Date
    Dec 2008
    Location
    UK
    Posts
    24

    Mobile broadband, reconnecting when the connection is dropped


    I have mobile broadband working well with my Linux (xandros), when I plug in the dongle the following script automatically connect to the network.

    #!/bin/bash
    #connect to 3Mobile network when the modem is installed
    /bin/su -c 'export DISPLAY=:0; /usr/bin/xandrosncs-proxy --request-start dialup1 &'

    the script is called from udev rule.

    Now what I would like to do if find a way of automatically reconnecting if I loose the connection (when the train goes through a tunnel for example), any Ideas?

  2. #2
    Just Joined! spg666's Avatar
    Join Date
    Dec 2008
    Location
    UK
    Posts
    24

    Solved

    As no solution was forth coming, I figured out the solution the hard way. I put the following script into /ect/ppp/ip-down.d

    #! /bin/bash

    export DISPLAY=:0.0

    MYNETSTART=/home/user/.reconnect

    if [ -x $MYNETSTART ]; then
    su -c "$MYNETSTART" user
    fi

    this calls the following script in my home folder:

    #!/bin/sh
    #this script is run when the modem disconnects

    #check the reason for the connection dropping,exit script if the modem is removed
    if eval "lsusb -d 12d1:1003"; then
    kdialog --title "Network Status" --passivepopup "Connection to the mobile network has been lost" 5
    else
    kdialog --title "Network Status" --passivepopup "Modem Unplugged" 5
    exit 0
    fi

    #check internet connectivity,attempt to reconnect modem if unreachable
    i="0"
    while [ $i -le 0 ]
    do
    if eval "ping -c 1 8.8.8.8"; then
    i="1"
    else
    #check the modem is still there
    if eval "lsusb -d 12d1:1003"; then
    #try to reconnect
    sudo pppd call dialup1
    sleep 20
    else
    #no modem, bail out
    kdialog --title "Network Status" --passivepopup "Modem Unplugged" 5
    exit 0
    fi
    fi
    done

    #report internet connection status
    if [ $i -eq 1 ]; then
    kdialog --title "Network Status" --passivepopup "Connected to the internet" 5
    else
    kdialog --title "Network Status" --passivepopup "No connection available" 5
    fi

    exit 0

    There's a couple of thing which are specific to my machine, the vendor/product id (12d1:1003) and the ppp connection config "dialup1"

    If the connection has been dropped and the modem is still connected the script will attempt to reconnect to the internet every 20 seconds until it's possible to ping Google's dns.

    ps posting seems to have stripped the spaces & indents from the script

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •