#!/bin/bash 
#	PPPSETUP  --  Script to set up pppd
#  	History:
#	  7/21/95 RSL         Script created (v1.0)
#         9/15/96 RSL         Added code to get the ISP's domainname (v1.1)
#         9/19/96 RSL         Revamped interface to use the 'dialog' 
#                             program. (v1.2)
#         2/22/98 KR          Added pap, chap, ms-chap, callback, & 
#                             modem init string options. (v1.98)
#                             Creates /etc/ppp/options, & pap, chap, 
#			      secrets files.
#                             More guidance.
#                             Monitor connection with tail & syslogd.
#                             Demand dialing setup with ppp-2.3.0 or later.        
#          4/4/98 PJV         Fixed massive /tmp-related security problems
#                             Switched to a default init string that's more
#                             likely to work
#                             Increased TIMEOUTs
#                             fixed bad flags given to chat -- caused dialout
#                             to fail
#          2/6/1999 PJV       Changed all occurances of /dev/cua* to /dev/ttyS*
#          5/3/1999 PJV       Commented 'debug' in /etc/ppp/options
#                             Add commented 'noauth' in /etc/ppp/options so
#                             people who want to use ppp but already have a
#                             default route have an easier time figuring out
#                             what to do. :)
#          6/18/2000 PJV      Added code to check for "ppp-stop" and "ppp-on"
#                             symlinks, and make them if they don't exist.
#          5/19/2002 PJV      Added support for more devices.

TMP=/var/log/setup/tmp

if [ ! "$UID" = "0" ]; then
echo
echo "NOTICE: * $LOGNAME * You need to be 'root' to run this script."
echo "You could login: root"
echo "You could also try this: # sudo pppsetup"
echo "You could also try this: # su -c pppsetup"
echo "This assumes the permissions on 'sudo' and 'su' are 4111."
echo "To give 'su' or 'sudo' these permissions, you have to be root."
echo "~# chown root.root sudo ; chmod 4111 sudo"
echo "You also need a /etc/sudoers file for 'sudo'."
echo
exit 1
fi

if ! type -all "dialog" >/dev/null 2>&1 ; then
echo
echo "Can't find 'dialog', i can't run without 'dialog' on your system."
echo "You can get a compiled ELF version of 'dialog' from here."
echo "http://www.tux.org/pub/people/kent-robotti/index.html"
echo "ftp://ftp.tux.org/pub/people/kent-robotti   'dialog-0.9a.ELF.tar.gz'"
echo
exit 1
fi

if [ -s /usr/lib/setup/hdsetup ]; then
SYS="on SLACKWARE."
fi

VERSION="1.98"

stty erase ^? 2>/dev/null 

if [ ! -r /usr/sbin/ppp-stop ]; then
  ( cd /usr/sbin ; ln -sf ppp-off ppp-stop )
fi
if [ ! -r /usr/sbin/ppp-on ]; then
  ( cd /usr/sbin ; ln -sf ppp-go ppp-on )
fi

echo "PPPSETUP $VERSION $SYS" > $TMP/txtTEMP01
echo >> $TMP/txtTEMP01
echo "Written by Robert S. Liesenfeld <xunil@bitstream.net> <IRC:Xunil>" >> $TMP/txtTEMP01
echo "Changes for 1.98 by Kent Robotti <robotti@erols.com>" >> $TMP/txtTEMP01
echo "Patched for Slackware by Patrick Volkerding <volkerdi@slackware.com>" >> $TMP/txtTEMP01
echo >> $TMP/txtTEMP01
echo "You should get these docs if you don't already have them:" >> $TMP/txtTEMP01
echo >> $TMP/txtTEMP01
echo "ftp://metalab.unc.edu/pub/Linux/docs/howto/PPP-HOWTO" >> $TMP/txtTEMP01
echo "ftp://metalab.unc.edu/pub/Linux/docs/faqs/PPP-FAQ" >> $TMP/txtTEMP01
echo >> $TMP/txtTEMP01
echo "Press [Enter] to continue with pppsetup..." >> $TMP/txtTEMP01

dialog --backtitle "PPPSETUP $VERSION/Slackware" --textbox "$TMP/txtTEMP01" 16 73 

while [ -z "$PHONENUM" ]
do
echo "To begin setting up your PPP connection, i need to know a few things." > $TMP/txtTEMP$$
echo "For starters, what is the phone number of your (I)nternet (S)ervice" >> $TMP/txtTEMP$$ 
echo "(P)rovider?" >> $TMP/txtTEMP$$ 
echo  >> $TMP/txtTEMP$$ 
echo "Example: atdt6661776   <-For (t)one dialing.)" >> $TMP/txtTEMP$$ 
echo "Example: atdp6661776   <-For (p)ulse dialing.)" >> $TMP/txtTEMP$$ 
echo  >> $TMP/txtTEMP$$ 
echo "Include the: atd?  It's usally just: atdtphonenumber" >> $TMP/txtTEMP$$ 
echo  >> $TMP/txtTEMP$$ 
echo "(Note: in the USA, use atdt*70,6661776 [comma required!] to turn" >> $TMP/txtTEMP$$ 
echo " off call waiting.)" >> $TMP/txtTEMP$$ 
echo  >> $TMP/txtTEMP$$ 
	
dialog --title "PHONE NUMBER ..." --inputbox "`cat $TMP/txtTEMP$$`" 18 75 2> $TMP/rspTEMP$$   

if [ $? = 1 ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
exit
fi 

PHONENUM="`cat $TMP/rspTEMP$$`"
 
if [ -z "$PHONENUM" ]; then
clear 2>/dev/null || echo
rm -f $TMP/*TEMP*
echo "PPP configuration cancelled."
echo "No phone number."
exit
fi
done

echo "Where is your modem /dev/ttyS?" > $TMP/txtTEMP$$ 
dialog --backtitle "MODEM DEVICE ..." --menu "`cat $TMP/txtTEMP$$`" 17 60 10 \
modem "= use whatever /dev/modem is linked to" \
ttyS0 "= (COM1: under DOS)" \
ttyS1 "= (COM2: under DOS)" \
ttyS2 "= (COM3: under DOS)" \
ttyS3 "= (COM4: under DOS)" \
ttyS4 "= PCI modem" \
ttyS5 "= PCI modem" \
ttyS6 "= PCI modem" \
ttyS7 "= PCI modem" \
ttyS8 "= PCI modem" \
ttyS9 "= PCI modem" \
ttyS10 "= PCI modem" \
ttyS11 "= PCI modem" \
ttyS12 "= PCI modem" \
ttyS13 "= PCI modem" \
ttyS14 "= PCI modem" \
ttyS15 "= PCI modem" \
2> $TMP/rspTEMP$$

MODEM="`cat $TMP/rspTEMP$$`"

if [ ! "$MODEM" = "modem" ]; then
  if [ -z $MODEM ]; then
    clear 2>/dev/null || echo
    rm -f $TMP/*TEMP*
    echo "PPP configuration cancelled."
    exit 
  elif [ ! -c "/dev/$MODEM" ]; then
    /dev/MAKEDEV $MODEM >/dev/null 2>&1 || MODERROR="YES"
  else
    rm -f /dev/modem 2>/dev/null
    ln -sf /dev/$MODEM /dev/modem 2>/dev/null
  fi
fi

echo "What baud rate is your modem?" > $TMP/txtTEMP$$
dialog --backtitle "MODEM BAUD RATE ..." --menu "`cat $TMP/txtTEMP$$`" 14 72 7 \
460800 "460KBps  - ISDN modem..." \
230400 "230KBps  - 56Kbps modem... or ISDN modem..." \
115200 "115KBps  - 28.8, 33.6, or 56Kbps modem..." \
57600  "57.6KBps - 28.8, 33.6, or 56Kbps modem..." \
38400  "38.4KBps - Hangin ten on the net! 28.8 or 33.6..." \
19200  "19.2KBps - Better known as 14.4..." \
9600   "9600bps  - No comment..." 2> $TMP/rspTEMP$$

BAUDRATE="`cat $TMP/rspTEMP$$`"

if [ -z $BAUDRATE ]; then
clear 2>/dev/null || echo
rm -f $TMP/*TEMP*
echo "PPP configuration cancelled."
exit 
fi

echo "Does your service provider use CALLBACK?" > $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "CALLBACK is when you call your service provider and give them" >> $TMP/txtTEMP$$
echo "your phone number so they can call you back, then when they" >> $TMP/txtTEMP$$
echo "call you back you give them your login name and password." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Most service providers don't use CALLBACK, so the answer is" >> $TMP/txtTEMP$$
echo "probably No, unless you know otherwise." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$

dialog --backtitle "CALLBACK YES or NO? ..." --menu "`cat $TMP/txtTEMP$$`" 16 70 2 "NO" "Most Internet providers do not use callback" "YES" "Use callback support (I know what I'm doing)" 2> $TMP/replyTEMP$$

if [ "`cat $TMP/replyTEMP$$`" = "YES" ]; then
echo "Put your phone number in the box below, so your service provider" > $TMP/txtTEMP$$
echo "can call you back." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Example: 7771818" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$

dialog --backtitle "CALLBACK Your Phone Number? ..." --inputbox "`cat $TMP/txtTEMP$$`" 11 72 2> $TMP/cb1TEMP$$

if [ $? = 1 ]; then
clear 2>/dev/null || echo
rm -f $TMP/*TEMP*
echo "PPP configuration cancelled."
exit 
elif [ ! -s $TMP/cb1TEMP$$ ]; then
clear 2>/dev/null || echo
rm -f $TMP/*TEMP*
echo "PPP configuration cancelled."
echo "No Phone Number for Callback."
exit
fi 
fi

if [ -s $TMP/cb1TEMP$$ ]; then
CBPN="`cat $TMP/cb1TEMP$$`"
echo "I have your phone number: $CBPN" > $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Do you have to give a Username or Login for the initial connection" >> $TMP/txtTEMP$$
echo "to $PHONENUM before you're called back." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Example: jerry" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "If NO, just press [Enter] on a empty box and skip this." >> $TMP/txtTEMP$$

dialog --backtitle "CALLBACK INITIAL LOGIN? ..." --inputbox "`cat $TMP/txtTEMP$$`" 15 74 2> $TMP/cb1.1TEMP$$

if [ $? = 1 ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
exit 
else
CBMODLOGIN="`cat $TMP/cb1.1TEMP$$`"
fi 
fi

if [ -s $TMP/cb1TEMP$$ ]; then
echo "I have your phone number: $CBPN" > $TMP/txtTEMP$$
if [ -s $TMP/cb1.1TEMP$$ ]; then
echo "I see you have to give a Username or Login: $CBMODLOGIN" >> $TMP/txtTEMP$$
echo "for the initial connection to: $PHONENUM" >> $TMP/txtTEMP$$
fi
echo >> $TMP/txtTEMP$$
echo "Do you have to give a Password for the initial connection" >> $TMP/txtTEMP$$
echo "to $PHONENUM before you're called back." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Example: Zoy85mWc" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "If NO, just press [Enter] on a empty box and skip this." >> $TMP/txtTEMP$$

dialog --backtitle "CALLBACK INITIAL PASSWORD? ..." --inputbox "`cat $TMP/txtTEMP$$`" 17 68 2> $TMP/cb2TEMP$$

if [ $? = 1 ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
exit 
else
CBMODPASS="`cat $TMP/cb2TEMP$$`"
fi
fi

if [ ! -z "$CBPN" ]; then
echo "Are they using PAP or CHAP for AUTHENTICATION? If so answer YES." > $TMP/txtTEMP$$
echo "Do they present you with a Username: or Login: and Password: prompt" >> $TMP/txtTEMP$$
echo "when they call you back, if so they're probably not using PAP or" >> $TMP/txtTEMP$$
echo "CHAP, so you can answer NO here." >> $TMP/txtTEMP$$
echo "If you're not sure, you'll have to ask you're service provider." >> $TMP/txtTEMP$$

dialog --backtitle "CALLBACK PAP-CHAP YES or NO? ..." --yesno "`cat $TMP/txtTEMP$$`" 9 72 

if [ $? = 1 ]; then
echo "What is your Username or Login to your service provider?" > $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "This is the information you'll give them when they call" >> $TMP/txtTEMP$$
echo "you back at: $CBPN" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Example: jerry" >> $TMP/txtTEMP$$

dialog --backtitle "CALLBACK LOGIN? ..." --inputbox "`cat $TMP/txtTEMP$$`" 13 72 2> $TMP/cb3TEMP$$

if [ $? = 1 ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
exit 
fi

CBLOGIN="`cat $TMP/cb3TEMP$$`"

if [ -z "$CBLOGIN" ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
echo "No Login for Callback."
exit 
fi
fi
fi

if [ ! -z "$CBLOGIN" ]; then
echo "What is the Password for: $CBLOGIN" > $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Example: Ziy79Kie" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$

dialog --backtitle "CALLBACK PASSWORD? ..." --inputbox "`cat $TMP/txtTEMP$$`" 10 64 2> $TMP/cb4TEMP$$

if [ $? = 1 ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
exit 1 
fi

CBPASS="`cat $TMP/cb4TEMP$$`"

if [ -z "$CBPASS" ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
echo "No Password for Callback."
exit 1
fi
fi

callback1() {
 cat << EOF
TIMEOUT	     60
ABORT	     BUSY    			
ABORT	     ERROR    			
ABORT	     VOICE    			
ABORT	     "NO CARRIER"   		
ABORT	     "NO DIALTONE"   		
""	     "AT\&FS0=1H0"  		
OK	     "ATDT$PHONENUM"			
TIMEOUT	     60
CONNECT	     ""				
ogin:--name: "$CBMODLOGIN"	                
word:--word: "$CBMODPASS"
CLR_ABORT "NO CARRIER"
HANGUP OFF			
TIMEOUT	     90
CONNECT	     ""
HANGUP 0N
ABORT	     "NO CARRIER"   		
ogin:--name: "$CBLOGIN"	                
word:--word: "$CBPASS"

EOF
}

callback2() {
 cat << EOF
TIMEOUT 60
ABORT	BUSY    			
ABORT	ERROR    			
ABORT	VOICE    			
ABORT	"NO CARRIER"   		
ABORT	"NO DIALTONE"   		
""	"AT\&FS0=1H0"  		
OK	"ATDT$PHONENUM"			
TIMEOUT	60
CONNECT	""				
CLR_ABORT "NO CARRIER"
HANGUP OFF			
TIMEOUT	90
CONNECT	"\c"
HANGUP 0N
ABORT   "NO CARRIER"   		

EOF
}

callback3() {
 cat << EOF
TIMEOUT	     60
ABORT	     BUSY    			
ABORT	     ERROR    			
ABORT	     VOICE    			
ABORT	     "NO CARRIER"   		
ABORT	     "NO DIALTONE"   		
""	     "AT\&FS0=1H0"  		
OK	     "ATDT$PHONENUM"			
TIMEOUT	     60
CONNECT	     ""				
CLR_ABORT "NO CARRIER"
HANGUP OFF			
TIMEOUT	     90
CONNECT	     ""
HANGUP 0N
ABORT	     "NO CARRIER"   		
ogin:--name: "$CBLOGIN"	                
word:--word: "$CBPASS"

EOF
}

callback4() {
 cat << EOF
TIMEOUT	     60
ABORT	     BUSY    			
ABORT	     ERROR    			
ABORT	     VOICE    			
ABORT	     "NO CARRIER"   		
ABORT	     "NO DIALTONE"   		
""	     "AT\&FS0=1H0"  		
OK	     "ATDT$PHONENUM"			
TIMEOUT	     60
CONNECT	     ""				
word:--word: "$CBMODPASS"			
CLR_ABORT "NO CARRIER"
HANGUP OFF			
TIMEOUT	     90
CONNECT	     ""
HANGUP 0N
ABORT	     "NO CARRIER"   		
ogin:--name: "$CBLOGIN"	                
word:--word: "$CBPASS"

EOF
}

callback5() {
 cat << EOF
TIMEOUT	     60
ABORT	     BUSY    			
ABORT	     ERROR    			
ABORT	     VOICE    			
ABORT	     "NO CARRIER"   		
ABORT	     "NO DIALTONE"   		
""	     "AT\&FS0=1H0"  		
OK	     "ATDT$PHONENUM"			
TIMEOUT	     60
CONNECT	     ""				
ogin:--name: "$CBMODLOGIN"	                
word:--word: "$CBMODPASS"			
CLR_ABORT "NO CARRIER"
HANGUP OFF			
TIMEOUT	     90
CONNECT      "\c"	       
HANGUP 0N
ABORT	     "NO CARRIER"   		

EOF
}

callback6() {
 cat << EOF
TIMEOUT	     60
ABORT	     BUSY    			
ABORT	     ERROR    			
ABORT	     VOICE    			
ABORT	     "NO CARRIER"   		
ABORT	     "NO DIALTONE"   		
""	     "AT\&FS0=1H0"  		
OK	     "ATDT$PHONENUM"			
TIMEOUT	     60
CONNECT	     ""				
ogin:--name: "$CBMODLOGIN"	                
CLR_ABORT "NO CARRIER"
HANGUP OFF			
TIMEOUT	     90
CONNECT      "\c"	       
HANGUP 0N
ABORT	     "NO CARRIER"   		

EOF
}

callback7() {
 cat << EOF
TIMEOUT	     60
ABORT	     BUSY    			
ABORT	     ERROR    			
ABORT	     VOICE    			
ABORT	     "NO CARRIER"   		
ABORT	     "NO DIALTONE"   		
""	     "AT\&FS0=1H0"  		
OK	     "ATDT$PHONENUM"			
TIMEOUT	     60
CONNECT	     ""				
word:--word: "$CBMODPASS"			
CLR_ABORT "NO CARRIER"
HANGUP OFF			
TIMEOUT	     90
CONNECT      "\c"	       
HANGUP 0N
ABORT	     "NO CARRIER"   		

EOF
}

if [ ! -d /etc/ppp ]; then 
mkdir -p /etc/ppp
fi

if [ -s $TMP/cb1TEMP$$ ]; then
if [ -s $TMP/cb1.1TEMP$$ ] && [ -s $TMP/cb2TEMP$$ ] && [ -s $TMP/cb3TEMP$$ ] && [ -s $TMP/cb4TEMP$$ ]; then
callback1 > /etc/ppp/callback
elif [ ! -s $TMP/cb1.1TEMP$$ ] && [ ! -s $TMP/cb2TEMP$$ ] && [ ! -s $TMP/cb3TEMP$$ ] && [ ! -s $TMP/cb4TEMP$$ ]; then
callback2 > /etc/ppp/callback
elif [ ! -s $TMP/cb1.1TEMP$$ ] && [ ! -s $TMP/cb2TEMP$$ ] && [ -s $TMP/cb3TEMP$$ ] && [ -s $TMP/cb4TEMP$$ ]; then
callback3 > /etc/ppp/callback
elif [ ! -s $TMP/cb1.1TEMP$$ ] && [ -s $TMP/cb2TEMP$$ ] && [ -s $TMP/cb3TEMP$$ ] && [ -s $TMP/cb4TEMP$$ ]; then
callback4 > /etc/ppp/callback
elif [ -s $TMP/cb1.1TEMP$$ ] && [ -s $TMP/cb2TEMP$$ ] && [ ! -s $TMP/cb3TEMP$$ ] && [ ! -s $TMP/cb4TEMP$$ ]; then
callback5 > /etc/ppp/callback
elif [ -s $TMP/cb1.1TEMP$$ ] && [ ! -s $TMP/cb3TEMP$$ ] && [ ! -s $TMP/cb4TEMP$$ ]; then
callback6 > /etc/ppp/callback
elif [ -s $TMP/cb2TEMP$$ ] && [ ! -s $TMP/cb3TEMP$$ ] && [ ! -s $TMP/cb4TEMP$$ ]; then
callback7 > /etc/ppp/callback
fi
fi

if [ -s /etc/ppp/callback ]; then
chown root.root /etc/ppp/callback 2>/dev/null
chmod 600 /etc/ppp/callback 2>/dev/null
fi

if [ ! -s $TMP/cb1TEMP$$ ]; then	
echo 'The default modem init string will be: "AT&FH0" OK' > $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "If you want to change it, put your init string in the box below." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "If you use \ in the init string, put it twice." >> $TMP/txtTEMP$$
echo 'Example: "AT\&F\\K3\\N3H0" OK' >> $TMP/txtTEMP$$
echo "M = No sound.  S95=46 = Show CARRIER speed: 28800 etc." >> $TMP/txtTEMP$$
echo 'Put "" around each init string with "&" in it.' >> $TMP/txtTEMP$$
echo 'Put OK after each init string. Example: ATZ OK "AT\&F1MH0" OK' >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Just press [Enter] on a empty box to accept the default above." >> $TMP/txtTEMP$$

dialog --backtitle "MODEM INIT STRING ..." --inputbox "`cat $TMP/txtTEMP$$`" 18 74 2> $TMP/rspTEMP$$

if [ $? = 1 ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
exit 
fi 

if [ -s $TMP/rspTEMP$$ ]; then
INIT="`cat $TMP/rspTEMP$$`"
else
INIT="below"
fi
fi

echo "What is your (I)nternet (S)ervice (P)rovider's domain name?" > $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "This is usually something like..." >> $TMP/txtTEMP$$
echo "Examples: something.edu something.net something.com something.org" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$

dialog --backtitle "DOMAIN NAME ..." --inputbox "`cat $TMP/txtTEMP$$`" 11 74 2> $TMP/rspTEMP$$

if [ $? = 1 ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
exit 
fi 

DOMAINNAME="`cat $TMP/rspTEMP$$`"

echo "What is the IP address of your Internet provider's nameserver?" > $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "It's important that these IP numbers be correct." >> $TMP/txtTEMP$$
echo "The IP numbers should not be: 0.0.0.0" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Note: Your service provider's technical support can provide you" >> $TMP/txtTEMP$$
echo "with this information.   Example: 207.132.116.5" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$

dialog --backtitle "DNS IP ADDRESS ..." --inputbox "`cat $TMP/txtTEMP$$`" 14 74 2> $TMP/rspTEMP$$

if [ $? = 1 ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
exit 
fi 

DNSIP="`cat $TMP/rspTEMP$$`"

if [ ! -s $TMP/cb3TEMP$$ ]; then   
echo "Does your service provider use PAP or CHAP?" > $TMP/txtTEMP$$
echo "If you're presented with a Username: or Login: and Password:" >> $TMP/txtTEMP$$
echo "prompt when you connect to your service provider, they're" >> $TMP/txtTEMP$$
echo "'probably' not using PAP or CHAP, so you can answer SCRIPT." >> $TMP/txtTEMP$$
echo "I said 'probably', the only way to know for sure is to ask you're" >> $TMP/txtTEMP$$
echo "service provider, this could save you a lot of wasted time." >> $TMP/txtTEMP$$

dialog --backtitle "PAP, CHAP, or SCRIPT? ..." --menu "`cat $TMP/txtTEMP$$`" 16 72 4 \
PAP  "AUTHENTICATION" \
CHAP "AUTHENTICATION" \
MS-CHAP-80 "is microsoft's version of CHAP." \
SCRIPT     "Create Chat Script For Login." 2> $TMP/papTEMP

if [ $? = 1 ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
exit 
else
PAP="`cat $TMP/papTEMP`"
fi
fi

RAS() {
cat << EOF
If your RAS server is not the 'domain controller' and is not a 
'stand-alone' server, then it must make a query to the domain 
controller for your domain.

In other words, your account is not on the NT server you first 
connect to, so it needs to know the name of the domain you have 
your account on, so it can query that domain about you. 

If not sure chose Stand-alone, then try Queries if Stand-alone 
doesn't work.
EOF
}

if [ "$PAP" = "MS-CHAP-80" ]; then   
if [ ! -z "$DOMAINNAME" ]; then
echo > $TMP/txtTEMP$$
echo "You gave $DOMAINNAME for domain name, this will be the" >> $TMP/txtTEMP$$
echo "NT server you connect to when you dial: $PHONENUM" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
else
echo > $TMP/txtTEMP$$
fi
RAS >> $TMP/txtTEMP$$

dialog --title "MS-CHAP NT server, Stand-alone or ? ..." --menu "`cat $TMP/txtTEMP$$`" 22 72 2 \
MS-CHAP-SERVER-1 "Stand-alone..." \
MS-CHAP-SERVER-2 "Queries domain controller..." 2> $TMP/mschapTEMP

if [ $? = 1 ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
exit 
fi 

MSCHAP="`cat $TMP/mschapTEMP`"

if [ "$MSCHAP" = "MS-CHAP-SERVER-2" ]; then   
echo "Put the name of the domain you have your account on." > $TMP/txtTEMP0
echo "Example: fooboo" >> $TMP/txtTEMP0
echo >> $TMP/txtTEMP0

dialog --backtitle "MS-CHAP QUERY DOMAIN? ..." --inputbox "`cat $TMP/txtTEMP0`" 9 64 2> $TMP/rspTEMP0

if [ $? = 1 ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
exit 
fi 

MSDOMAIN="`cat $TMP/rspTEMP0`"

if [ ! -s $TMP/rspTEMP0 ]; then   
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
echo "No ms-chap query domain name given."
exit
fi 
fi
fi

if [ ! "$PAP" = "SCRIPT" ] && [ ! -s $TMP/cb3TEMP$$ ]; then   
echo "Put your Login = Username in the box below." > $TMP/txtTEMP1
echo >> $TMP/txtTEMP1
echo "Sometimes they want your username or number followed" >> $TMP/txtTEMP1
echo "by their @domain name like this below." >> $TMP/txtTEMP1
echo "Example: jerry@foo.boo.com" >> $TMP/txtTEMP1
echo "Example: 1234567@foo.boo.com" >> $TMP/txtTEMP1
echo >> $TMP/txtTEMP1
echo "Sometimes the username is two words." >> $TMP/txtTEMP1
echo "Example: jerry donut" >> $TMP/txtTEMP1
echo >> $TMP/txtTEMP1
echo "Usally it's just your username like this below." >> $TMP/txtTEMP1
echo "Example: jerry" >> $TMP/txtTEMP1
echo >> $TMP/txtTEMP1

dialog --backtitle "PAP or CHAP LOGIN? ..." --inputbox "`cat $TMP/txtTEMP1`" 19 64 2> $TMP/rspTEMP1

if [ $? = 1 ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
exit 
fi

if [ ! -s $TMP/rspTEMP1 ]; then   
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
echo "No username for pap, chap, or ms-chap given."
exit
fi 
fi

if [ -s $TMP/rspTEMP1 ]; then 
AUTH1="`cat $TMP/rspTEMP1`"
echo "$AUTH1" > $TMP/txtTEMP2
echo "What's the password for the username above?" >> $TMP/txtTEMP2
echo "Example: Xpi9u87T" >> $TMP/txtTEMP2
dialog --backtitle "PAP or CHAP PASSWORD? ..." --inputbox "`cat $TMP/txtTEMP2`" 10 64 2> $TMP/rspTEMP2

AUTH2="`cat $TMP/rspTEMP2`"
END=""

elif [ ! -s $TMP/cb1TEMP$$ ] && [ "$PAP" = "SCRIPT" ]; then  
END='""'
echo "If you reached this part of the script, it should be because you" > $TMP/txtTEMP$$
echo "skipped the PAP or CHAP? and CALLBACK? parts of this script." >> $TMP/txtTEMP$$
echo "In other words, your service provider is not using PAP, CHAP, or" >> $TMP/txtTEMP$$
echo "CALLBACK." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Now comes the tough part. :) I need to know what your" >> $TMP/txtTEMP$$
echo "service provider prints to your screen when you dial in," >> $TMP/txtTEMP$$
echo "and what you respond with." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Usally when you connect to your service provider you see a" >> $TMP/txtTEMP$$
echo "Username: or Login: prompt, and you respond with your name." >> $TMP/txtTEMP$$
echo "Then there's a Password: prompt and you respond with your" >> $TMP/txtTEMP$$
echo "password." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "If you're not sure if it's Login: or login:, just put ogin:" >> $TMP/txtTEMP$$
echo "you don't have to spell the whole thing out, the end part of" >> $TMP/txtTEMP$$
echo "what to wait for should be enough." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo 'If they put this for example "foobar fooboo ID:", you could just' >> $TMP/txtTEMP$$
echo 'put ID: or you could spell the whole thing out & put "" around it.' >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "What text should I wait for?" >> $TMP/txtTEMP$$
echo "ID:" >> $TMP/txtTEMP$$
echo "What text should I send?" >> $TMP/txtTEMP$$
echo "jerry" >> $TMP/txtTEMP$$
echo "What text should I wait for?" >> $TMP/txtTEMP$$
echo '"foobar fooboo ID:"' >> $TMP/txtTEMP$$
echo "What text should I send?" >> $TMP/txtTEMP$$
echo "jerry" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Sometimes you may want to wait for nothing, but send something." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "What text should I wait for?" >> $TMP/txtTEMP$$
echo '""' >> $TMP/txtTEMP$$
echo "What text should I send?" >> $TMP/txtTEMP$$
echo "something" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo '"" = wait for nothing.' >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "If you don't want your password printed out put \q in front of it." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "What text should I wait for?" >> $TMP/txtTEMP$$
echo "Password:" >> $TMP/txtTEMP$$
echo "What text should I send?" >> $TMP/txtTEMP$$
echo "\qsecret" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "ogin: = Login:   name: = Username:   word: = Password:" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "This below would end up looking like this in the /etc/ppp/pppscript" >> $TMP/txtTEMP$$
echo "file created by pppsetup when you're done." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "ogin: jerry" >> $TMP/txtTEMP$$
echo "word: secret" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "For example..." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "What text should I wait for?" >> $TMP/txtTEMP$$
echo "ogin:" >> $TMP/txtTEMP$$
echo "And what text should I send?" >> $TMP/txtTEMP$$
echo "jerry" >> $TMP/txtTEMP$$
echo "What text should I wait for?" >> $TMP/txtTEMP$$
echo "word:" >> $TMP/txtTEMP$$
echo "And what text should I send?" >> $TMP/txtTEMP$$
echo "secret" >> $TMP/txtTEMP$$
echo "What text should I wait for?" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "( End by pressing Enter on an empty = blank wait for? box. )" >> $TMP/txtTEMP$$

dialog --title "CHAT SCRIPT" --textbox "$TMP/txtTEMP$$" 22 72

MESSAGE=' '
YOUSAY=' '
while [ ! "$MESSAGE" = "" -a ! "$YOUSAY" = "" ]
do

echo "     End by pressing Enter on a empty = blank box." > $TMP/txtTEMP$$
echo "            What text should I wait for?" >> $TMP/txtTEMP$$
dialog --backtitle "EXPECT ..." --inputbox "`cat $TMP/txtTEMP$$`" 9 60 2> $TMP/rspTEMP$$	

MESSAGE="`cat $TMP/rspTEMP$$`"

if [ -z "$MESSAGE" ]; then
continue
fi

dialog --backtitle "SEND ..." --inputbox "And what text should I send?" 8 60 2> $TMP/rspTEMP$$

if [ $? = 1 ]; then
rm -f $TMP/*TEMP*
clear 2>/dev/null || echo
echo "PPP configuration cancelled."
exit 
fi

YOUSAY="`cat $TMP/rspTEMP$$`"

echo "$MESSAGE $YOUSAY" >> $TMP/sayTEMP1
	
if [ -z "$YOUSAY" ]; then
clear 2>/dev/null || echo
rm -f $TMP/*TEMP*
echo "PPP configuration cancelled."
echo "Nothing to send."
exit 
else	
continue
fi
done
fi

if [ ! -s $TMP/cb3TEMP$$ ]; then
if [ -s $TMP/cb1TEMP$$ ] && [ ! -s $TMP/cb3TEMP$$ ] && [ "$PAP" = "SCRIPT" ]; then
clear 2>/dev/null || echo
rm -f $TMP/*TEMP*
echo "PPP configuration cancelled."
echo "You chose callback with PAP or CHAP, but answered SCRIPT to PAP or CHAP?."
exit 
elif [ ! -s $TMP/rspTEMP2 ] && [ -s $TMP/rspTEMP1 ]; then
clear 2>/dev/null || echo
rm -f $TMP/*TEMP*
echo "PPP configuration cancelled."
echo "No password for: $AUTH1"
exit 	
elif [ ! -s $TMP/sayTEMP1 ] && [ ! -s $TMP/rspTEMP2 ]; then
clear 2>/dev/null || echo
rm -f $TMP/*TEMP*
echo "PPP configuration cancelled."
echo "Nothing to wait for."
exit 
fi
fi

if dmesg 2>/dev/null | grep "PPP: version" >/dev/null 2>&1 ; then
MSG1=YES
fi
if [ -s /lib/modules/`uname -r 2>/dev/null`/net/ppp.o ]; then
MSG2=YES
fi

if [ ! -s /etc/host.conf ]; then
echo "order hosts,bind" > /etc/host.conf
echo "multi on" >> /etc/host.conf
fi

if [ ! -z $DOMAINNAME ]; then
# backup file
cp -a /etc/resolv.conf /etc/resolv.conf.$$ 2> /dev/null
echo "search $DOMAINNAME" > /etc/resolv.conf
else
rm -f /etc/resolv.conf 2>/dev/null
DOMAINNAME="unknown.com"
fi

if [ -z $DNSIP ]; then
echo "nameserver 207.132.116.5" >> /etc/resolv.conf
else
echo "nameserver $DNSIP" >> /etc/resolv.conf
fi

if [ ! -s /etc/hosts ]; then
# backup file
cp -a /etc/hosts /etc/hosts.bak.$$ 2> /dev/null
echo "127.0.0.1    localhost" > /etc/hosts
if [ "$DOMAINNAME" = "unknown.com" ]; then
echo "0.0.0.0     `hostname 2>/dev/null`.localnet `hostname 2>/dev/null`" >> /etc/hosts
else
echo "0.0.0.0     `hostname 2>/dev/null`.$DOMAINNAME `hostname 2>/dev/null`" >> /etc/hosts
fi
fi

if [ -x /usr/sbin/pppd ]; then
PATH1="/usr/sbin/pppd"
elif [ -x /usr/bin/pppd ]; then
PATH1="/usr/bin/pppd"
elif [ -x /usr/local/bin/pppd ]; then
PATH1="/usr/local/bin/pppd"
elif [ -x /bin/pppd ]; then
PATH1="/bin/pppd"
elif [ -x /sbin/pppd ]; then
PATH1="/sbin/pppd"
else
PATH1="pppd"
fi

#if [ "$PATH1" != "pppd" ]; then
#chmod 4755 $PATH1 2>/dev/null
#fi

if [ -x /usr/sbin/chat ]; then
PATH2="/usr/sbin/chat"
elif [ -x /usr/bin/chat ]; then
PATH2="/usr/bin/chat"
elif [ -x /usr/local/bin/chat ]; then
PATH2="/usr/local/bin/chat"
elif [ -x /bin/chat ]; then
PATH2="/bin/chat"
elif [ -x /sbin/chat ]; then
PATH2="/sbin/chat"
else
PATH2="chat"
fi

if [ ! -s $TMP/cb1TEMP$$ ]; then
echo "TIMEOUT 60" > /etc/ppp/pppscript
echo "ABORT ERROR" >> /etc/ppp/pppscript 
echo "ABORT BUSY" >> /etc/ppp/pppscript 
echo 'ABORT "NO CARRIER"' >> /etc/ppp/pppscript
echo 'ABORT "NO DIALTONE"' >> /etc/ppp/pppscript
if [ "$INIT" = "below" ]; then
echo '"" "AT&FH0"' >> /etc/ppp/pppscript
echo 'OK "'$PHONENUM'"' >> /etc/ppp/pppscript
else
echo '"" '$INIT'' >> /etc/ppp/pppscript
echo '"'$PHONENUM'"' >> /etc/ppp/pppscript
fi
echo "TIMEOUT 75" >> /etc/ppp/pppscript
echo 'CONNECT '$END'' >> /etc/ppp/pppscript
chown root.root /etc/ppp/pppscript 2>/dev/null
chmod 600 /etc/ppp/pppscript 2>/dev/null
fi

if [ -s $TMP/sayTEMP1 ]; then
cat $TMP/sayTEMP1 >> /etc/ppp/pppscript
echo >> /etc/ppp/pppscript 
else
echo >> /etc/ppp/pppscript 
fi

if [ -s /etc/ppp/ip-up ]; then
mv /etc/ppp/ip-up /etc/ppp/ip-up.OLD
fi

echo "#!/bin/sh" > /etc/ppp/ip-up

echo "#" >> /etc/ppp/ip-up
echo "# This file /etc/ppp/ip-up is run by pppd when there's a" >> /etc/ppp/ip-up
echo "# successful ppp connection." >> /etc/ppp/ip-up
echo "#" >> /etc/ppp/ip-up
echo "# Put any commands you want run after a successful connection" >> /etc/ppp/ip-up
echo "# in this file." >> /etc/ppp/ip-up
echo "#" >> /etc/ppp/ip-up
echo "# Any commands you want printed to the screen should be directed" >> /etc/ppp/ip-up
echo "# to: >/dev/tty0" >> /etc/ppp/ip-up
echo "#" >> /etc/ppp/ip-up
echo "# Other commands should not be directed to: >/dev/tty0" >> /etc/ppp/ip-up
echo "#" >> /etc/ppp/ip-up
echo "# The companion file is /etc/ppp/ip-down, it's run when the PPP" >> /etc/ppp/ip-up
echo "# connection ends." >> /etc/ppp/ip-up
echo "#" >> /etc/ppp/ip-up
echo "# This file is created when you run pppsetup: `date 2>/dev/null`" >> /etc/ppp/ip-up
echo "#" >> /etc/ppp/ip-up
echo "# The environment is cleared before executing this script" >> /etc/ppp/ip-up
echo "# so the path must be reset." >> /etc/ppp/ip-up
echo "#" >> /etc/ppp/ip-up
echo "PATH=/usr/bin:/usr/sbin:/usr/local/bin:/sbin:/bin" >> /etc/ppp/ip-up
echo "export PATH" >> /etc/ppp/ip-up

echo >> /etc/ppp/ip-up
echo "# This will print to the screen the local & remote IP address when you" >> /etc/ppp/ip-up
echo '# make a successful ppp connection.  $4 = Local IP $5 = Remote IP' >> /etc/ppp/ip-up
echo "#" >> /etc/ppp/ip-up
echo "# The CARRIER speed at which you connected will be reported, if it's in" >> /etc/ppp/ip-up
echo '# the /var/log/messages file.  You also need the programs "tail" "cut"' >> /etc/ppp/ip-up
echo '# "tr" "grep" and "syslogd" running for this to work.' >> /etc/ppp/ip-up
echo "# You may have to add S95=46 to your modem init string" >> /etc/ppp/ip-up
echo "# to get your modem to report the DCE = CARRIER speed." >> /etc/ppp/ip-up
echo "# Example: AT&FS95=46" >> /etc/ppp/ip-up

echo >> /etc/ppp/ip-up
echo "if [ -s /var/log/messages ] && ( ps xc 2>/dev/null | grep -q syslogd 2>/dev/null ); then" >> /etc/ppp/ip-up
echo 'S=`tail -n 30 /var/log/messages 2>/dev/null | grep "CARRIER[^)]" 2>/dev/null | tr -d "^M" 2>/dev/null | cut -d: -f4 2>/dev/null`' >> /etc/ppp/ip-up
echo 'echo -n "$S" >/dev/tty0' >> /etc/ppp/ip-up
echo 'echo " Local: $4 -> Remote: $5 $1" >/dev/tty0' >> /etc/ppp/ip-up
echo "else" >> /etc/ppp/ip-up
echo 'echo " Local: $4 -> Remote: $5 $1" >/dev/tty0' >> /etc/ppp/ip-up
echo "fi" >> /etc/ppp/ip-up

echo >> /etc/ppp/ip-up
echo "# If you want to ping the other end to keep the connection open." >> /etc/ppp/ip-up
echo "# The output from ping will goto >/dev/null, you won't see it." >> /etc/ppp/ip-up
echo '# Ping -i 60 = send ping every 60 seconds to remote = $5.' >> /etc/ppp/ip-up

echo >> /etc/ppp/ip-up
echo '#(ping -i 60 $5 &) >/dev/null 2>&1' >> /etc/ppp/ip-up

echo >> /etc/ppp/ip-up
echo "# If you want sendmail to send any mail in /var/spool/mqueue when" >> /etc/ppp/ip-up
echo "# you connect, remove the # below." >> /etc/ppp/ip-up

echo >> /etc/ppp/ip-up
echo "#sendmail -q" >> /etc/ppp/ip-up

echo >> /etc/ppp/ip-up
echo "# If you want fetchmail to get your mail when you connect and check" >> /etc/ppp/ip-up
echo "# every 300 seconds = 5 minutes for mail, remove the # below." >> /etc/ppp/ip-up

echo >> /etc/ppp/ip-up
echo "#fetchmail -d 300" >> /etc/ppp/ip-up

echo >> /etc/ppp/ip-up
echo "# End..." >> /etc/ppp/ip-up

#chmod 4755 /etc/ppp/ip-up 2>/dev/null
chmod 755 /etc/ppp/ip-up 2>/dev/null

if [ -s /etc/ppp/ip-down ]; then
mv /etc/ppp/ip-down /etc/ppp/ip-down.OLD
fi

ipdown() {
cat <<EOF
#!/bin/sh
#
# This script is run by pppd after the PPP connection is ended.
#
# The companion file is /etc/ppp/ip-up, it's run when the PPP
# connection is started.
#
# This file is created when you run pppsetup: `date 2>/dev/null`
#
# The environment is cleared before executing this script
# so the path must be reset.
#
PATH=/usr/sbin:/sbin:/usr/bin:/usr/local/bin:/bin
export PATH

# Stop ping if you started it in /etc/ppp/ip-up.

#killall ping 2>/dev/null

# Stop the fetchmail daemon if you started it in /etc/ppp/ip-up
# with 'fetchmail -d 300'.

#fetchmail -q

# Send "ath" = hangup etc. to modem when ppp connection ends.
# You'll see the modem reponse OK and date in the /etc/ppp/modem.cua?, 
# modem.ttyS?, or modem.modem file.
# You need the 'modem-stats' program for this below to work.
# ftp://metalab.unc.edu/pub/apps/serialcomm/modem 
# modem-stats-1.0.1.src.elf.tar.gz
# Remove the ##### from the lines below.

EOF
}

ipdown > /etc/ppp/ip-down
#chmod 4755 /etc/ppp/ip-down 2>/dev/null
chmod 755 /etc/ppp/ip-down 2>/dev/null

echo "#sleep 2   # Make sure the modem is really down." >> /etc/ppp/ip-down
echo '#DEV=`echo $2 | sed -e "s./dev/.."`' >> /etc/ppp/ip-down
echo '#echo "--------------------------" >> /etc/ppp/modem.$DEV' >> /etc/ppp/ip-down
echo '#date                              >> /etc/ppp/modem.$DEV' >> /etc/ppp/ip-down
echo '#modem-stats -c "ath" $2           >> /etc/ppp/modem.$DEV' >> /etc/ppp/ip-down
echo >> /etc/ppp/ip-down
echo "# End..." >> /etc/ppp/ip-down

echo "#!/bin/bash" > /usr/sbin/ppp-go

echo >> /usr/sbin/ppp-go
echo "ifconnect() {" >> /usr/sbin/ppp-go
echo >> /usr/sbin/ppp-go
echo 'if ! ( ifconfig | grep "P-t-P" >/dev/null ); then' >> /usr/sbin/ppp-go 
echo 'echo "* NO! not PPP connected. *"' >> /usr/sbin/ppp-go
echo "echo" >> /usr/sbin/ppp-go
echo "else" >> /usr/sbin/ppp-go
echo "exit 0" >> /usr/sbin/ppp-go
echo "fi" >> /usr/sbin/ppp-go

echo >> /usr/sbin/ppp-go
echo "if [ -s /var/log/debug ] && ( ps xc 2>/dev/null | grep -q syslogd 2>/dev/null ); then" >> /usr/sbin/ppp-go
echo 'echo "Look at /var/log/messages and or debug for more info."' >> /usr/sbin/ppp-go
echo "echo" >> /usr/sbin/ppp-go
echo "else" >> /usr/sbin/ppp-go
echo "exit 0" >> /usr/sbin/ppp-go
echo "fi" >> /usr/sbin/ppp-go

echo >> /usr/sbin/ppp-go
echo 'echo "Do you want to see /var/log/messages & debug?"' >> /usr/sbin/ppp-go
echo 'echo "The PAGER less or more will be used: Q = Quit!"' >> /usr/sbin/ppp-go
echo 'echo "The last 30 lines of each file will be shown, there"' >> /usr/sbin/ppp-go
echo 'echo -n "may be some overlap from previous attempts: (N/y) : "' >> /usr/sbin/ppp-go
echo "read ans" >> /usr/sbin/ppp-go

echo >> /usr/sbin/ppp-go
echo 'if [ "$ans" = "y" -o "$ans" = "Y" ]; then' >> /usr/sbin/ppp-go
echo 'tail -n 30 /var/log/messages /var/log/debug 2>/dev/null | less -aCMrsi || more -ds || echo "No PAGER found, no more or less."' >> /usr/sbin/ppp-go
echo "grepauth" >> /usr/sbin/ppp-go
echo "else" >> /usr/sbin/ppp-go
echo "grepauth" >> /usr/sbin/ppp-go
echo "fi" >> /usr/sbin/ppp-go
echo "}" >> /usr/sbin/ppp-go

auth() {
cat <<EOF
grepauth() {

tail -n 30 /var/log/debug 2>/dev/null | grep -i -s "rcvd" > $TMP/grep.tmp

if ( grep -i -q "auth pap" $TMP/grep.tmp ); then
echo
echo "They seem to be requesting PAP = <auth pap> for authentication."
echo "I don't know if you're setup for 'PAP' or not."
echo "Did you answer 'PAP' when you ran pppsetup?"
echo
elif ( grep -E -i -q "auth chap msoft|auth chap 80" $TMP/grep.tmp ); then
echo
echo "They seem to be requesting MS-CHAP-80 = <auth chap 80> for authentication."
echo "I don't know if you're setup for 'MS-CHAP' or not."
echo "Did you answer 'MS-CHAP' when you ran pppsetup?"
echo
elif ( grep -i -q "auth chap" $TMP/grep.tmp ); then
echo "They seem to be requesting CHAP = <auth chap> for authentication."
echo "I don't know if you're setup for 'CHAP' or not."
echo "Did you answer 'CHAP' when you ran pppsetup?"
echo
else
rm -f $TMP/grep.tmp
exit 0
fi

if ( grep -i -q "callback" $TMP/grep.tmp ); then
echo "They seem to be requesting CALLBACK."
echo "I don't know if you're setup for 'callback' or not."
echo "Did you answer 'CALLBACK' when you ran pppsetup?"
echo
fi

rm -f $TMP/grep.tmp
}
EOF
}

echo >> /usr/sbin/ppp-go
auth >> /usr/sbin/ppp-go

echo >> /usr/sbin/ppp-go
echo 'if [ "$1" = "" ]; then' >> /usr/sbin/ppp-go
echo "killall -INT pppd 2>/dev/null" >> /usr/sbin/ppp-go
echo "rm -f /var/lock/LCK* /var/run/ppp*.pid" >> /usr/sbin/ppp-go

if [ -s $TMP/cb1TEMP$$ ]; then
echo '('$PATH1' -detach connect "'$PATH2' -v -f /etc/ppp/callback" &) || exit 1' >> /usr/sbin/ppp-go
else
echo '('$PATH1' -detach connect "'$PATH2' -v -f /etc/ppp/pppscript" &) || exit 1' >> /usr/sbin/ppp-go
fi

echo "#read" >> /usr/sbin/ppp-go
echo "#ifconnect" >> /usr/sbin/ppp-go
echo "exit 0" >> /usr/sbin/ppp-go
echo "fi" >> /usr/sbin/ppp-go

echo >> /usr/sbin/ppp-go
echo 'if [ "$1" = "-q" ]; then' >> /usr/sbin/ppp-go
echo "killall -INT pppd 2>/dev/null" >> /usr/sbin/ppp-go
echo "rm -f /var/lock/LCK* /var/run/ppp*.pid" >> /usr/sbin/ppp-go

if [ -s $TMP/cb1TEMP$$ ]; then
echo '('$PATH1' connect "'$PATH2' -v -f /etc/ppp/callback" 1> /dev/null 2> /dev/null ) || exit 1' >> /usr/sbin/ppp-go
else
echo '('$PATH1' connect "'$PATH2' -v -f /etc/ppp/pppscript" 1> /dev/null 2> /dev/null ) || exit 1' >> /usr/sbin/ppp-go
fi

echo "exit 0" >> /usr/sbin/ppp-go
echo "fi" >> /usr/sbin/ppp-go

echo >> /usr/sbin/ppp-go
echo 'if [ "$1" = "-d" ]; then' >> /usr/sbin/ppp-go
echo "killall -INT pppd 2>/dev/null" >> /usr/sbin/ppp-go
echo "rm -f /var/lock/LCK* /var/run/ppp*.pid" >> /usr/sbin/ppp-go
echo '('$PATH1' file "/etc/ppp/options.demand" &) || exit 1' >> /usr/sbin/ppp-go
echo 'echo "Demand Dialing Started."' >> /usr/sbin/ppp-go
echo "exit 0" >> /usr/sbin/ppp-go
echo "fi" >> /usr/sbin/ppp-go

echo >> /usr/sbin/ppp-go
echo 'if [ "$1" = "-h" ]; then' >> /usr/sbin/ppp-go
echo 'echo "USAGE: ppp-go    <Make PPP connection, print messages to screen.>"' >> /usr/sbin/ppp-go
echo 'echo "USAGE: ppp-go -q <Make PPP connection, do not print messages to screen.>"' >> /usr/sbin/ppp-go
echo 'echo "USAGE: ppp-go -r <Remove contents of /var/log/messages & debug files.>"' >> /usr/sbin/ppp-go
echo 'echo "USAGE: ppp-go -d <Put pppd in demand dialing mode.>"' >> /usr/sbin/ppp-go
echo 'echo "USAGE: ppp-go -h <Help>"' >> /usr/sbin/ppp-go
echo "exit 0" >> /usr/sbin/ppp-go
echo "fi" >> /usr/sbin/ppp-go

echo >> /usr/sbin/ppp-go
echo 'if [ "$1" = "-r" ]; then' >> /usr/sbin/ppp-go
echo 'echo -n "Remove contents of /var/log/messages file? (N/y) : "' >> /usr/sbin/ppp-go
echo "read ans" >> /usr/sbin/ppp-go
echo 'if [ "$ans" = "y" -o "$ans" = "Y" ]; then' >> /usr/sbin/ppp-go
echo "cat /dev/null >/var/log/messages" >> /usr/sbin/ppp-go
echo 'echo "Contents of /var/log/messages file removed."' >> /usr/sbin/ppp-go
echo "else" >> /usr/sbin/ppp-go
echo 'echo "Cancelled."' >> /usr/sbin/ppp-go
echo "fi" >> /usr/sbin/ppp-go
echo 'echo -n "Remove contents of /var/log/debug file? (N/y) : "' >> /usr/sbin/ppp-go
echo "read ans" >> /usr/sbin/ppp-go
echo 'if [ "$ans" = "y" -o "$ans" = "Y" ]; then' >> /usr/sbin/ppp-go
echo "cat /dev/null >/var/log/debug" >> /usr/sbin/ppp-go
echo 'echo "Contents of /var/log/debug file removed."' >> /usr/sbin/ppp-go
echo "exit 0" >> /usr/sbin/ppp-go
echo "else" >> /usr/sbin/ppp-go
echo 'echo "Cancelled."' >> /usr/sbin/ppp-go
echo "exit 0" >> /usr/sbin/ppp-go
echo "fi" >> /usr/sbin/ppp-go
echo "fi" >> /usr/sbin/ppp-go

echo >> /usr/sbin/ppp-go
echo 'echo "USAGE: ppp-go -h <Help>"' >> /usr/sbin/ppp-go
echo "exit 1" >> /usr/sbin/ppp-go

#chmod 4755 /usr/sbin/ppp-go 2>/dev/null 
chmod 755 /usr/sbin/ppp-go 2>/dev/null 
	
cat << EOF > /etc/ppp/options
# General configuration options for PPPD:
lock
defaultroute
noipdefault
modem
/dev/$MODEM
$BAUDRATE
crtscts
# Uncomment the line below for more verbose error reporting:
#debug
# If you have a default route already, pppd may require the other side
# to authenticate itself, which most ISPs will not do.  To work around this,
# uncomment the line below.  Note that this may have negative side effects
# on system security if you allow PPP dialins.  See the docs in /usr/doc/ppp*
# for more information.
#noauth
passive
asyncmap 0
EOF

if [ ! -z "$CBPN" ]; then
echo 'callback "'$CBPN'"' >> /etc/ppp/options
fi
  
if  [ "$MSCHAP" = "MS-CHAP-SERVER-2" ] && [ -s $TMP/rspTEMP2 ]; then
echo 'name "'$MSDOMAIN\\\\$AUTH1'"' >> /etc/ppp/options
elif [ -s $TMP/rspTEMP2 ]; then
echo 'name "'$AUTH1'"' >> /etc/ppp/options
fi

if [ ! -z $DOMAINNAME ] && [ "$PAP" = "MS-CHAP-80" ]; then        
echo 'remotename "'$DOMAINNAME'"' >> /etc/ppp/options
elif [ "$DOMAINNAME" = "unknown.com" ] && [ "$PAP" = "MS-CHAP-80" ]; then        
echo 'remotename "unknown.com"' >> /etc/ppp/options
fi

chown root.root /etc/ppp/options 2>/dev/null
chmod 600 /etc/ppp/options 2>/dev/null

if [ "$PAP" = "PAP" ]; then
echo "# PAP authentication file: /etc/ppp/pap-secrets" > /etc/ppp/pap-secrets
echo "# This file should have a permission of 600." >> /etc/ppp/pap-secrets
echo "# ~# chmod 600 /etc/ppp/pap-secrets" >> /etc/ppp/pap-secrets
echo "# Username      Server      Password      IP addresses" >> /etc/ppp/pap-secrets
echo '"'$AUTH1'"   *   "'$AUTH2'"' >> /etc/ppp/pap-secrets

chown root.root /etc/ppp/pap-secrets 2>/dev/null
chmod 600 /etc/ppp/pap-secrets 2>/dev/null
        
elif [ "$PAP" = "CHAP" ]; then
echo "# CHAP authentication file: /etc/ppp/chap-secrets" > /etc/ppp/chap-secrets
echo "# This file should have a permission of 600." >> /etc/ppp/chap-secrets
echo "# ~# chmod 600 /etc/ppp/chap-secrets" >> /etc/ppp/chap-secrets
echo "# Username      Server      Password      IP addresses" >> /etc/ppp/chap-secrets
echo '"'$AUTH1'"   *   "'$AUTH2'"' >> /etc/ppp/chap-secrets
echo '*   "'$AUTH1'"   "'$AUTH2'"' >> /etc/ppp/chap-secrets

chown root.root /etc/ppp/chap-secrets 2>/dev/null
chmod 600 /etc/ppp/chap-secrets 2>/dev/null

elif [ "$PAP" = "MS-CHAP-80" ] && [ "$MSCHAP" = "MS-CHAP-SERVER-2" ]; then
echo "# MS-CHAP authentication file: /etc/ppp/chap-secrets" > /etc/ppp/chap-secrets
echo "# This file should have a permission of 600." >> /etc/ppp/chap-secrets
echo "# ~# chmod 600 /etc/ppp/chap-secrets" >> /etc/ppp/chap-secrets
echo "# Username      RemoteHost      Password" >> /etc/ppp/chap-secrets
echo '"'$MSDOMAIN\\\\$AUTH1'"   "'$DOMAINNAME'"   "'$AUTH2'"' >> /etc/ppp/chap-secrets
echo '"'$DOMAINNAME'"   "'$MSDOMAIN\\\\$AUTH1'"   "'$AUTH2'"' >> /etc/ppp/chap-secrets

chown root.root /etc/ppp/chap-secrets 2>/dev/null
chmod 600 /etc/ppp/chap-secrets 2>/dev/null

elif [ "$PAP" = "MS-CHAP-80" ]; then
echo "# MS-CHAP authentication file: /etc/ppp/chap-secrets" > /etc/ppp/chap-secrets
echo "# This file should have a permission of 600." >> /etc/ppp/chap-secrets
echo "# ~# chmod 600 /etc/ppp/chap-secrets" >> /etc/ppp/chap-secrets
echo "# Username      RemoteHost      Password" >> /etc/ppp/chap-secrets
echo '"'$AUTH1'"   "'$DOMAINNAME'"   "'$AUTH2'"' >> /etc/ppp/chap-secrets
echo '"'$DOMAINNAME'"   "'$AUTH1'"   "'$AUTH2'"' >> /etc/ppp/chap-secrets

chown root.root /etc/ppp/chap-secrets 2>/dev/null
chmod 600 /etc/ppp/chap-secrets 2>/dev/null
fi

cp /etc/ppp/options /etc/ppp/options.demand

echo "ipcp-accept-local" >> /etc/ppp/options.demand
echo "ipcp-accept-remote" >> /etc/ppp/options.demand
echo "0.0.0.0:10.10.10.10" >> /etc/ppp/options.demand
echo "demand" >> /etc/ppp/options.demand

if [ -s $TMP/cb1TEMP$$ ]; then
echo 'connect "'$PATH2' -v -f /etc/ppp/callback"' >> /etc/ppp/options.demand
else
echo 'connect "'$PATH2' -v -f /etc/ppp/pppscript"' >> /etc/ppp/options.demand
fi

chown root.root /etc/ppp/options.demand 2>/dev/null
chmod 600 /etc/ppp/options.demand 2>/dev/null

if [ -f $HOME/.ppprc ]; then
mv $HOME/.ppprc $HOME/.ppprc.off
PPPRC="YES"
fi

demand() {
 cat <<EOF
PPP-2.3.0 and later has a demand dialing option, you can use it this way,
the options file for demand dialing will be /etc/ppp/options.demand.

Start ppp-go -d, pppd will just stay in the background until you try to 
connect to some site, then pppd will dial your service provider and make 
the ppp connection.

~# ppp-go -d        <-Start pppd this way for demand dialing.)
 #                  <-It should drop you back to #.)
 	      
~# ftp ftp.funet.fi               <-Pppd will start dialing.)             
 # lynx http://www.foo.com        <-Pppd will start dialing etc.)
 # ppp-off -d       <-To end and restart pppd in demand dialing mode.)
 # ppp-off                        <-To end the ppp connection.)

End...
=========================================================================
EOF
}

other() {
 cat <<EOF
These are some other ways to make a PPP connection.

The best way to make a PPP connection is to create a chat script, if
you're having trouble with the chat script you can use these methods
below to make the PPP connection.

You can also use these methods below to see what's going on when you
connect to your service provider, i.e. what do they require, do they
present you with a Login: or Username: and Password: prompt etc.

What steps do you have to go through before they start PPP at there
end?

First make sure the IP address of your service providers nameserver  
is in the /etc/resolv.conf file.

nameserver 205.117.312.56   <-For example.)
 
=========================================================================
Using 'dip' to make the PPP connection.
=========================================================================

~# dip -tv
Host name lookup failure

If you get the above messgae when you start 'dip', it's because you
don't have your hostname in the /etc/hosts file.

~# hostname
foobar

If your hostname were 'foobar' you should put it in the /etc/hosts file.

127.0.0.1   localhost
0.0.0.0     foobar.localnet foobar

~# dip -tv
dip> port /dev/ttyS1
can't open - problems with locking ttyS1

If you get the above message after "port /dev/modem", it means you have a
lock file in /var/lock/LCK..ttyS1, remove the lock file and kill dip.

~# rm /var/lock/LCK*
 # killall -9 dip

~# dip -tv

dip> port /dev/ttyS1    <-Where's the modem? ttyS0 = com1 ttyS1 = com2 etc.)
dip> speed 115200      <-Modem speed: 19200 38400 57600
dip> term

at&fw2                 <-Modem init string.)
atdt1234567            <-Replace 1234567 with the phone number.)

Usally you give your username and password then ppp is started, if
they use PAP or CHAP you probably won't be asked for a username and
password, they will just say that PPP has been started or nothing.

Press Ctrl ] to exit dip term mode when PPP is started at their end.

dip> default              <-Use default route.)
dip> mode ppp             <-Start PPP at your end.)

~# ping metalab.unc.edu   <-To see if you're connected.)

~# dip -k                 <-To kill dip and the PPP connection.)

=========================================================================
Using 'minicom' to make the PPP connection.
=========================================================================

Keep the /etc/ppp/options file that was created by pppsetup, it should 
have at least these options in it.

lock
defaultroute
noipdefault
/dev/ttyS1         <- ttyS0 = com1 ttyS1 = com2 ttyS2 = com3 ttyS3 = com4           
57600
modem
crtscts
debug
asyncmap 0

~# minicom -m -s

at&fw2
atdt1234567

Press Alt Q to exit minicom without reset after PPP is started at 
the other end.

~# pppd                <-Start PPP at your end.)

~# ppp-off             <-To end the PPP connection.)
 # killall -INT pppd   <-If you don't have 'ppp-off' end it this way.)

End...
=========================================================================
EOF
}

echo "=========================================================================" > /etc/ppp/pppsetup.txt
cat $TMP/txtTEMP01 >> /etc/ppp/pppsetup.txt

echo "=========================================================================" > $TMP/txtTEMP$$
echo "These are your PPP configuration files and instructions..." >> $TMP/txtTEMP$$
echo "=========================================================================" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$

if [ ! -s $TMP/cb1TEMP$$ ] && [ ! -s $TMP/sayTEMP1 ]; then
echo "# This is your /etc/ppp/pppscript." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
cat /etc/ppp/pppscript >> $TMP/txtTEMP$$
elif [ ! -s $TMP/cb1TEMP$$ ] && [ -s $TMP/sayTEMP1 ]; then
echo "# This is your /etc/ppp/pppscript." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Look at /etc/ppp/pppscript." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
fi

if [ -s $TMP/cb1TEMP$$ ]; then
echo "# This is your /etc/ppp/callback script." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Look at /etc/ppp/callback." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
fi

echo "# This is your /etc/ppp/options file." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
cat /etc/ppp/options >> $TMP/txtTEMP$$

if [ "$MODERROR" = "YES" ]; then
echo >> $TMP/txtTEMP$$
echo "WARNING: I could not find the modem device: '/dev/$MODEM'" >> $TMP/txtTEMP$$
echo "ttyS0 = com1 ttyS1 = com2 ttyS2 = com3  ttyS3 = com4" >> $TMP/txtTEMP$$
echo "# MAKEDEV $MODEM   # /dev/MAKEDEV $MODEM" >> $TMP/txtTEMP$$
fi

if [ "$DOMAINNAME" = "unknown.com" ] && [ "$PAP" = "MS-CHAP-80" ]; then        
echo >> $TMP/txtTEMP$$
echo "The remotename option is required for microsoft's ms-chap-80." >> $TMP/txtTEMP$$
echo "You didn't give a DOMAIN NAME so i put unknown.com, you should" >> $TMP/txtTEMP$$
echo "change that to your service providers domain name." >> $TMP/txtTEMP$$
fi

if [ ! "$MODERROR" = "YES" ]; then
echo >> $TMP/txtTEMP$$
echo "I created the symbolic link: /dev/modem -> /dev/$MODEM" >> $TMP/txtTEMP$$
fi

echo >> $TMP/txtTEMP$$
echo "# This is your /etc/ppp/options.demand dialing file." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
cat /etc/ppp/options.demand >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
echo "If you have a ethernet connection you should change the local:remote" >> $TMP/txtTEMP$$
echo "IP addresses in the options.demand file, to your actual local and" >> $TMP/txtTEMP$$
echo "remote address.  Example: 215.346.117.89:312.217.187.96" >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
echo "# This in your /etc/resolv.conf file." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
cat /etc/resolv.conf >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
if [ -z $DNSIP ]; then
echo "207.132.116.5   <-IMPORTANT: This should be the IP address of" >> $TMP/txtTEMP$$
echo "                             your service providers nameserver." >> $TMP/txtTEMP$$
else
echo "$DNSIP   <-IMPORTANT: This should be the IP address of" >> $TMP/txtTEMP$$
echo "                    your service providers nameserver." >> $TMP/txtTEMP$$
fi

if [ -z $DNSIP ]; then
echo >> $TMP/txtTEMP$$
echo "WARNING: You didn't give a IP address for your internet service" >> $TMP/txtTEMP$$
echo "providers nameserver, i put '207.132.116.5' but this may not work." >> $TMP/txtTEMP$$
fi

if [ "$PAP" = "CHAP" ] || [ "$PAP" = "MS-CHAP-80" ]; then
echo >> $TMP/txtTEMP$$
echo "# This is your /etc/ppp/chap-secrets file." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Look at /etc/ppp/chap-secrets." >> $TMP/txtTEMP$$
fi

if [ "$DOMAINNAME" = "unknown.com" ] && [ "$PAP" = "MS-CHAP-80" ]; then
echo >> $TMP/txtTEMP$$
echo "You didn't give a DOMAIN NAME that's why i put unknown.com in" >> $TMP/txtTEMP$$
echo "the /etc/ppp/chap-secrets file." >> $TMP/txtTEMP$$
echo "You should change that to your service providers domain name." >> $TMP/txtTEMP$$
fi

if [ "$PAP" = "PAP" ]; then
echo >> $TMP/txtTEMP$$
echo "# This is your /etc/ppp/pap-secrets file." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Look at /etc/ppp/pap-secrets." >> $TMP/txtTEMP$$
fi

if [ "$PATH1" = "pppd" ]; then
echo >> $TMP/txtTEMP$$
echo "ATENTION: I couldn't find <pppd> on your system." >> $TMP/txtTEMP$$
echo "You need <pppd> on your system to make the PPP connection." >> $TMP/txtTEMP$$
fi

if [ "$PATH2" = "chat" ]; then
echo >> $TMP/txtTEMP$$
echo "ATENTION: I couldn't find <chat> on your system." >> $TMP/txtTEMP$$
echo "You need <chat> on your system to make the PPP connection." >> $TMP/txtTEMP$$
fi

if [ ! "$MSG1" = "YES" ] && [ ! "$MSG2" = "YES" ]; then
echo >> $TMP/txtTEMP$$
echo "ATENTION: I couldn't find 'PPP' in the kernel or as a module." >> $TMP/txtTEMP$$
echo "You'll need 'PPP' in the kernel or as a module to make a PPP connection." >> $TMP/txtTEMP$$
fi

if [ "$PPPRC" = "YES" ]; then
echo >> $TMP/txtTEMP$$
echo "ATENTION: I found a $HOME/.ppprc file and moved it to" >> $TMP/txtTEMP$$
echo ".ppprc.off, it might interfere with the PPP connection." >> $TMP/txtTEMP$$
fi

echo >> $TMP/txtTEMP$$
echo "Does everything look correct? if not, run 'pppsetup' again..." >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
echo "=========================================================================" >> $TMP/txtTEMP$$
echo "To connect to your service provider." >> $TMP/txtTEMP$$
echo "=========================================================================" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "~# ppp-go      <-Make PPP connection.)" >> $TMP/txtTEMP$$
 
echo >> $TMP/txtTEMP$$
echo "You'll hear and see the modem dialing then once connected," >> $TMP/txtTEMP$$
echo "logging you in Username: or Login: and Password: etc." >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
echo "You won't see a Username or Login: and Password: prompt" >> $TMP/txtTEMP$$
echo "if they're using PAP or CHAP to authenticate you." >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
echo "If they use PAP or CHAP you'll just see CONNECT -- got it." >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
echo "If the connection was successful you'll see the Local IP and" >> $TMP/txtTEMP$$
echo "Remote IP address printed to the screen, you can press [Enter]." >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
echo "If you run ppp-go in X windows you probably won't see a Local" >> $TMP/txtTEMP$$
echo "and Remote IP address printed to the screen, you'll just see" >> $TMP/txtTEMP$$
echo "the connection process come to a end, wait a few seconds and" >> $TMP/txtTEMP$$
echo "press [Enter] at that point." >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
echo "If you don't connect for whatever reason e.g. Failed No" >> $TMP/txtTEMP$$ 
echo "Dialtone, Busy, No Carrier, Whatever, Exit, just press" >> $TMP/txtTEMP$$ 
echo "[Enter] at that point." >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
echo "if you have syslogd running, you can see the output messages" >> $TMP/txtTEMP$$ 
echo "from pppd and chat in the /var/log/messages and or debug file." >> $TMP/txtTEMP$$ 

echo >> $TMP/txtTEMP$$
echo "Sample /var/log/messages file." >> $TMP/txtTEMP$$    
echo >> $TMP/txtTEMP$$
echo "`hostname 2>/dev/null` pppd[562]: Serial connection established." >> $TMP/txtTEMP$$    
echo "`hostname 2>/dev/null` pppd[562]: Using interface ppp0" >> $TMP/txtTEMP$$              
echo "`hostname 2>/dev/null` pppd[562]: Connect: ppp0 <--> /dev/modem" >> $TMP/txtTEMP$$     
echo "`hostname 2>/dev/null` pppd[562]: local IP address 215.87.78.18" >> $TMP/txtTEMP$$      
echo "`hostname 2>/dev/null` pppd[562]: remote IP address 205.94.97.35" >> $TMP/txtTEMP$$     

echo >> $TMP/txtTEMP$$
echo "You don't have a successful PPP connection until you" >> $TMP/txtTEMP$$ 
echo "receive a local & remote IP address like above." >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
echo "If you have the X window system, you could connect in a Xterm." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "`hostname 2>/dev/null` # startx" >> $TMP/txtTEMP$$
echo "`hostname 2>/dev/null` # ppp-go" >> $TMP/txtTEMP$$
echo "`hostname 2>/dev/null` # netscape mosaic etc." >> $TMP/txtTEMP$$
 
echo >> $TMP/txtTEMP$$
echo "~# ppp-off     <-To end the ppp connection.)" >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
echo "~# ppp-go -h   <-For help.)" >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
echo 'There is no support in linux for "WinModems", if you have a' >> $TMP/txtTEMP$$
echo "WinModem you will not be able to use it in linux." >> $TMP/txtTEMP$$ 
echo >> $TMP/txtTEMP$$
echo "There is support for plug n play modems, if you have a pnp" >> $TMP/txtTEMP$$
echo 'modem you may need "isapnptools" to get it recognized.' >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
echo "=========================================================================" >> $TMP/txtTEMP$$
if [ -s /usr/doc/pppsetup/pppsetup-$VERSION.README ]; then
echo "#### Look at the /usr/doc/pppsetup/pppsetup-$VERSION.README. ####" >> $TMP/txtTEMP$$
fi
echo "#### A copy of this text can be found in: /etc/ppp/pppsetup.txt ####" >> $TMP/txtTEMP$$
echo "=========================================================================" >> $TMP/txtTEMP$$

echo >> $TMP/txtTEMP$$
echo "Done... You can exit now..." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "End..." >> $TMP/txtTEMP$$
echo "=========================================================================" >> $TMP/txtTEMP$$

dialog --title "DONE" --clear --textbox "$TMP/txtTEMP$$" 22 78	
	  	  
clear 2>/dev/null || echo

cat $TMP/txtTEMP$$ >> /etc/ppp/pppsetup.txt
chmod 600 /etc/ppp/pppsetup.txt 2>/dev/null 

if [ ! -s /etc/syslog.conf ]; then
echo "# Log info & debug messages to these files." > /etc/syslog.conf
echo >> /etc/syslog.conf
echo "*.=debug		                /var/log/debug" >> /etc/syslog.conf
echo "*.=info;*.=notice		        /var/log/messages" >> /etc/syslog.conf

demand >> /etc/ppp/pppsetup.txt
other >> /etc/ppp/pppsetup.txt
rm -f $TMP/*TEMP* 2>/dev/null

killall -9 syslogd 2>/dev/null 
syslogd & 2>/dev/null 
echo
echo "#### A copy of this text can be found in: /etc/ppp/pppsetup.txt ####" 
if [ -s /usr/doc/pppsetup/pppsetup-$VERSION.README ]; then
echo "#### Look at the /usr/doc/pppsetup/pppsetup-$VERSION.README. ####" 
fi
echo
exit 

else
demand >> /etc/ppp/pppsetup.txt
other >> /etc/ppp/pppsetup.txt
rm -f $TMP/*TEMP* 2>/dev/null
echo
echo "#### A copy of this text can be found in: /etc/ppp/pppsetup.txt ####" 
if [ -s /usr/doc/pppsetup/pppsetup-$VERSION.README ]; then
echo "#### Look at the /usr/doc/pppsetup/pppsetup-$VERSION.README. ####" 
fi
echo
exit 
fi

