#!/bin/sh

# This script works for me and ppp 2.3.5. Older versions of pppd might have
# slightly different options. In case of error messages consult the manpages
# for ppp and chat. (Older versions of chat for example use SAY instead of
# REPORT.)
#
# Variables  **	ExpU:	Set to the string your ISP uses to request your user
#			name. Examples:	ExpU=ogin:
#					ExpU="name>"
#
#	     **	ExpP:   Set to the string your ISP uses to request your password
#			Examples:	ExpP=word:
#					ExpP='word>'
#
#		The above strings must be enclosed in single or double quotes
#		if they contain characters which the shell might treat
#		specially, e.g. !?\{}()[]~`'<>+*. If in doubt use single quotes
#		which protect any character (except single quotes).
#
#	     **	User:   Sorry, I forgot what it meant.
#	     **	Pass:
#
#		Init:	This  variable should be set to contain the string
#			you normally use to initialize your modem.
#			BTW, do you really need all those %D&E&F's ?
#			If you want my advice - the shorter the better. Most
#			modems should be intelligent enough to best work with
#			a simple "ATZ". I use "ATZL3M2" because I want to
#			hear the dialog between the two modems, but only until
#			the connection has been established.
#
#		Lock:	I use this variable to specify an additional string
#			to disable the redial lock of the German Telekom.
#			If you don't need it or don't know the appropriate
#			string for your modem leave this variable empty.
#
#		Debg:	If you want pppd to log the contents of all packets
#			sent or received set this variable may not be empty
#			or unset. Set it to any value.
#			Logging is done via syslogd using facility daemon and
#			level debug.
#
#		KDeb:	Setting this variable enables debugging code in the
#			kernel-level ppp driver. Logging is also done via
#			syslogd.
#			Set kdeb to a sum of the following:
#				1    general messages
#				2    contents of received packets
#				3    contents of transmitted packets
#			If you don't want this leave the variable empty.
#
#		ErrO:	If you leave this variable empty error messages of pppd
#			and chat go to the current console.
#
#		T1,T2:	These are timeouts in seconds. Change them if you need.
#
#		If you have an alternate (pre-dinosaur hercules) monitor
#		attached to your machine and have a driver installed it's a
#		good idea to set ErrOut to the corresponding device.
#		In this case you could also add a line similar to the following
#		to your /etc/syslog.conf:
#
#			*.*	/dev/the_name_of_your_alternate_device
#
#		Use tabs to separate these two fields.
#
#		Variables marked ** MUST be set.
#
#		The complete chat script below is enclosed in double quotes.
#		On the one hand this allows shell variables to be expanded.
#		On the other hand this allows for single quotes to be passed
#		to the chat program.
#
# Hmmm, and what about security. Well, I admit, security is anything else but
# this script because it contains your user ID and your password. So be aware
# that if your grandma reads this script she will be able to use your ISP
# account on her laptop to surf the internet. And you will have to pay for it.
# Perhaps you should properly set up your firewall to keep your grandma out.
#
# Email me to <h.vossieck@ndh.net> if your problems don't disappear.
#
# Henning
#

ErrO=		Dial=ISP_phone_number
		
ExpU='name>'	User=YouID	T1=5	Init=L3M2	Debg=
ExpP='word>'	Pass=YourPW	T2=25	Lock=		KDeb=

chvt 22

exec pppd /dev/ttyS2 							\
	57600								\
	crtscts								\
	defaultroute							\
	lock								\
	modem								\
	-detach								\
	noipdefault							\
	user $User							\
	${Debg:+debug}							\
	${KDeb:+kdebug $KDeb}						\
	connect "chat	-v						\
			ABORT 	'NO CARRIER'				\
			ABORT 	'NO DIALTONE'				\
			ABORT 	BUSY					\
			TIMEOUT $T1					\
			'' 	ATZ$Init				\
			OK 	AT${Lock}DT$Dial			\
			TIMEOUT $T2					\
			REPORT	'*** Waiting for connect ($T2 sec)\n'	\
			CONNECT \c					\
			'$ExpU'	'$User'					\
			'$ExpP'	'$Pass'					\
			REPORT	'*** Login ok\n'"			\
	2>${ErrO:-/dev/console} &
	
