LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Nice script for Dynamic IP and DNS (https://www.linuxquestions.org/questions/slackware-14/nice-script-for-dynamic-ip-and-dns-126716/)

gnashley 12-17-2003 02:32 PM

Nice script for Dynamic IP and DNS
 
For those who don't use KDE or Gnome but miss the PPP config utilities which setup ppp for use with dynamic IP and DNS assignment, I've come up with a script which does so. I use windowmaker and a little DOCKAPP called yawmppp to connect to the internet. If I hadn't already used kppp and made a note of the entries in /etc/ppp/resolv.conf, I would never be able to go on-line, since pppsetup only sets up for static DNS. So I altered (some may say hacked) pppsetup in such a way that it writes the scripts and negotiates the connection providing dynamic IP and DNS. This script ISPSETUP is just a subset of the pppsetup that comes in slackware, so it won't misplace files or do weird things with any permissions. Enjoy!

#!/bin/bash
# ISPSETUP -- Script to set up pppd
# Based on PPPSETUP 1.98
# 12/12/03 GNA ISPSETUP is a subset of the script PPPSETUP (see History below).
# This script is designed to provide a simple interface to establish
# an internet connection in the simplest possible way. This script
# assumes that you will only be using only one connection, using a
# dial-up modem, with Dynamic IP addressing, Dynamic assignment of
# a Domain Name Server and PAP authentication. For other types of
# connections you should run the 'pppsetup' script instead of this.
# 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.
# 12/13/2003 GNA Major re-write to make simple connection script
# for newbies, and modern ISP's which usually use
# PAP authentication and Dynamic Name Servers.
#

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 as: root"
echo "You could also try this: # sudo ispsetup"
echo "You could also try this: # su -c ispsetup"
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

SYS="for PHOENIX."

VERSION="1.0"

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 "ISPSETUP $VERSION $SYS" > $TMP/txtTEMP01
echo >> $TMP/txtTEMP01
echo "This script will help you set up your Internet connection. You will" >> $TMP/txtTEMP01
echo "need to know the phone number of your Internet Service Provider (ISP)," >> $TMP/txtTEMP01
echo "the username and password that your ISP gave you, and the location of" >> $TMP/txtTEMP01
echo "your modem. ISPSETUP will set up a single connection using Dynamic IP" >> $TMP/txtTEMP01
echo "and DNS addressing, and PAP authorization, since these are the most" >> $TMP/txtTEMP01
echo "common options. For any other kind of connection you should run the." >> $TMP/txtTEMP01
echo "pppsetup script.ISPSETUP is a subset of PPPSETUP which was written by" >> $TMP/txtTEMP01
echo "Robert S. Liesenfeld, with changes by Kent Robotti and Patrick " >> $TMP/txtTEMP01
echo "Volkerding. ISPSETUP by Gilbert Ashley <gnashley@earthlink.net>." >> $TMP/txtTEMP01

echo >> $TMP/txtTEMP01
echo "Press [Enter] to continue with pppsetup..." >> $TMP/txtTEMP01

dialog --backtitle "ISPSETUP $VERSION/Phoenix" --textbox "$TMP/txtTEMP01" 18 75

while [ -z "$PHONENUM" ]
do
echo >> $TMP/txtTEMP$$
echo "What is the phone number of your Internet Service Provider?" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "Do not use any dashes,dots or spaces between the numbers." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "In the USA, if you have call-waiting you should add '70,' before the" >> $TMP/txtTEMP$$
# echo >> $TMP/txtTEMP$$
echo "number. Example: 70,6543210 (comma required)" >> $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 "ISP configuration cancelled."
exit
fi

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

if [ -z "$PHONENUM" ]; then
clear 2>/dev/null || echo
rm -f $TMP/*TEMP*
echo "ISP 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 "ISP 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$$
echo >> $TMP/txtTEMP$$
echo "Usually you should choose a rate higher than your modem speed." >> $TMP/txtTEMP$$
echo "For instance, if you have a 56K modem, try 115200." >> $TMP/txtTEMP$$
dialog --backtitle "MODEM BAUD RATE ..." --menu "`cat $TMP/txtTEMP$$`" 18 72 7 \
230400 "230KBps - 56Kbps modem..." \
115200 "115KBps - 56Kbps modem..." \
57600 "57.6KBps - 33.6, or 56Kbps modem..." \
38400 "38.4KBps - 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 "ISP configuration cancelled."
exit
fi

INIT="default"

echo "Put the Username or Login name given to you by your ISP in the box below." > $TMP/txtTEMP1
echo >> $TMP/txtTEMP1
echo "Usually this is your username or number followed" >> $TMP/txtTEMP1
echo "by their @domain name like this:" >> $TMP/txtTEMP1
echo "Example: jerry@foo.boo.com" >> $TMP/txtTEMP1
echo "Example: 1234567@foo.boo.com" >> $TMP/txtTEMP1
echo >> $TMP/txtTEMP1
echo "If you use net-by-call it might be something like:" >> $TMP/txtTEMP1
echo "Example: surf@easysurf4you" >> $TMP/txtTEMP1
echo >> $TMP/txtTEMP1

dialog --backtitle "USERNAME or LOGIN? ..." --inputbox "`cat $TMP/txtTEMP1`" 19 64 2> $TMP/rspTEMP$$

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

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

echo "What's the password for the username above?" >> $TMP/txtTEMP2
echo "Example: Xpi9u87T" >> $TMP/txtTEMP2
dialog --backtitle "PAP PASSWORD? ..." --inputbox "`cat $TMP/txtTEMP2`" 10 64 2> $TMP/rspTEMP$$

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

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 [ -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 90" > /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" = "default" ]; then
echo '"" "ATM1L1"' >> /etc/ppp/pppscript
echo 'OK "'ATDT$PHONENUM'"' >> /etc/ppp/pppscript
else
echo '"" '$INIT'' >> /etc/ppp/pppscript
echo '"'ATDT$PHONENUM'"' >> /etc/ppp/pppscript
fi
echo "TIMEOUT 90" >> /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 ispsetup: `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 "# This makes a symbolic link from /etc/resolv.conf to /etc/ppp/resolv.conf." >> /etc/ppp/ip-up
echo "# It will be removed by /etc/ppp/ip-down." >> /etc/ppp/ip-up

echo >> /etc/ppp/ip-up
echo 'ln -s /etc/ppp/resolv.conf /etc/resolv.conf' >> /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 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

==========================================================
On trying to post, it was too long so I'll have to put the rest in another post. Sorry!

gnashley 12-17-2003 02:35 PM

Here follows the rest of ISPSETUP:

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 ispsetup: `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

# Remove stale resolv.conf from /etc/ppp/
rm -f /etc/ppp/resolv.conf
rm -f /etc/resolv.conf

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

#fetchmail -q

EOF
}

ipdown > /etc/ppp/ip-down
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 "You must run pppsetup in order to set up MS-CHAP authentication."
echo
elif ( grep -i -q "auth chap" $TMP/grep.tmp ); then
echo "They seem to be requesting CHAP = <auth chap> for authentication."
echo "You must run pppsetup in order to set up CHAP authentication."
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 "You must run pppsetup to set up 'CALLBACK'."
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
noauth
passive
asyncmap 0
name "$USERNAME"
usepeerdns
EOF

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 '"'$USERNAME'" * "'$PASSWORD'"' >> /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
# fi
echo
# exit
# fi

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

echo "=========================================================================" > $TMP/txtTEMP$$
echo "These are your PPP configuration files and instructions. Use the" >> $TMP/txtTEMP$$
echo "cursor keys to scroll down and see the rest of this notice." >> $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

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 [ ! "$MODERROR" = "YES" ]; then
echo >> $TMP/txtTEMP$$
echo "# A symbolic link has been created from: /dev/modem -> /dev/$MODEM" >> $TMP/txtTEMP$$
fi

echo >> $TMP/txtTEMP$$
echo "# Your Username and Password are in the file: /etc/ppp/pap-secrets" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$

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 [ "$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 "How to connect to your Internet Service Provider." >> $TMP/txtTEMP$$
echo "=========================================================================" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
#echo "~# ppp-go <-Make PPP connection.)" >> $TMP/txtTEMP$$
echo "Phoenix comes with yawmppp, a dial-up and net monitoring utility." >> $TMP/txtTEMP$$
echo "This is the DOCKAPP that says WEB and has a 'check' mark and 'X'." >> $TMP/txtTEMP$$
echo "To start your internet connection just click on the 'check' mark." >> $TMP/txtTEMP$$
echo "To end your connection just click the 'X'. YAWMPPP will report" >> $TMP/txtTEMP$$
echo "your connection speed and the time you have been connected." >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "If you have problems or want to check your connection first," >> $TMP/txtTEMP$$
echo "you can run ppp manually by opening an xterm and typing:" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "ppp-on <-establish ppp connection)" >> $TMP/txtTEMP$$
echo >> $TMP/txtTEMP$$
echo "You'll hear and see the modem dialing, then, once connected," >> $TMP/txtTEMP$$

#echo >> $TMP/txtTEMP$$
echo "you'll see CONNECT: ppp0 <--> /dev/ttyS?." >> $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 "You'll also see one or more Domain Name Server (DNS)" >> $TMP/txtTEMP$$
echo "addresses. It's a good idea to write these down for future" >> $TMP/txtTEMP$$
echo "reference, in case you have problems with dynamic DNS assignment." >> $TMP/txtTEMP$$
echo "If you use pppsetup instead of ispsetup you will need these numbers." >> $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 "~# 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
rm -f $TMP/*TEMP* 2>/dev/null
echo
echo "#### A copy of this text can be found in: /etc/ppp/pppsetup.txt ####"
echo
exit
fi


All times are GMT -5. The time now is 04:57 AM.