371 lines
9.4 KiB
Bash
Executable File
371 lines
9.4 KiB
Bash
Executable File
#!/bin/sh
|
||
# $Id: dialup.en,v 1.3 1998/08/07 19:29:57 abial Exp $
|
||
set_resolv() {
|
||
echo "[H[J"
|
||
echo "[1m Default Domain Name[m"
|
||
echo ""
|
||
echo "Here you should enter your default Internet domain. If your"
|
||
echo "provider uses something like 'www.big.isp.com', this should"
|
||
echo "be most probably 'big.isp.com'."
|
||
echo ""
|
||
echo "If you simply press enter here, you will have a 'mydomain.edu',"
|
||
echo "which is not the best idea, but may suffice for now..."
|
||
echo ""
|
||
read -p "Please enter the default domain name: " domain
|
||
if [ "X${domain}" = "X" ]
|
||
then
|
||
echo ""
|
||
echo "Fine, your domain will be 'mydomain.edu', but be aware"
|
||
echo "that it probably doesn't exist."
|
||
echo ""
|
||
read -p "Press any key to continue." junk
|
||
domain="mydomain.edu"
|
||
fi
|
||
echo "[H[J"
|
||
echo "[1m DNS Server Address[m"
|
||
echo ""
|
||
echo "Here you should enter the numeric address of your domain name"
|
||
echo "server. It is needed for resolving human-readable host names"
|
||
echo "(such as www.freebsd.org) to machine readable IP numbers. If"
|
||
echo "it's not set properly, you will have to use numeric IP addresses"
|
||
echo "when connecting to other hosts, which is highly inconvenient."
|
||
echo ""
|
||
echo "If you simply press Enter here, we'll set it to one of root"
|
||
echo "DNS servers. This may not always work."
|
||
echo ""
|
||
read -p "Please enter the DNS server address in form A.B.C.D: " dns
|
||
if [ "X${dns}" = "X" ]
|
||
then
|
||
echo ""
|
||
echo "Fine, your DNS server will be 192.33.4.12, but be aware"
|
||
echo "that this may not always work ok."
|
||
echo ""
|
||
read -p "Press any key to continue." junk
|
||
dns="192.33.4.12"
|
||
fi
|
||
}
|
||
|
||
set_phone() {
|
||
while [ "X${phone}" = "X" ]
|
||
do
|
||
echo "[H[J"
|
||
echo "[1m Phone Number[m"
|
||
echo ""
|
||
echo "Here you should enter the full phone number you normally"
|
||
echo "use to connect to your provider, with all necessary prefixes"
|
||
echo "attached, e.g.: 01122334455"
|
||
echo ""
|
||
read -p "Please enter the phone number: " phone
|
||
done
|
||
}
|
||
|
||
set_port() {
|
||
while [ "X${dev}" = "X" ]
|
||
do
|
||
echo "[H[J"
|
||
echo "[1m Port Number[m"
|
||
echo ""
|
||
echo "Here you should enter the port number, to which your modem is"
|
||
echo "attached. REMEMBER: COM1 is port 0 in FreeBSD, COM2 - port 1,"
|
||
echo "and so on. You should enter only the number, not the full name"
|
||
echo "of the device."
|
||
echo ""
|
||
read -p "Please enter the port number (0,1,2): " dev
|
||
done
|
||
}
|
||
|
||
set_speed() {
|
||
while [ "X${speed}" = "X" ]
|
||
do
|
||
echo "[H[J"
|
||
echo "[1m Port Speed[m"
|
||
echo ""
|
||
echo "Here you should choose the serial port speed."
|
||
echo ""
|
||
echo "NOTICE: port speed is NOT the same as modem speed - these are"
|
||
echo "different things. If your modem is capable of V.42 or MNP"
|
||
echo "compression, the actual speed of serial port should be set much"
|
||
echo "higher. E.g. for 14.4 kbps modem with compression you should"
|
||
echo "choose 38400, for 28.8 kbps modem with compression you should"
|
||
echo "choose 115200."
|
||
echo ""
|
||
echo " 1. 9600 bps"
|
||
echo " 2. 14400 bps"
|
||
echo " 3. 28800 bps"
|
||
echo " 4. 38400 bps (14.4 kbps modem with compression)"
|
||
echo " 5. 57600 bps"
|
||
echo " 6. 115200 bps (28.8 kbps modem with compression)"
|
||
echo ""
|
||
read -p "Please choose the port speed (1-6): " ans
|
||
case ${ans} in
|
||
1)
|
||
speed=9600
|
||
;;
|
||
2)
|
||
speed=14400
|
||
;;
|
||
3)
|
||
speed=28800
|
||
;;
|
||
4)
|
||
speed=38400
|
||
;;
|
||
5)
|
||
speed=57600
|
||
;;
|
||
6)
|
||
speed=115200
|
||
;;
|
||
*)
|
||
read -p "Bad value! Press enter to continue..." junk
|
||
unset speed
|
||
;;
|
||
esac
|
||
done
|
||
}
|
||
|
||
set_timeout() {
|
||
while [ "X${timo}" = "X" ]
|
||
do
|
||
echo "[H[J"
|
||
echo "[1m Idle Timeout[m"
|
||
echo ""
|
||
echo "Here you should enter timeout (in seconds). After this time, if"
|
||
echo "the connection is idle, it's disconnected (to save your money :-)"
|
||
echo ""
|
||
read -p "Please enter the timeout value: " timo
|
||
done
|
||
}
|
||
|
||
set_login() {
|
||
while [ "X${user}" = "X" ]
|
||
do
|
||
echo "[H[J"
|
||
echo "[1m Login Name[m"
|
||
echo ""
|
||
echo "Here you should enter your login name that you normally use"
|
||
echo "to log in to your provider's terminal server."
|
||
echo ""
|
||
read -p "Please enter your login name: " user
|
||
done
|
||
}
|
||
|
||
set_password() {
|
||
while [ "X${pass}" = "X" ]
|
||
do
|
||
echo "[H[J"
|
||
echo "[1m Password[m"
|
||
echo ""
|
||
echo "Here you enter the password that you use to log in to the"
|
||
echo "terminal server."
|
||
echo ""
|
||
echo "[31mWARNING: your password will be stored in readable form on the"
|
||
echo "floppy!!! If you don't like it... well, you must dial in manually."
|
||
echo "In that case abort this script (Ctrl-C). Otherwise, continue.[37m"
|
||
echo ""
|
||
read -p "Please enter your password: " pass
|
||
done
|
||
}
|
||
|
||
set_chat() {
|
||
echo "[H[J"
|
||
while [ "X${chat}" = "X" ]
|
||
do
|
||
echo "[1m Type of Login Dialog[m"
|
||
echo ""
|
||
echo "What type of login dialog do you expect from the terminal server?"
|
||
echo ""
|
||
echo "1) [32m......login:[37m ${user}"
|
||
echo " [32m...password:[37m ********"
|
||
echo " [36m(terminal server starts PPP here)[37m"
|
||
echo ""
|
||
echo "2) [32m......login:[37m ${user}"
|
||
echo " [32m...password:[37m ********"
|
||
echo " [32m...protocol:[37m ppp"
|
||
echo " [36m(terminal server starts PPP here)[37m"
|
||
echo ""
|
||
echo "3) [32m......username:[37m ${user}"
|
||
echo " [32m......password:[37m ********"
|
||
echo " [36m(terminal server starts PPP here)[37m"
|
||
echo ""
|
||
echo "4) [32m......username:[37m ${user}"
|
||
echo " [32m......password:[37m ********"
|
||
echo " [32mportX/..xxx...:[37m ppp"
|
||
echo " [36m(terminal server starts PPP here)[37m"
|
||
echo ""
|
||
read -p "Choose 1,2,3 or 4: " chat
|
||
case ${chat} in
|
||
1)
|
||
chat1="TIMEOUT 10 ogin:--ogin: ${user} word: \\\\P"
|
||
chat2="login/password"
|
||
;;
|
||
2)
|
||
chat1="TIMEOUT 10 ogin:--ogin: ${user} word: \\\\P otocol: ppp"
|
||
chat2="login/password/protocol"
|
||
;;
|
||
3)
|
||
chat1="TIMEOUT 10 ername:--ername: ${user} word: \\\\P"
|
||
chat2="username/password"
|
||
;;
|
||
4)
|
||
chat1="TIMEOUT 10 ername:--ername: ${user} word: \\\\P port ppp"
|
||
chat2="username/password/port"
|
||
;;
|
||
*) echo "Bad value! Please choose 1,2,3 or 4."
|
||
echo ""
|
||
unset chat
|
||
unset chat2
|
||
;;
|
||
esac
|
||
done
|
||
}
|
||
|
||
# Main entry of the script
|
||
|
||
echo "[H[J"
|
||
echo "[1m Welcome to The Simplest PPP Configurator! :-)[m"
|
||
echo ""
|
||
echo " Your PPP is already preconfigured, so that you can dial manually."
|
||
echo "However, you probably noticed that it requires chatting with your modem"
|
||
echo "and logging in every time you want to connect. It's simple and it works,"
|
||
echo "but it's also annoying."
|
||
echo ""
|
||
echo "This script will try to configure your PPP so that you can run it in"
|
||
echo "background (thus freeing the console), and log in automatically."
|
||
echo ""
|
||
echo "If you want to continue, press [1mEnter[m, otherwise press [1mCtrl-C[m."
|
||
echo ""
|
||
read junk
|
||
|
||
# Step through the options.
|
||
set_phone
|
||
set_port
|
||
set_speed
|
||
set_timeout
|
||
set_login
|
||
set_password
|
||
set_chat
|
||
set_resolv
|
||
|
||
ans="loop_it"
|
||
while [ "X${ans}" != "X" ]
|
||
do
|
||
|
||
echo "[H[J"
|
||
echo "[1m Ok. You assigned the following values:[m"
|
||
echo ""
|
||
echo " 1. Phone number: ${phone}"
|
||
echo " 2. Port number: cuaa${dev}"
|
||
echo " 3. Port speed: ${speed} baud"
|
||
echo " 4. Timeout: ${timo} s"
|
||
echo " 5. Login name: ${user}"
|
||
echo " 6. Password: ${pass}"
|
||
echo " 7. Chat pattern: ${chat} (${chat2})"
|
||
echo " 8. Default domain: ${domain}"
|
||
echo " DNS Server: ${dns}"
|
||
echo ""
|
||
echo "If you're satisfied with these values, just press [1mEnter[m."
|
||
read -p "Otherwise, enter the number of the option you want to change (1-8): " ans
|
||
a="X${ans}"
|
||
case ${a} in
|
||
X1)
|
||
unset phone
|
||
set_phone
|
||
;;
|
||
X2)
|
||
unset dev
|
||
set_port
|
||
;;
|
||
X3)
|
||
unset speed
|
||
set_speed
|
||
;;
|
||
X4)
|
||
unset timo
|
||
set_timeout
|
||
;;
|
||
X5)
|
||
unset user
|
||
set_login
|
||
;;
|
||
X6)
|
||
unset pass
|
||
set_password
|
||
;;
|
||
X7)
|
||
unset chat
|
||
set_chat
|
||
;;
|
||
X8)
|
||
unset dns
|
||
unset domain
|
||
set_resolv
|
||
;;
|
||
X) ;;
|
||
*)
|
||
read -p "Unknown option: ${ans}. Press enter to continue..."
|
||
;;
|
||
esac
|
||
|
||
done
|
||
|
||
echo ""
|
||
echo -n "Generating /etc/ppp/ppp.conf file..."
|
||
rm -f /etc/ppp/ppp.conf
|
||
cp /etc/ppp/ppp.conf.template /etc/ppp/ppp.conf
|
||
echo "" >>/etc/ppp/ppp.conf
|
||
echo "# This part was generated with $0" >>/etc/ppp/ppp.conf
|
||
echo "dialup:" >>/etc/ppp/ppp.conf
|
||
echo " set line /dev/cuaa${dev}" >>/etc/ppp/ppp.conf
|
||
echo " set speed ${speed}" >>/etc/ppp/ppp.conf
|
||
echo " set phone ${phone}" >>/etc/ppp/ppp.conf
|
||
echo " set authkey ${pass}" >>/etc/ppp/ppp.conf
|
||
echo " set timeout ${timo}" >>/etc/ppp/ppp.conf
|
||
echo " set login \"${chat1}\"" >>/etc/ppp/ppp.conf
|
||
echo " set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0" >>/etc/ppp/ppp.conf
|
||
|
||
echo " Done."
|
||
echo -n "Generating /etc/resolv.conf..."
|
||
echo "# This file was generated with $0">/etc/resolv.conf
|
||
echo "domain ${domain}" >>/etc/resolv.conf
|
||
echo "nameserver ${dns}">>/etc/resolv.conf
|
||
echo "hostname=\"pico.${domain}\"">>/etc/rc.conf
|
||
|
||
echo " Done."
|
||
|
||
echo ""
|
||
echo "REMEMBER to run /stand/update! Otherwise these changes will be lost!"
|
||
echo ""
|
||
echo "Please check the contents of /etc/ppp/ppp.conf, and edit it if"
|
||
echo "necessary. When you're satisfied with it, run ppp in background:"
|
||
echo ""
|
||
echo " [1mppp -background dialup[m"
|
||
echo ""
|
||
echo "Now, if you're sure that your /etc/ppp/ppp.conf file is ok (which is"
|
||
echo -n "probable :-) would you like to start the dialup connection now? (y/n) "
|
||
read ans
|
||
while [ "X${ans}" = "Xy" ]
|
||
do
|
||
echo "[H[J"
|
||
echo "Starting dialup connection. Wait until you see a 'PPP Enabled' message..."
|
||
echo ""
|
||
ppp -background dialup
|
||
if [ "X$?" != "X0" ]
|
||
then
|
||
echo ""
|
||
echo -n "Hmmm... Command failed. Try again? (y/n) "
|
||
read ans
|
||
if [ "X${ans}" != "Xy" ]
|
||
then
|
||
echo ""
|
||
echo "Try again later. Check also your config file (/etc/ppp/ppp.conf)"
|
||
echo ""
|
||
fi
|
||
else
|
||
echo ""
|
||
echo "Congratulations! You're on-line now."
|
||
echo ""
|
||
exit 0
|
||
fi
|
||
done
|