[H-GEN] vppp

Robert Brockway robert at zen.humbug.org.au
Wed Mar 4 21:13:50 EST 1998


Hi all.  I've changed the name of my ppp script to vppp (for ' 
The versatile PPP script' :)  Anyway, here is the latest version.  You
will find a few things have changed, but it should be mostly self
explanatory.

Eventually I'm going to move all the config stuff over to a file,etc (and
maybe rewrite in perl as everyone has this these days).
Cheers,
	-Robert 

--Robert Brockway B.Sc.  Email: robert at zen.humbug.org.au, robert at icc.net.au
				r.brockway at uq.edu.au
                         WWW:   http://www.humbug.org.au/~robert
                         President of HUMBUG (http://www.humbug.org.au)
-------------- next part --------------
#!/bin/bash

#
# vppp -  The Versatile PPP Script
#

#
# Set up a PPP link to The University of Queensland from a Linux box.
# Should also work on FreeBSD and NetBSD with a few minor changes.
# Originally based on the default ppp-on script, this script has been heavily
# modified in the last 2 years.
# Permission is granted for unlimited distribution of original or modified
# versions of this script in electronic or other format as long as this
# comment block is retained intact.
# Thanks to Anthony Towns and Bradley Marshall for suggestions on how to
# improve the script.
# Copyright Robert Brockway 1995.
#
# Last modified: 12th Feburary 1997.
#                               --Robert Brockway.
#

# Best to leave this alone :-)
VERSION=3.1.6

#
# Installation
#
# Call this file something easy to remember, say ppp, then 'chown root'
# and 'chmod go-rwx' the file, as it contains passwords.  Then go through
# and modify the various configuration options below.
# If you experience problems, or have suggestions as to how to make this
# script better, feel free to email me at robert at zen.humbug.org.au.
#

#
# Configuration
#
# Fill in these variables to be appropriate for your local setup.
#

# Account 1.
LABEL1=staff
USER1=
PASSWORD1=
LOGIN1="name: $USER1 word: $PASSWORD1 nnex: ppp"
PPPCONF1="defaultroute mtu 1500 mru 1500 asyncmap 0 ipcp-accept-local ipcp-accept-remote bsdcomp 15,15 crtscts modem"
PHONELIST1="38640178 33354079 33354099"

# Account 2.
LABEL2=external
USER2=
PASSWORD2=
LOGIN2="name: $USER2 word: $PASSWORD2 nnex: ppp"
PPPCONF2="defaultroute lock mtu 1500 mru 1500 asyncmap 0 ipcp-accept-local ipcp-accept-remote bsdcomp 15,15 crtscts modem"
PHONELIST2="33354069 32912577 32912568 33354068 32912567 33354067 38341569"

# Account 3.
LABEL3=
USER3=
PASSWORD3=
LOGIN3=
PPPCONF3=
PHONELIST3=

# Put in fast turn around modem bank numbers here.
FASTBANK=33354089

# Make sure the paths to this files is valid and correct.
LOGFILE=~/log/ppplog

# Make sure this is a full path to the device file.
# If you use /dev/modem, make sure the link points at the right device file.
DEVICE=/dev/ttyS3

# Put your modem init string without the leading AT here surrounded by " characters, eg "&FM0"
HAYES="M0"

# Enter the speed of the serial port (bps).  This should be greater than 4 times the speed of the
# modem measured in bits per second (bps) if hardware compression is being used.  For example, if
# using a 14400bps modem, then the value should be at least 57600.  Valid values to consider are
# 38400,57600 and 115200.
SPEED=115200

#
# The real work
#

# Determine what function we actually want to invoke.
case $1 in
-u)
        case $2 in
        $LABEL1)
                USER=$USER1
                PASSWORD=$PASSWORD1
                PHONELIST=$PHONELIST1
		LOGIN=$LOGIN1
		PPPCONF=$PPPCONF1
                ;;
        $LABEL2)
                USER=$USER2
                PASSWORD=$PASSWORD2
                PHONELIST=$PHONELIST2
		LOGIN=$LOGIN2
		PPPCONF=$PPPCONF2
                ;;
        $LABEL3)
                USER=$USER3
                PASSWORD=$PASSWORD3
                PHONELIST=$PHONELIST3
		LOGIN=$LOGIN3
		PPPCONF=$PPPCONF3
                ;;
        *)
                echo "Please enter a valid username after ppp -u"
                exit
                ;;
        esac
        case $3 in
        fast)
                PHONELIST=$FASTBANK
                ;;
        esac
        for PHONE in $PHONELIST
        do
                (
                stty $SPEED -tostop
                if /usr/sbin/chat -v ABORT 'NO CARRIER' ABORT BUSY '' ATZ OK AT$HAYES OK ATDT$PHONE CONNECT \r\r\r\r\r\r $LOGIN
                then
                        sleep 2
                        /bin/date >> $LOGFILE
                        /usr/sbin/pppd $DEVICE $PPPCONF
                        sleep 8
                        exit 0
                else
                        exit 1
                fi
                ) < $DEVICE > $DEVICE
        done
	# Execute the file ~/.vppprc after dialing in
	/bin/sh ~/.vppprc
	;;
-d)
        # mail spool flushed to prevent messages being caught in the queue
        # before the link goes down.  This is fine for sendmail or smail,
        # modify for qmail.
        sendmail -q

        # sleep $2 seconds and shutdown ppp link
        case $2 in
        "")
                SLEEP=60
                ;;
        *)
                SLEEP=$2
                ;;
        esac
        sleep $SLEEP
        killall pppd
        killall vppp
        ;;
-l)
        echo -n "Modem usage statistics for host "
        hostname
        echo
        echo -n "Earliest record: "
        head -n 1 ~/log/ppplog
        echo
        echo -n "Latest record: "
        tail -n 1 ~/log/ppplog
        echo
        echo -n "Total connects: "
        cat ~/log/ppplog | wc -l
        echo
        echo "Month"

        echo "-----"
        for MONTH in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
        do
                echo -n $MONTH ":"
                cat ~/log/ppplog | grep $MONTH | wc -l
        done
        echo
        echo "Day"
        echo "---"
        for DAY in Mon Tue Wed Thu Fri Sat Sun
        do
                echo -n $DAY ":"
                cat $LOGFILE | grep $DAY | wc -l
        done
        ;;
-v)
        echo -n "vppp version" $VERSION
        echo
        ;;
*)
	# This is currently just a cat of a help file.  Eventually
	# this will bring up the man page, when one is written.
	cat ~/.vppp.help

        ;;
esac


More information about the General mailing list