Contents

  1. ppp-on
  2. ppp-on-dialer
  3. ppp-off

ppp-on

[
Back][top][prev][next]
#!/bin/sh
#
# This file should be called "ppp-on". It can be placed under 
# /etc/ppp/scripts with execute permission (chmod 744). It can also run 
# suid root (chmod 4744 [or something like that]), along with the other
# executable scripts. This script is geared for Internet Direct Users.
#
# A really good suggestion for X-Windows users is to divert the output for
# this command to /dev/console using the tail command:
#         tail -f /var/log/mesages > /dev/console
# This way you have something to look at in case things don't go right.
#
# You're obviously going to fix this file for your own username, password,
# modem speed, and other stuff.
#
# Comments and corrections to: pking@idirect.com
# ------------------------------------------------------------------------
#
# Script to initiate a ppp connection. This is the first part of the
# pair of scripts. This is not a secure pair of scripts as the codes
# are visible with the 'ps' command.  However, it is simple.

#
# The proper syntax is now: ppp-on xxx-xxx-xxxx
# where "xxx-xxx-xxxx" is the phone number with area code. 
# If no paramaters are entered, the script falls back to a default 
# phone number. This case statement below also gives a usage and 
# allows the user to dial an alternate phone number.
# This script will ignore everything after the first parameter.
case $1 in
   -?|-h) # user wants help
         echo ''
         echo 'Usage: ppp-on [-h|-?|telephone-number]'
         echo ''
         echo '  -h or -?'
         echo '     This help message'
         echo '  telephone-number'
         echo '     Suggested phone numbers:'
         echo '     4162365805 . . . . (33.6k PPP-Express)'
         echo '     4162334923 . . . . (33.6k)'
         echo '     4162333626 . . . . (56K Flex)'
         echo '     4162337126 . . . . (56K Flex)'
         echo '     4162332999 . . . . (28.8 K)'
         echo ''
         echo 'If the user enters "ppp-on" without a phone number,'
         echo 'this script will dial a pre-set phone number.'
         echo ''
         exit 0
         ;;
   "") # user wants a default phone number
         PHN=4162337126
         ;;
   *) # user has a phone number
         PHN=$1
         ;;
esac

#
# These are the parameters. Change as needed.
TELEPHONE=*70,$PHN        # The telephone number as entered
ACCOUNT='user'		# The account name for logon (as in 'George.Burns')
PASSWORD=pass   	# The password for this account (and 'Gracie.Allen')
LOCAL_IP=0.0.0.0	# Local IP address if known. Dynamic = 0.0.0.0
REMOTE_IP=0.0.0.0	# Remote IP address if desired. Normally 0.0.0.0
NETMASK=255.255.255.0	# The proper netmask if needed
PROTOCOL=PPP            # The connection protocol (SLIP or PPP)
#
# Export them so that they will be available at 'ppp-on-dialer' time.
export TELEPHONE ACCOUNT PASSWORD PROTOCOL
# 
# This is the location of the script which dials the phone and logs
# in.  Please use the absolute file name as the $PATH variable is not
# used on the connect option.  (To do so on a 'root' account would be
# a security hole so don't ask.)
#
DIALER_SCRIPT=/etc/ppp/scripts/ppp-on-dialer
#
# Initiate the connection
# 
# I put most of the common options on this command. Please, don't
# forget the 'lock' option or some programs such as mgetty will not
# work. The asyncmap and escape will permit the PPP link to work with
# a telnet or rlogin connection. You are welcome to make any changes
# as desired. Don't use the 'defaultroute' option if you currently
# have a default route to an ethernet gateway.
#
# /bin/setserial /dev/modem spd_normal &
/sbin/setserial /dev/modem spd_normal &
#
# Use kdebug 0 when doing debugging of the connection. Leave it out,
# otherwise.
#
exec /usr/sbin/pppd debug kdebug 0 $LOCAL_IP:$REMOTE_IP netmask $NETMASK \
        defaultroute -detach /dev/modem 57600 connect $DIALER_SCRIPT &


ppp-on-dialer

[
Back][top][prev][next]
#!/bin/sh
#
# This is part 2 of the ppp-on script. It will perform the connection
# protocol for the desired connection.
#
exec /usr/sbin/chat -v					\
	TIMEOUT		3				\
	ABORT		'\nBUSY\r'			\
	ABORT		'\nNO ANSWER\r'			\
	ABORT		'\nRINGING\r\n\r\nRINGING\r'	\
	''		\rAT				\
	'OK-+++\c-OK'	ATH0				\
	TIMEOUT		45				\
	OK		ATDT$TELEPHONE			\
	CONNECT		''				\
	ogin:		$ACCOUNT			\
	assword:	$PASSWORD 

ppp-off

[
Back][top][prev][next]
#!/bin/sh
######################################################################
#
# Determine the device to be terminated.
#
if [ "$1" = "" ]; then
	DEVICE=ppp0
else
	DEVICE=$1
fi

######################################################################
#
# If the ppp0 pid file is present then the program is running. Stop it.
if [ -r /var/run/$DEVICE.pid ]; then
        kill -INT `cat /var/run/$DEVICE.pid`
#
# If the kill did not work then there is no process running for this
# pid. It may also mean that the lock file will be left. You may wish
# to delete the lock file at the same time.
        if [ ! "$?" = "0" ]; then
                rm -f /var/run/$DEVICE.pid
                echo "ERROR: Removed stale pid file"
                exit 1
        fi
#
# Success. Let pppd clean up its own junk.
        echo "PPP link to $DEVICE terminated."
        exit 0
fi
#
# The ppp process is not running for ppp0
echo "ERROR: PPP link is not active on $DEVICE"
exit 1

Generated by GNU enscript 1.5.5.
Modified by Paul King on 11/28/1998

since Apr 1 2007