Re: PPP dial-up script working at last.
On Sun, 13 Jul 1997, mark powers wrote:
>
> upp105@ibm.rhrz.uni-bonn.de said:
>
> > -- after there is a directory /etc/ppp all the files _should_
> > be there, IMO. As it is now, the configuration of ppp is not easy to
> > understand.
>
> Agreed, though a simple question-and-answer PPP configuration script ought not
> to be too difficult. I have one from Sunsite that does the trick, although
> under the hood all it does is write your chatscript and leave a script that
> does naught but invoke pppd with the proper arguments ;) but I had to go
> through two or three for the scrap heap before finding it. Smail configuration
> for Debian was impressive in its simplicity - any thoughts on a "Debian PPP
> setup script" along the same lines?
Concerning PPP:
I picked up a script from a friend that makes setting up ppp
extremely easy. A few Q&A's and it's done. I slightly modified it to
write to /etc/ppp.chatscript and /etc/ppp/ppp-on-dialer, and when
summoning the ppp daemon I added the options: persist crtscts
ipcp-accept-remote ipcp-accept-local modem. It takes care of resolv.conf
as well by prompting the user for their ISP's domain name and name
server's ip. However, it doesn't address ppp.options_out. Under most
configs this should not be a huge problem.
~bash
#!/bin/sh
###############################################################################
#
# 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)
###############################################################################
VERSION="1.2"
echo > /tmp/txtTEMP$$
echo "PPPSETUP v$VERSION" >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
echo "Written by Robert S. Liesenfeld <xunil@bitstream.net> <IRC:Xunil>" >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
echo " press [enter]" >> /tmp/txtTEMP$$
clear
dialog --title "PPPSETUP v$VERSION" --msgbox "`cat /tmp/txtTEMP$$`" 10 80
if [ -f README.pppsetup ]; then
dialog --title README --textbox README.pppsetup 20 80
fi
if [ ! `whoami` = "root" ]; then
dialog --title "Must Be Root" --msgbox "You must be root to run this script." 10 80
exit 1
fi
while [ -z "$PHONENUM" ]
do
echo > /tmp/txtTEMP$$
echo "To begin setting up your PPP connection, I need to know a" >> /tmp/txtTEMP$$
echo "few things. For starters, what is the phone number of your" >> /tmp/txtTEMP$$
echo "Internet service provider?" >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
echo "(Note: in the USA, use *70, [comma required!] to turn off call" >> /tmp/txtTEMP$$
echo " waiting.)" >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
dialog --title "Phone Number" --inputbox "`cat /tmp/txtTEMP$$`" 20 80 2> /tmp/rspTEMP$$
PHONENUM="`head -1 /tmp/rspTEMP$$`"
if [ -z "$PHONENUM" ]; then
clear
echo "PPP configuration cancelled."
exit 0
fi
done
if [ -e "/dev/modem" ]; then
echo > /tmp/txtTEMP$$
echo -n "Found your modem...(" >> /tmp/txtTEMP$$
echo -n `ls -l /dev/modem | cut -b56-80` >> /tmp/txtTEMP$$
echo ")" >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
dialog --title "Modem Found" --msgbox "`cat /tmp/txtTEMP$$`" 10 80
DEVICE="/dev/modem"
else
while [ -z "$DEVICE" ]
do
echo > /tmp/txtTEMP$$
echo "Secondly, what is the name of your modem device?" >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
dialog --title "Modem Device" --menu "`cat /tmp/txtTEMP$$`" 20 80 12 \
cua0 "/dev/cua0 (COM1: under DOS)" \
cua1 "/dev/cua1 (COM2: under DOS)" \
cua2 "/dev/cua2 (COM3: under DOS)" \
cua3 "/dev/cua3 (COM4: under DOS)" \
2> /tmp/rspTEMP$$
DEVICE="`cat /tmp/rspTEMP$$`"
if [ -z $DEVICE ]; then
clear
echo "PPP configuration cancelled."
exit 0
fi
DEVICE="/dev/$DEVICE"
done
fi
echo > /tmp/txtTEMP$$
echo "What baud rate is your modem?" >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
dialog --title "Baud Rate" --menu "`cat /tmp/txtTEMP$$`" 20 80 12 \
115200 "115KBps - Nirvana!" \
38400 "38.4KBps - Hangin' ten on the 'net!" \
19200 "19.2KBps - Better known as 14.4" \
9600 "9600bps - Kinda pokey, aren'tcha?" \
2400 "2400bps - God help you. :>" 2> /tmp/rspTEMP$$
BAUDRATE="`cat /tmp/rspTEMP$$`"
if [ -z $BAUDRATE ]; then
clear
echo "PPP configuration cancelled."
exit 0
fi
echo > /tmp/txtTEMP$$
echo "What is your Internet provider's domain name?" >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
echo "(This is usually something like umn.edu," >> /tmp/txtTEMP$$
echo " mr.net, or winternet.com)" >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
dialog --title "Domain Name" --inputbox "`cat /tmp/txtTEMP$$`" 20 80 2> /tmp/rspTEMP$$
DOMAINNAME="`cat /tmp/rspTEMP$$`"
if [ -z $DOMAINNAME ]; then
clear
echo "PPP configuration cancelled."
exit 0
fi
echo > /tmp/txtTEMP$$
echo "What is the IP address of your Internet provider's nameserver?" >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
echo "Note: Your service provider's technical support can provide you" >> /tmp/txtTEMP$$
echo "with this information." >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
dialog --title "DNS IP" --inputbox "`cat /tmp/txtTEMP$$`" 20 80 2> /tmp/rspTEMP$$
DNSIP="`cat /tmp/rspTEMP$$`"
if [ -z $DNSIP ]; then
clear
echo "PPP configuration cancelled."
exit 0
fi
if [ -f /etc/resolv.conf ]; then
mv /etc/resolv.conf /etc/resolv.conf.old
fi
echo > /etc/resolv.conf
echo "domain $DOMAINNAME" >> /etc/resolv.conf
echo "nameserver $DNSIP" >> /etc/resolv.conf
OLDDIR=`pwd`
cd $HOME
echo > /tmp/txtTEMP$$
echo "Now comes the tough part. :) I need to know what your" >> /tmp/txtTEMP$$
echo "dialup system prints to your screen, and I need to know what" >> /tmp/txtTEMP$$
echo "you respond with." >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
echo "( End by pressing Cancel )" >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
echo "ABORT BUSY ABORT 'NO CARRIER' '' ATDT$PHONENUM" > /etc/ppp/ppp-on-dialer
dialog --title "Chat Script" --msgbox "`cat /tmp/txtTEMP$$`" 20 80
MESSAGE=' '
YOUSAY=' '
while [ ! "$MESSAGE" = "" -a ! "$YOUSAY" = "" ]
do
dialog --title "Expect" --inputbox "What text should I wait for?" 10 80 2> /tmp/rspTEMP$$
MESSAGE="`cat /tmp/rspTEMP$$`"
if [ -z "$MESSAGE" ]; then
continue
fi
dialog --title "Send" --inputbox "And what text should I send?" 10 80 2> /tmp/rspTEMP$$
YOUSAY="`cat /tmp/rspTEMP$$`"
if [ -z "$YOUSAY" ]; then
continue
fi
echo "$MESSAGE $YOUSAY" >> /etc/ppp/ppp-on-dialer
done
rm -f /etc/ppp.chatscript
echo "#!/bin/sh" > /etc/ppp.chatscript
echo "/usr/sbin/pppd connect '/usr/sbin/chat -v -f /etc/ppp/ppp-on-dialer' \\" >> /etc/ppp.chatscript
echo "defaultroute persist crtscts modem ipcp-accept-remote ipcp-accept-local \\" >> /etc/ppp.chatscript
echo "$BAUDRATE $DEVICE &" >> /etc/ppp.chatscript
chmod 700 /etc/ppp/ppp-on-dialer
chmod 700 /etc/ppp.chatscript
cd $OLDDIR
echo > /tmp/txtTEMP$$
echo "To connect to your remote system, type /etc/ppp.chatscript" >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
echo "Then wait 2 minutes or so. You should be able to use the Internet" >> /tmp/txtTEMP$$
echo " without a problem. (Hopefully. ;)" >> /tmp/txtTEMP$$
echo >> /tmp/txtTEMP$$
dialog --title "All Done" --msgbox "`cat /tmp/txtTEMP$$`" 20 80
rm -f /tmp/txtTEMP$$
rm -f /tmp/rspTEMP$$
exit 0
Reply to: