#!/bin/sh # # Author : Edouard Gomez # Last Modifs : May, the 7th 2002 # # ToDo : this needs a special module configuration for debian # which uses files in /etc/modules/ and then run update-modules # # Configuration script for the pppd daemon PEER="adsl" PPP_DIR="/etc/ppp" PEER_DIR=$PPP_DIR"/peers" PEER_FILE=$PEER_DIR"/"$PEER CHAP_FILE="/etc/ppp/chap-secrets" PAP_FILE="/etc/ppp/pap-secrets" PPPOA3=`which pppoa3` WHOAMI=`whoami` echo "PPPD Configuration Script for GNU/Linux" echo if [ "$WHOAMI" != "root" ]; then echo "You must launch this script with root privileges" exit -1 fi if [ ! -x $PPOA3 ] ; then echo "You must install the drivers first" exit -1 fi # Reads user input read -p "Login : " LOGIN read -p "Password : " PASSWORD cat << EOF You will be prompted for your Vpi Vci, Here are some working values but your configuration may differ +----------------+---------+ | Country | vpi.vci | +----------------+---------+ |Belgium, ? | 8.35 | +----------------+---------+ |Denmark, Orange | 8.35 | +----------------+---------+ |France, wanadoo | 8.35 | +----------------+---------+ |France, ? | 8.67 | +----------------+---------+ |Italy, ? | 8.35 | +----------------+---------+ |Netherlands, ? | 8.48 | +----------------+---------+ |UK, BTopenworld | 0.38 | +----------------+---------+ |US, BellSouth | 8.35 | +----------------+---------+ EOF read -p "Your Vpi : " VPI read -p "Your Vci : " VCI cat << EOF Now you will be prompted for some pppd options Answer Y/y or N/n EOF read -p "Do you want pppd to reconnect automatically ? : " PERSISTA read -p "Do you want pppd to use peer DNS ? : " DNSPEERA read -p "Do you want to set the adsl connection as your default route ? : " DEFA echo "Do you want pppd to be in debug mode ?" read -p "(usefull if you install this package for the 1st time) : " DEBUGA if [ $PERSISTA == "Y" ] || [ $PERSISTA == "y" ] ; then PERSIST="persist" else PERSIST="#persist" fi if [ $DNSPEERA == "Y" ] || [ $DNSPEERA == "y" ] ; then DNSPEER="usepeerdns" else DNSPEER="#usepeerdns" fi if [ $DEFA == "Y" ] || [ $DEFA == "y" ] ; then DEF="defaultroute" else DEF="#defaultroute" fi if [ $DEBUGA == "Y" ] || [ $DEBUGA =="y" ] ; then DEBUG1="debug" DEBUG2="kdebug 1" else DEBUG1="#debug" DEBUG2="#kdebug 1" fi # Generates chap/pap-secrets line SECRETLINE="\"$LOGIN\" \"*\" \"$PASSWORD\" \"*\"" # Generates the user line needed in /etc/ppp/peers/adsl USERLINE="user \"$LOGIN\"" # Creates /etc/ppp/peers if [ ! -d $PEER_DIRECTORY ] ; then echo "Creating /etc/ppp/peers directory" mkdir /etc/ppp/peers fi # Check /etc/ppp/peers/adsl existence if [ -f $PEER_FILE ] ; then read -p "Do you want to overwrite $PEER_FILE (y/n) : " ANSWER if [ $ANSWER == "n" ] || [ $ANSWER == "N" ] ; then exit 1 fi rm -f $PEER_FILE touch $PEER_FILE fi # # Generates /etc/ppp/peers/adsl file # echo Generating $PEER_FILE echo "PPPoA3 is located there : $PPPOA3" cat > $PEER_FILE < $PPP_DIR"/options" << EOF lock noauth noipdefault usepeerdns EOF # # Generates user/password entry in chap and pap secrets files # # Creates the chap file if needed if [ ! -f $CHAP_FILE ] ; then echo Creating $CHAP_FILE touch $CHAP_FILE chmod 600 $CHAP_FILE echo "# Secrets for authentication using CHAP" > $CHAP_FILE echo "# client server secret IP addresses" >> $CHAP_FILE fi # Creates the pap file if needed if [ ! -f $PAP_FILE ] ; then echo Creating $PAP_FILE touch $PAP_FILE chmod 600 $PAP_FILE echo "# Secrets for authentication using PAP" > $PAP_FILE echo "# client server secret IP addresses" >> $PAP_FILE fi # Saves old files echo Saving old $CHAP_FILE to $CHAP_FILE.old cp -f $CHAP_FILE $CHAP_FILE.old chmod 600 $CHAP_FILE.old echo Saving old $PAP_FILE to $PAP_FILE.old cp -f $PAP_FILE $PAP_FILE.old chmod 600 $PAP_FILE.old # Remove old login entry from pap and chap file echo Removing old $LOGIN entry from $CHAP_FILE grep -v $LOGIN $CHAP_FILE.old > $CHAP_FILE echo Removing old $LOGIN entry from $PAP_FILE grep -v $LOGIN $PAP_FILE.old > $PAP_FILE # Add the new entry echo Adding new $LOGIN entry to $CHAP_FILE echo $SECRETLINE >> $CHAP_FILE echo Adding new $LOGIN entry to $PAP_FILE echo $SECRETLINE >> $PAP_FILE # # Add ppp entries to /etc/modules.conf # if [ -f /etc/conf.modules ] ; then MODULE_CONF="/etc/conf.modules" fi if [ -f /etc/modules.conf ] ; then MODULE_CONF="/etc/modules.conf" fi # # We handle the Debian way here # if [ -f /etc/debian_version ]; then MODULE_CONF="/etc/modutils/hdlc" echo "Configuring the modules.conf the debian way !" fi echo "Adding ppp entries to your $MODULE_CONF" # This bunch of aliases are already defined in debian systems if [ ! -f /etc/debian_version ]; then echo >> $MODULE_CONF grep -q "char-major-108" $MODULE_CONF if [ $? -ne 0 ] ; then echo "alias char-major-108 ppp_generic" >> $MODULE_CONF fi grep -q "tty-ldisc-3" $MODULE_CONF if [ $? -ne 0 ] ; then echo "alias tty-ldisc-3 ppp_async" >> $MODULE_CONF fi fi # This one needs to be added in every case grep -q "tty-ldisc-13" $MODULE_CONF if [ $? -ne 0 ] ; then echo "alias tty-ldisc-13 n_hdlc" >> $MODULE_CONF fi # This bunch of aliases are also already defined in debian systems if [ ! -f /etc/debian_version ]; then grep -q "tty-ldisc-14" $MODULE_CONF if [ $? -ne 0 ] ; then echo "alias tty-ldisc-14 ppp_synctty" >> $MODULE_CONF fi grep -q "ppp-compress-21" $MODULE_CONF if [ $? -ne 0 ] ; then echo "alias ppp-compress-21 bsd_comp" >> $MODULE_CONF fi grep -q "ppp-compress-24" $MODULE_CONF if [ $? -ne 0 ] ; then echo "alias ppp-compress-24 ppp_deflate" >> $MODULE_CONF fi grep -q "ppp-compress-26" $MODULE_CONF if [ $? -ne 0 ] ; then echo "alias ppp-compress-26 ppp_deflate" >> $MODULE_CONF fi fi # # We update the /etc/modules.conf with the debian tool # if [ -f /etc/debian_version ]; then echo "Updating /etc/modules.conf using update-modules" update-modules fi # Finished... echo echo PPPD configuration done.