Metropoli BBS
VIEWER: dipsetup MODE: TEXT (ASCII)
#!/bin/sh
# This script "dipsetup" creates a dip script for connecting to a internet 
# service provider...
#
# This script requires 'dip.mold', which should be in the same directory as
# this script: /usr/sbin/dipsetup dip.mold

clear
echo
echo "This script will ask questions relating to your system and ISP."
echo 
echo "You will need to have the program 'dip' on your system, to use"
echo "the dip script that will be created by this script."
echo
echo "You'll need the program 'pppd', if you want to make a ppp connection."
echo
echo "Continue (Y/n)"
read CONT
if [ "$CONT" = "n" ]
  then exit
elif [ "$CONT" = "N" ]
  then exit
fi
echo
GATEIP=""
while [ "$DNAME" = "" ]
  do
  echo "What is your internet service providers domain name?"
  echo "For example: foo.com foo.net foo.edu"
  echo "The domain name will be put in the /etc/resolv.conf file."
  read DNAME
  done
echo
GATEIP=""
while [ "$GATEIP" = "" ]
  do
  echo "What is your internet service providers IP address?"
  echo "For example: 255.116.98.75   <-It will be a series of"
  echo "numbers like this, it's important that this be correct,"
  echo "if you don't know, ask your service provider..."
  echo "The IP address will be put in the /etc/resolv.conf file."
  read GATEIP
  done
echo
MODEM_PATH=""
while [ "$MODEM_PATH" = "" ]
  do
  echo "What is the full path to your modem?"
  echo "For example: /dev/modem /dev/cua0 /dev/cua1 etc..."
  read MODEM_PATH
  if [ ! -a "$MODEM_PATH" ]
    then MODEM_PATH=""
    echo "$MODEM_PATH file not found..."
  fi
  done
echo
ISPLOGIN=""
while [ "$ISPLOGIN" = "" ]
  do
  echo "What name do you use as your username: or login: to your ISP?"
  read ISPLOGIN
  done
echo
ISPPASS=""
while [ "$ISPPASS" = "" ]
  do
  echo "What password do you use for $ISPLOGIN?"
  read ISPPASS
  done
echo
ISPPHONE=""
while [ "$ISPPHONE" = "" ]
  do
  echo "What is the phone number for your ISP?"
  read ISPPHONE
  done
echo
PPPNAME="dip-go"
  echo "What would you like to have your startup script called?"
  echo "The default is 'dip-go' just hit [Enter] for that..."
  read REPLY
  if [ "$REPLY" != "" ]
  then 
     PPPNAME=$REPLY
  fi
echo  
MODE="slip" 
  echo "What protocol? slip slip6 cslip cslip6 ppp (default is: slip)"
  read PROTOCOL
  if [ "$PROTOCOL" != "" ]
  then
   MODE=$PROTOCOL
  fi
echo
echo "  Domain:          $DNAME"
echo "  Gateway:         $GATEIP"
echo "  Modem path:      $MODEM_PATH"
echo "  Login:           $ISPLOGIN"
echo "  Password:        $ISPPASS"
echo "  Phone number:    $ISPPHONE"
echo "  Dip startup:	   $PPPNAME"
echo "  Modem init:      AT&FW2"
echo "  Modem speed:     38400"
echo "  Protocol:        $MODE"
echo
echo "Does this look correct? (Y/n)"
echo "Anything that can't be changed here, can be changed in" 
echo "the /root/.dip.script file...(i.e. Modem init & speed...)"
read CONT
if [ "$CONT" = "n" ] 
then exit
elif [ "$CONT" = "N" ] 
then exit
fi

echo "rm -f /var/lock/LCK* /var/spool/uucp/LCK* /var/run/dip.pid" > /usr/sbin/$PPPNAME 
echo "dip /root/.dip.script" >> /usr/sbin/$PPPNAME

if [ -s /etc/resolv.conf ]; then
mv /etc/resolv.conf /etc/resolv.conf.old
fi

echo "domain $DNAME" > /etc/resolv.conf
echo "nameserver $GATEIP" >> /etc/resolv.conf

cat /usr/sbin/dip.mold | 
sed /"# This is a mold dip script, it is used as a reference by 'dipsetup' for"/d |
sed s/"# creating a dip script.../# This is a dip script created by dipsetup..."/g > /tmp/dip.mold.tmp
    
cat /tmp/dip.mold.tmp | sed s/GATEWAY_ADDRESS/"$GATEIP"/g | 
sed s-PORT-"$MODEM_PATH"-g | 
sed s/PHONE_NUMBER/"$ISPPHONE"/g | 
sed s/LOGIN/"$ISPLOGIN"/g | 
sed s/PASS/"$ISPPASS"/g |
sed s-PROTOCOL-"$MODE"-g > /root/.dip.script  

rm -f /tmp/dip.mold.tmp   
echo "Adding /root/.dip.script & /usr/sbin/$PPPNAME"
chown root.root /root/.dip.script
chmod 0600 /root/.dip.script

chown root.root /usr/sbin/$PPPNAME
chmod 751 /usr/sbin/$PPPNAME

echo "DONE..."
echo 
echo "***NOTE: If your ISP account doesn't automatically start SLIP/PPP"
echo "         right away (ie after you give your password you must type"
echo "         'slip' 'ppp' or something) or requires another step (ie"
echo "         'annex:' number) edit the /root/.dip.script file, there" 
echo "         are comments that tell you what to do."
echo
echo "         To connect to your service provider do this:  ~# $PPPNAME"
echo "         CONNECTED -> 208.115.112.97   <-You should be connected"
echo "         when you receive a remote IP address like above."
echo "         To kill dip and the slip/cslip/ppp connection: # dip -k" 
echo                
[ RETURN TO DIRECTORY ]