#!/bin/sh # # ncf-ppp-2.4 * Feb 1999 * Jeff East (an972) # # - bash script to install basic PPP files on a Linux system for # connecting to the National Capital Freenet (NCF) # - this script is self-contained, and creates files in directories # /etc and /etc/ppp # # Changes: # - text adjusted for easier reading # - slight change testing for ppp/chat installation # - link to ppp-ncf placed in /usr/local/bin # - setuid pppd in case your distribution needs it # - phone numbers now reflect changes made late February 1999 ###################### install portion ############################ echo "" # test for running as root - else give error and quit if [ "$UID" != "0" ]; then echo "** You are not root. You must run this as root." echo "No changes were make to your system." exit fi # test for the pppd package if [ ! -f "/usr/sbin/pppd" ]; then echo "** You don't have the 'pppd/chat' package installed. You must" echo " install this." echo "No changes were make to your system." exit fi # prompt for user's values echo " NCF PPP install for Linux systems" echo " ---------------------------------" echo echo "** You can abort (control-C) at any prompt, and your system will" echo " not be altered." echo "" echo "This script will not do any error checking on what you enter, so" echo "make sure that you're careful. In any event, you can re-run this" echo "script later and overwrite your previous entries." echo echo -n "-- enter your Freenet login ID: " read NCF_ID echo -n "-- enter your Freenet password: " read NCF_PASSWORD echo "-- enter your modem device (without the '/dev/')" echo -n " (it might be 'modem' or 'ttyS1' or ...) : " read MODEM_DEVICE echo "-- enter a speed to operate your modem at" echo " (for modern modems, use a speed two or more times faster than its" echo " connection speed; ie use 38400 or 57600 for a '14400' modem)" echo -n " ?: " read MODEM_SPEED echo "-- enter an initialization string for your modem" echo " (it should enable hardware handshaking, not software handshaking;" echo -n " example: 'AT&F1M1' for a USR Sportster) : " read MODEM_INIT_STRING echo -n "-- do you want verbose debugging messages? (y/n) " read TEMP if [ "$TEMP" = "y" ]; then DEBUG='-v' else DEBUG='' fi echo -n "-- do you have call waiting on your phone line? (y/n) " read TEMP if [ "$TEMP" = "y" ]; then CALL_WAITING='*70,' else CALL_WAITING='' fi echo echo "** I am now going to preserve your original files and make the new ones." echo -n "** Hit to proceed, or to abort. " read TEMP # rename old files (if they exist) to 'origfilename.orig' # - WON'T overwrite an existing 'filename.orig' mv /etc/ppp/pap-secrets /etc/ppp/pap-secrets.orig 2> /dev/null mv /etc/ppp/options /etc/ppp/options.orig 2> /dev/null mv /etc/host.conf /etc/host.conf.orig 2> /dev/null mv /etc/resolv.conf /etc/resolv.conf.orig 2> /dev/null ########################## make the files ########################## cat - > /etc/ppp/ppp-ncf <<-EOF #!/bin/sh # ppp-ncf # - connect/disconnect to Freenet via PPP # - calls the script /etc/ppp/freenet.dialer # - command-line parameter (becomes variable 'LINE') can be: # "help"/"-h" or "off" # or "slow", "fast", or "mitel" (see freenet.dialer), # - phone numbers reflect NCF changes late February 1999 # - password information stored in /etc/ppp/pap-secrets # - user watches the /var/log/messages file for status LINE=\$1 case \$LINE in 'help' | '-h' ) echo "Usage: \$0 [ slow | fast | mitel | off ]" ;; 'off' ) kill \`pidof -x freenet-dialer\` kill -INT \`/sbin/pidof pppd\` ;; * ) export LINE insmod ppp 2> /dev/null /usr/sbin/pppd user $NCF_ID connect /etc/ppp/freenet-dialer # watch the connection process with 'tail' # - you can comment this out later if you don't like it tail -f /var/log/messages ;; esac EOF cat - > /etc/ppp/freenet-dialer <<-EOF #!/bin/sh #freenet-dialer # - dial using environment variable 'LINE' # - phone numbers reflect NCF changes late February 1999 MAX_REDIALS=50 case \$LINE in 'slow' ) TELEPHONE=5201130 ;; 'fast' ) TELEPHONE=5207835 ;; 'mitel' ) TELEPHONE=2719768 ;; * ) TELEPHONE=5207835 ;; # default to fast modems esac # initialize modem /usr/sbin/chat $DEBUG TIMEOUT 3 '' '$MODEM_INIT_STRING' OK '' if [ "\$?" != "0" ]; then exit 1 fi # Dial telephone number until connection is made attempt=0 while : ; do attempt=\`expr \$attempt + 1\` # dial and login /usr/sbin/chat $DEBUG \\ TIMEOUT 4 \\ ABORT 'BUSY' \\ ABORT 'NO CARRIER' \\ ABORT 'NO DIALTONE' \\ ABORT 'RING' \\ ABORT 'Command not found' \\ '' 'at' \\ 'OK'-+++-'OK' 'ath' \\ 'ath' '\c' \\ TIMEOUT 40 \\ OK atdt$CALL_WAITING\$TELEPHONE \\ CONNECT '\c' # leave chat, and let pppd do PAP authentication if [ "\$?" = "0" ]; then # We connected! - exit script - pass '0' to pppd exit 0 fi if [ "\$attempt" = "\$MAX_REDIALS" ]; then # We failed! - pass '1' to pppd exit 1 fi done EOF cat - > /etc/ppp/pap-secrets <<-EOF # Secrets for authentication using PAP # client server secret IP addresses $NCF_ID * $NCF_PASSWORD EOF cat - > /etc/ppp/options <<-EOF /dev/$MODEM_DEVICE $MODEM_SPEED modem lock crtscts defaultroute asyncmap 0 mtu 1500 mru 1500 ipcp-accept-local ipcp-accept-remote EOF cat - > /etc/resolv.conf <<-EOF domain localhost search ncf.carleton.ca carleton.ca # Freenet DNS #1 nameserver 134.117.137.1 # Mitel DNS ? nameserver 209.89.174.193 # Freenet DNS #2 nameserver 134.117.136.24 EOF cat - > /etc/host.conf <<-EOF order hosts,bind multi on EOF # change ownerships/permission on all files we created chmod 755 /etc/ppp/ppp-ncf chmod 755 /etc/ppp/freenet-dialer chmod 600 /etc/ppp/pap-secrets chmod 644 /etc/ppp/options chmod 644 /etc/host.conf chmod 644 /etc/resolv.conf # make sure pppd has setuid bit set chmod +s /usr/sbin/pppd # allow all users to read /var/log/messages chmod a+r /var/log/messages # link to ppp-ncf in a common PATH directory ln -s /etc/ppp/ppp-ncf /usr/local/bin/ppp-ncf echo "" echo "** Done. Did you see any error messages?"