[Gelistirici] Fwd: Network Manager Speedtouch Modem and supporting ATM

Koray Löker loker at pardus.org.tr
6 Tem 2007 Cum 11:48:11 EEST


----------  Doorgestuurd bericht  ----------

Onderwerp: Network Manager Speedtouch Modem and supporting ATM
Datum: 06 Tem 2007 Cum
Van: Martin Prout <mamba2928 at googlemail.com>
Aan: info at pardus.org.tr

Would you be interested in how to set up a Speedtouch 330 modem for connecting 
via ATM to an isp.
To do this I have recompiled ppp from source to get the pppoatm plugin 
required. Otherwise my set up to connect to Tiscali.co.uk is much the same as 
that for ubuntu described at 
http://www.linux-usb.org/SpeedTouch/ubuntu/index.html.
Note following differences:
1. I wrote my own dial.py script to do the connection (I'm not sure how to get 
it run via mudur.py though), so I run the following script at the command 
line.  
2. Pardus already includes the speedtch firmware (cf. ubuntu etc.).
3. My script assumes pppd is now at /usr/local/sbin (due to recompile and not 
wanting to interfere with Pardus, also won't get overwritten on any pppd 
update).

###############################################

#!/usr/bin/python
## -*- coding: utf-8 -*-
""" tiscali.py
  Author Martin Prout mamba2928 at yahoo.co.uk
  Script that checks that ppp daemon is not already running,
  then uses pppd to call isp if required, returns the primary dns
"""

import sys
import subprocess as S
from subprocess import Popen


def get_pid(process):
    """Return a single process id using pgrep"""
    proc1 = Popen(["pgrep", process], stdout = S.PIPE)
    return proc1.communicate()[0]

def connect(isp):
    """Uses local version of pppd 'has atm plugin' to call isp.
        Returns the primary dns from the isp"""
    proc1 = Popen(["/usr/local/sbin/pppd", "call", isp], stdout = S.PIPE)
    proc2 = Popen(["grep", "primary"], stdin = proc1.stdout, stdout = S.PIPE)
    output = proc2.communicate()[0]
    return output

def check_line(adsl_up):
    """Returns True if line is up, ie. kernel ring returns 'up'. """
    message = "Is the modem connected!!!"
    proc1 = Popen(["dmesg", "-s" "8192"], stdout = S.PIPE)
    proc2 = Popen(["grep", adsl_up], stdin = proc1.stdout, stdout = S.PIPE)
    output = proc2.communicate()[0]
    if (len(output) > 10):
        return True
    print message
    return False

def __main__():
    """ Is the Main method"""
    pid = get_pid("ppp")
    if len(pid) is 0:
        # uncomment in production
        # adsl_up = check_line("ADSL line is up")
        adsl_up = True # comment whole lin in production
        if (adsl_up):
            primary_dns = connect("tiscali")
            print primary_dns
            sys.exit(0)
        else:
            print "Is the modem online?"
            sys.exit(-1)
    else:
        print "Already Connected with ppp pid =", pid
        sys.exit(0)

__main__()

##############################################

Martin Prout

 

-------------------------------------------------------

-- 
Koray Löker
<-/ Özgürlük için... http://www.pardus.org.tr /->



Gelistirici mesaj listesiyle ilgili daha fazla bilgi